From python-3000-checkins at python.org Fri Jun 1 04:32:46 2007 From: python-3000-checkins at python.org (brett.cannon) Date: Fri, 1 Jun 2007 04:32:46 +0200 (CEST) Subject: [Python-3000-checkins] r55724 - in python/branches/p3yk: Doc/mac/undoc.tex Lib/plat-mac/cfmfile.py Misc/NEWS Message-ID: <20070601023246.B26B21E400E@bag.python.org> Author: brett.cannon Date: Fri Jun 1 04:32:41 2007 New Revision: 55724 Removed: python/branches/p3yk/Lib/plat-mac/cfmfile.py Modified: python/branches/p3yk/Doc/mac/undoc.tex python/branches/p3yk/Misc/NEWS Log: Remove the cfmfile. Modified: python/branches/p3yk/Doc/mac/undoc.tex ============================================================================== --- python/branches/p3yk/Doc/mac/undoc.tex (original) +++ python/branches/p3yk/Doc/mac/undoc.tex Fri Jun 1 04:32:41 2007 @@ -23,18 +23,6 @@ \deprecated{2.4}{} -\section{\module{cfmfile} --- Code Fragment Resource module} -\declaremodule{standard}{cfmfile} - \platform{Mac} -\modulesynopsis{Code Fragment Resource module.} - -\module{cfmfile} is a module that understands Code Fragments and the -accompanying ``cfrg'' resources. It can parse them and merge them, and is -used by BuildApplication to combine all plugin modules to a single -executable. - -\deprecated{2.4}{} - \section{\module{icopen} --- Internet Config replacement for \method{open()}} \declaremodule{standard}{icopen} \platform{Mac} Deleted: /python/branches/p3yk/Lib/plat-mac/cfmfile.py ============================================================================== --- /python/branches/p3yk/Lib/plat-mac/cfmfile.py Fri Jun 1 04:32:41 2007 +++ (empty file) @@ -1,183 +0,0 @@ -"""codefragments.py -- wrapper to modify code fragments.""" - -# (c) 1998, Just van Rossum, Letterror - -__version__ = "0.8b3" -__author__ = "jvr" - -import Carbon.File -import struct -from Carbon import Res -import os -import sys - -DEBUG = 0 - -error = "cfm.error" - -BUFSIZE = 0x80000 - -def mergecfmfiles(srclist, dst, architecture = 'fat'): - """Merge all files in srclist into a new file dst. - - If architecture is given, only code fragments of that type will be used: - "pwpc" for PPC, "m68k" for cfm68k. This does not work for "classic" - 68k code, since it does not use code fragments to begin with. - If architecture is None, all fragments will be used, enabling FAT binaries. - """ - - srclist = list(srclist) - for i in range(len(srclist)): - srclist[i] = Carbon.File.pathname(srclist[i]) - dst = Carbon.File.pathname(dst) - - dstfile = open(dst, "wb") - rf = Res.FSpOpenResFile(dst, 3) - try: - dstcfrg = CfrgResource() - for src in srclist: - srccfrg = CfrgResource(src) - for frag in srccfrg.fragments: - if frag.architecture == 'pwpc' and architecture == 'm68k': - continue - if frag.architecture == 'm68k' and architecture == 'pwpc': - continue - dstcfrg.append(frag) - - frag.copydata(dstfile) - - cfrgres = Res.Resource(dstcfrg.build()) - Res.UseResFile(rf) - cfrgres.AddResource('cfrg', 0, "") - finally: - dstfile.close() - rf = Res.CloseResFile(rf) - - -class CfrgResource: - - def __init__(self, path = None): - self.version = 1 - self.fragments = [] - self.path = path - if path is not None and os.path.exists(path): - currentresref = Res.CurResFile() - resref = Res.FSpOpenResFile(path, 1) - Res.UseResFile(resref) - try: - try: - data = Res.Get1Resource('cfrg', 0).data - except Res.Error: - raise Res.Error, "no 'cfrg' resource found", sys.exc_info()[2] - finally: - Res.CloseResFile(resref) - Res.UseResFile(currentresref) - self.parse(data) - if self.version != 1: - raise error, "unknown 'cfrg' resource format" - - def parse(self, data): - (res1, res2, self.version, - res3, res4, res5, res6, - self.memberCount) = struct.unpack("8l", data[:32]) - data = data[32:] - while data: - frag = FragmentDescriptor(self.path, data) - data = data[frag.memberSize:] - self.fragments.append(frag) - - def build(self): - self.memberCount = len(self.fragments) - data = struct.pack("8l", 0, 0, self.version, 0, 0, 0, 0, self.memberCount) - for frag in self.fragments: - data = data + frag.build() - return data - - def append(self, frag): - self.fragments.append(frag) - - -class FragmentDescriptor: - - def __init__(self, path, data = None): - self.path = path - if data is not None: - self.parse(data) - - def parse(self, data): - self.architecture = data[:4] - ( self.updatelevel, - self.currentVersion, - self.oldDefVersion, - self.stacksize, - self.applibdir, - self.fragtype, - self.where, - self.offset, - self.length, - self.res1, self.res2, - self.memberSize,) = struct.unpack("4lhBB4lh", data[4:42]) - pname = data[42:self.memberSize] - self.name = pname[1:1+ord(pname[0])] - - def build(self): - data = self.architecture - data = data + struct.pack("4lhBB4l", - self.updatelevel, - self.currentVersion, - self.oldDefVersion, - self.stacksize, - self.applibdir, - self.fragtype, - self.where, - self.offset, - self.length, - self.res1, self.res2) - self.memberSize = len(data) + 2 + 1 + len(self.name) - # pad to 4 byte boundaries - if self.memberSize % 4: - self.memberSize = self.memberSize + 4 - (self.memberSize % 4) - data = data + struct.pack("hb", self.memberSize, len(self.name)) - data = data + self.name - data = data + '\000' * (self.memberSize - len(data)) - return data - - def getfragment(self): - if self.where != 1: - raise error, "can't read fragment, unsupported location" - f = open(self.path, "rb") - f.seek(self.offset) - if self.length: - frag = f.read(self.length) - else: - frag = f.read() - f.close() - return frag - - def copydata(self, outfile): - if self.where != 1: - raise error, "can't read fragment, unsupported location" - infile = open(self.path, "rb") - if self.length == 0: - infile.seek(0, 2) - self.length = infile.tell() - - # Position input file and record new offset from output file - infile.seek(self.offset) - - # pad to 16 byte boundaries - offset = outfile.tell() - if offset % 16: - offset = offset + 16 - (offset % 16) - outfile.seek(offset) - self.offset = offset - - l = self.length - while l: - if l > BUFSIZE: - outfile.write(infile.read(BUFSIZE)) - l = l - BUFSIZE - else: - outfile.write(infile.read(l)) - l = 0 - infile.close() Modified: python/branches/p3yk/Misc/NEWS ============================================================================== --- python/branches/p3yk/Misc/NEWS (original) +++ python/branches/p3yk/Misc/NEWS Fri Jun 1 04:32:41 2007 @@ -226,6 +226,9 @@ Mac --- +- The cfmfile was removed. + + New platforms ------------- From python-3000-checkins at python.org Fri Jun 1 07:19:55 2007 From: python-3000-checkins at python.org (neal.norwitz) Date: Fri, 1 Jun 2007 07:19:55 +0200 (CEST) Subject: [Python-3000-checkins] r55727 - in python/branches/p3yk: Demo/imputil/knee.py Doc/api/utilities.tex Doc/ext/extending.tex Doc/lib/libfuncs.tex Doc/lib/libimp.tex Doc/lib/libsys.tex Doc/lib/libzipimport.tex Doc/tut/tut.tex Lib/idlelib/StackViewer.py Lib/ihooks.py Lib/imputil.py Lib/pydoc.py Lib/test/infinite_reload.py Lib/test/output/test_pkg Lib/test/regrtest.py Lib/test/test_builtin.py Lib/test/test_doctest.py Lib/test/test_import.py Lib/test/test_importhooks.py Lib/test/test_pkg.py Lib/test/test_traceback.py Lib/test/test_xmlrpc.py Misc/NEWS Misc/cheatsheet Python/bltinmodule.c Message-ID: <20070601051955.CC6491E4003@bag.python.org> Author: neal.norwitz Date: Fri Jun 1 07:19:44 2007 New Revision: 55727 Removed: python/branches/p3yk/Lib/test/infinite_reload.py Modified: python/branches/p3yk/Demo/imputil/knee.py python/branches/p3yk/Doc/api/utilities.tex python/branches/p3yk/Doc/ext/extending.tex python/branches/p3yk/Doc/lib/libfuncs.tex python/branches/p3yk/Doc/lib/libimp.tex python/branches/p3yk/Doc/lib/libsys.tex python/branches/p3yk/Doc/lib/libzipimport.tex python/branches/p3yk/Doc/tut/tut.tex python/branches/p3yk/Lib/idlelib/StackViewer.py python/branches/p3yk/Lib/ihooks.py python/branches/p3yk/Lib/imputil.py python/branches/p3yk/Lib/pydoc.py python/branches/p3yk/Lib/test/output/test_pkg python/branches/p3yk/Lib/test/regrtest.py python/branches/p3yk/Lib/test/test_builtin.py python/branches/p3yk/Lib/test/test_doctest.py python/branches/p3yk/Lib/test/test_import.py python/branches/p3yk/Lib/test/test_importhooks.py python/branches/p3yk/Lib/test/test_pkg.py python/branches/p3yk/Lib/test/test_traceback.py python/branches/p3yk/Lib/test/test_xmlrpc.py python/branches/p3yk/Misc/NEWS python/branches/p3yk/Misc/cheatsheet python/branches/p3yk/Python/bltinmodule.c Log: Remove reload() builtin. Modified: python/branches/p3yk/Demo/imputil/knee.py ============================================================================== --- python/branches/p3yk/Demo/imputil/knee.py (original) +++ python/branches/p3yk/Demo/imputil/knee.py Fri Jun 1 07:19:44 2007 @@ -106,8 +106,7 @@ return m -# Replacement for reload() -def reload_hook(module): +def reload(module): name = module.__name__ if '.' not in name: return import_module(name, name, None) @@ -119,8 +118,6 @@ # Save the original hooks original_import = __builtin__.__import__ -original_reload = __builtin__.reload # Now install our hooks __builtin__.__import__ = import_hook -__builtin__.reload = reload_hook Modified: python/branches/p3yk/Doc/api/utilities.tex ============================================================================== --- python/branches/p3yk/Doc/api/utilities.tex (original) +++ python/branches/p3yk/Doc/api/utilities.tex Fri Jun 1 07:19:44 2007 @@ -140,10 +140,7 @@ \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PyImport_ReloadModule}{PyObject *m} - Reload a module. This is best described by referring to the - built-in Python function \function{reload()}\bifuncindex{reload}, as - the standard \function{reload()} function calls this function - directly. Return a new reference to the reloaded module, or \NULL{} + Reload a module. Return a new reference to the reloaded module, or \NULL{} with an exception set on failure (the module still exists in this case). \end{cfuncdesc} Modified: python/branches/p3yk/Doc/ext/extending.tex ============================================================================== --- python/branches/p3yk/Doc/ext/extending.tex (original) +++ python/branches/p3yk/Doc/ext/extending.tex Fri Jun 1 07:19:44 2007 @@ -400,11 +400,6 @@ \cfunction{exec()}) can create problems for some extension modules. Extension module authors should exercise caution when initializing internal data structures. -Note also that the \function{reload()} function can be used with -extension modules, and will call the module initialization function -(\cfunction{initspam()} in the example), but will not load the module -again if it was loaded from a dynamically loadable object file -(\file{.so} on \UNIX, \file{.dll} on Windows).} A more substantial example module is included in the Python source distribution as \file{Modules/xxmodule.c}. This file may be used as a Modified: python/branches/p3yk/Doc/lib/libfuncs.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libfuncs.tex (original) +++ python/branches/p3yk/Doc/lib/libfuncs.tex Fri Jun 1 07:19:44 2007 @@ -890,82 +890,6 @@ \end{verbatim} \end{funcdesc} -\begin{funcdesc}{reload}{module} - Reload a previously imported \var{module}. The - argument must be a module object, so it must have been successfully - imported before. This is useful if you have edited the module - source file using an external editor and want to try out the new - version without leaving the Python interpreter. The return value is - the module object (the same as the \var{module} argument). - - When \code{reload(module)} is executed: - -\begin{itemize} - - \item Python modules' code is recompiled and the module-level code - reexecuted, defining a new set of objects which are bound to names in - the module's dictionary. The \code{init} function of extension - modules is not called a second time. - - \item As with all other objects in Python the old objects are only - reclaimed after their reference counts drop to zero. - - \item The names in the module namespace are updated to point to - any new or changed objects. - - \item Other references to the old objects (such as names external - to the module) are not rebound to refer to the new objects and - must be updated in each namespace where they occur if that is - desired. - -\end{itemize} - - There are a number of other caveats: - - If a module is syntactically correct but its initialization fails, - the first \keyword{import} statement for it does not bind its name - locally, but does store a (partially initialized) module object in - \code{sys.modules}. To reload the module you must first - \keyword{import} it again (this will bind the name to the partially - initialized module object) before you can \function{reload()} it. - - When a module is reloaded, its dictionary (containing the module's - global variables) is retained. Redefinitions of names will override - the old definitions, so this is generally not a problem. If the new - version of a module does not define a name that was defined by the - old version, the old definition remains. This feature can be used - to the module's advantage if it maintains a global table or cache of - objects --- with a \keyword{try} statement it can test for the - table's presence and skip its initialization if desired: - -\begin{verbatim} -try: - cache -except NameError: - cache = {} -\end{verbatim} - - - It is legal though generally not very useful to reload built-in or - dynamically loaded modules, except for \refmodule{sys}, - \refmodule[main]{__main__} and \refmodule[builtin]{__builtin__}. In - many cases, however, extension modules are not designed to be - initialized more than once, and may fail in arbitrary ways when - reloaded. - - If a module imports objects from another module using \keyword{from} - \ldots{} \keyword{import} \ldots{}, calling \function{reload()} for - the other module does not redefine the objects imported from it --- - one way around this is to re-execute the \keyword{from} statement, - another is to use \keyword{import} and qualified names - (\var{module}.\var{name}) instead. - - If a module instantiates instances of a class, reloading the module - that defines the class does not affect the method definitions of the - instances --- they continue to use the old class definition. The - same is true for derived classes. -\end{funcdesc} - \begin{funcdesc}{repr}{object} Return a string containing a printable representation of an object. This is the same value yielded by conversions (reverse quotes). Modified: python/branches/p3yk/Doc/lib/libimp.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libimp.tex (original) +++ python/branches/p3yk/Doc/lib/libimp.tex Fri Jun 1 07:19:44 2007 @@ -69,8 +69,7 @@ Load a module that was previously found by \function{find_module()} (or by an otherwise conducted search yielding compatible results). This function does more than importing the module: if the module was -already imported, it is equivalent to a -\function{reload()}\bifuncindex{reload}! The \var{name} argument +already imported, it will reload the module! The \var{name} argument indicates the full module name (including the package name, if this is a submodule of a package). The \var{file} argument is an open file, and \var{filename} is the corresponding file name; these can be @@ -286,7 +285,7 @@ \end{verbatim} A more complete example that implements hierarchical module names and -includes a \function{reload()}\bifuncindex{reload} function can be +includes a \function{reload()} function can be found in the module \module{knee}\refmodindex{knee}. The \module{knee} module can be found in \file{Demo/imputil/} in the Python source distribution. Modified: python/branches/p3yk/Doc/lib/libsys.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libsys.tex (original) +++ python/branches/p3yk/Doc/lib/libsys.tex Fri Jun 1 07:19:44 2007 @@ -346,10 +346,7 @@ \begin{datadesc}{modules} This is a dictionary that maps module names to modules which have already been loaded. This can be manipulated to force reloading of - modules and other tricks. Note that removing a module from this - dictionary is \emph{not} the same as calling - \function{reload()}\bifuncindex{reload} on the corresponding module - object. + modules and other tricks. \end{datadesc} \begin{datadesc}{path} Modified: python/branches/p3yk/Doc/lib/libzipimport.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libzipimport.tex (original) +++ python/branches/p3yk/Doc/lib/libzipimport.tex Fri Jun 1 07:19:44 2007 @@ -29,11 +29,6 @@ if a ZIP archive doesn't contain \file{.pyc} files, importing may be rather slow. -Using the built-in \function{reload()} function will -fail if called on a module loaded from a ZIP archive; it is unlikely that -\function{reload()} would be needed, since this would imply that the ZIP -has been altered during runtime. - The available attributes of this module are: \begin{excdesc}{ZipImportError} Modified: python/branches/p3yk/Doc/tut/tut.tex ============================================================================== --- python/branches/p3yk/Doc/tut/tut.tex (original) +++ python/branches/p3yk/Doc/tut/tut.tex Fri Jun 1 07:19:44 2007 @@ -2703,7 +2703,7 @@ 'id', 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'min', 'object', 'oct', 'open', 'ord', 'pow', 'property', 'quit', 'range', - 'reload', 'repr', 'reversed', 'round', 'set', + 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'unichr', 'unicode', 'vars', 'zip'] \end{verbatim} Modified: python/branches/p3yk/Lib/idlelib/StackViewer.py ============================================================================== --- python/branches/p3yk/Lib/idlelib/StackViewer.py (original) +++ python/branches/p3yk/Lib/idlelib/StackViewer.py Fri Jun 1 07:19:44 2007 @@ -120,18 +120,3 @@ item = make_objecttreeitem(key + " =", value, setfunction) sublist.append(item) return sublist - - -def _test(): - try: - import testcode - reload(testcode) - except: - sys.last_type, sys.last_value, sys.last_traceback = sys.exc_info() - from Tkinter import Tk - root = Tk() - StackBrowser(None, top=root) - root.mainloop() - -if __name__ == "__main__": - _test() Modified: python/branches/p3yk/Lib/ihooks.py ============================================================================== --- python/branches/p3yk/Lib/ihooks.py (original) +++ python/branches/p3yk/Lib/ihooks.py Fri Jun 1 07:19:44 2007 @@ -45,9 +45,7 @@ If a module importer class supports dotted names, its import_module() must return a different value depending on whether it is called on behalf of a "from ... import ..." statement or not. (This is caused -by the way the __import__ hook is used by the Python interpreter.) It -would also do wise to install a different version of reload(). - +by the way the __import__ hook is used by the Python interpreter.) """ @@ -379,17 +377,14 @@ def install(self): self.save_import_module = __builtin__.__import__ - self.save_reload = __builtin__.reload if not hasattr(__builtin__, 'unload'): __builtin__.unload = None self.save_unload = __builtin__.unload __builtin__.__import__ = self.import_module - __builtin__.reload = self.reload __builtin__.unload = self.unload def uninstall(self): __builtin__.__import__ = self.save_import_module - __builtin__.reload = self.save_reload __builtin__.unload = self.save_unload if not __builtin__.unload: del __builtin__.unload Modified: python/branches/p3yk/Lib/imputil.py ============================================================================== --- python/branches/p3yk/Lib/imputil.py (original) +++ python/branches/p3yk/Lib/imputil.py Fri Jun 1 07:19:44 2007 @@ -40,9 +40,6 @@ self.namespace = namespace namespace['__import__'] = self._import_hook - ### fix this - #namespace['reload'] = self._reload_hook - def uninstall(self): "Restore the previous import mechanism." self.namespace['__import__'] = self.previous_importer @@ -194,22 +191,6 @@ return module return None - def _reload_hook(self, module): - "Python calls this hook to reload a module." - - # reloading of a module may or may not be possible (depending on the - # importer), but at least we can validate that it's ours to reload - importer = module.__dict__.get('__importer__') - if not importer: - ### oops. now what... - pass - - # okay. it is using the imputil system, and we must delegate it, but - # we don't know what to do (yet) - ### we should blast the module dict and do another get_code(). need to - ### flesh this out and add proper docco... - raise SystemError, "reload not yet implemented" - class Importer: "Base class for replacing standard import functions." @@ -682,7 +663,6 @@ # flag to force absolute imports? (speeds _determine_import_context and # checking for a relative module) # insert names of archives into sys.path (see quote below) -# note: reload does NOT blast module dict # shift import mechanisms and policies around; provide for hooks, overrides # (see quote below) # add get_source stuff Modified: python/branches/p3yk/Lib/pydoc.py ============================================================================== --- python/branches/p3yk/Lib/pydoc.py (original) +++ python/branches/p3yk/Lib/pydoc.py Fri Jun 1 07:19:44 2007 @@ -273,12 +273,11 @@ # that inherits from another module that has changed). if forceload and path in sys.modules: if path not in sys.builtin_module_names: - # Avoid simply calling reload() because it leaves names in - # the currently loaded module lying around if they're not - # defined in the new source file. Instead, remove the - # module from sys.modules and re-import. Also remove any - # submodules because they won't appear in the newly loaded - # module's namespace if they're already in sys.modules. + # Remove the module from sys.modules and re-import to try + # and avoid problems with partially loaded modules. + # Also remove any submodules because they won't appear + # in the newly loaded module's namespace if they're already + # in sys.modules. subs = [m for m in sys.modules if m.startswith(path + '.')] for key in [path] + subs: # Prevent garbage collection. Deleted: /python/branches/p3yk/Lib/test/infinite_reload.py ============================================================================== --- /python/branches/p3yk/Lib/test/infinite_reload.py Fri Jun 1 07:19:44 2007 +++ (empty file) @@ -1,7 +0,0 @@ -# For testing http://python.org/sf/742342, which reports that Python -# segfaults (infinite recursion in C) in the presence of infinite -# reload()ing. This module is imported by test_import.py:test_infinite_reload -# to make sure this doesn't happen any more. - -import infinite_reload -reload(infinite_reload) Modified: python/branches/p3yk/Lib/test/output/test_pkg ============================================================================== --- python/branches/p3yk/Lib/test/output/test_pkg (original) +++ python/branches/p3yk/Lib/test/output/test_pkg Fri Jun 1 07:19:44 2007 @@ -15,8 +15,6 @@ t3 loading t3.sub.subsub loading t3 t3.sub t3.sub.subsub -t3 loading -t3.sub.subsub loading running test t4 t4 loading t4.sub.subsub loading Modified: python/branches/p3yk/Lib/test/regrtest.py ============================================================================== --- python/branches/p3yk/Lib/test/regrtest.py (original) +++ python/branches/p3yk/Lib/test/regrtest.py Fri Jun 1 07:19:44 2007 @@ -669,7 +669,8 @@ indirect_test() else: def run_the_test(): - reload(the_module) + del sys.modules[the_module.__name__] + exec('import ' + the_module.__name__) deltas = [] nwarmup, ntracked, fname = huntrleaks Modified: python/branches/p3yk/Lib/test/test_builtin.py ============================================================================== --- python/branches/p3yk/Lib/test/test_builtin.py (original) +++ python/branches/p3yk/Lib/test/test_builtin.py Fri Jun 1 07:19:44 2007 @@ -1558,14 +1558,6 @@ fp.close() unlink(TESTFN) - def test_reload(self): - import marshal - reload(marshal) - import string - reload(string) - ## import sys - ## self.assertRaises(ImportError, reload, sys) - def test_repr(self): self.assertEqual(repr(''), '\'\'') self.assertEqual(repr(0), '0') Modified: python/branches/p3yk/Lib/test/test_doctest.py ============================================================================== --- python/branches/p3yk/Lib/test/test_doctest.py (original) +++ python/branches/p3yk/Lib/test/test_doctest.py Fri Jun 1 07:19:44 2007 @@ -2409,7 +2409,7 @@ def test_coverage(coverdir): tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,], trace=0, count=1) - tracer.run('reload(doctest); test_main()') + tracer.run('test_main()') r = tracer.results() print('Writing coverage results...') r.write_results(show_missing=True, summary=True, Modified: python/branches/p3yk/Lib/test/test_import.py ============================================================================== --- python/branches/p3yk/Lib/test/test_import.py (original) +++ python/branches/p3yk/Lib/test/test_import.py Fri Jun 1 07:19:44 2007 @@ -6,6 +6,7 @@ import sys import py_compile import warnings +from test.test_support import unlink def remove_files(name): @@ -63,22 +64,9 @@ self.assertEquals(mod.b, b, "module loaded (%s) but contents invalid" % mod) finally: - os.unlink(source) - - try: - try: - reload(mod) - except ImportError as err: - self.fail("import from .pyc/.pyo failed: %s" % err) - finally: - try: - os.unlink(pyc) - except OSError: - pass - try: - os.unlink(pyo) - except OSError: - pass + unlink(source) + unlink(pyc) + unlink(pyo) del sys.modules[TESTFN] sys.path.insert(0, os.curdir) @@ -136,6 +124,8 @@ # New in 2.4, we shouldn't be able to import that no matter how often # we try. sys.path.insert(0, os.curdir) + if TESTFN in sys.modules: + del sys.modules[TESTFN] try: for i in 1, 2, 3: try: @@ -149,60 +139,6 @@ sys.path.pop(0) remove_files(TESTFN) - def test_failing_reload(self): - # A failing reload should leave the module object in sys.modules. - source = TESTFN + os.extsep + "py" - f = open(source, "w") - print("a = 1", file=f) - print("b = 2", file=f) - f.close() - - sys.path.insert(0, os.curdir) - try: - mod = __import__(TESTFN) - self.assert_(TESTFN in sys.modules, "expected module in sys.modules") - self.assertEquals(mod.a, 1, "module has wrong attribute values") - self.assertEquals(mod.b, 2, "module has wrong attribute values") - - # On WinXP, just replacing the .py file wasn't enough to - # convince reload() to reparse it. Maybe the timestamp didn't - # move enough. We force it to get reparsed by removing the - # compiled file too. - remove_files(TESTFN) - - # Now damage the module. - f = open(source, "w") - print("a = 10", file=f) - print("b = 20//0", file=f) - f.close() - - self.assertRaises(ZeroDivisionError, reload, mod) - - # But we still expect the module to be in sys.modules. - mod = sys.modules.get(TESTFN) - self.failIf(mod is None, "expected module to still be in sys.modules") - - # We should have replaced a w/ 10, but the old b value should - # stick. - self.assertEquals(mod.a, 10, "module has wrong attribute values") - self.assertEquals(mod.b, 2, "module has wrong attribute values") - - finally: - sys.path.pop(0) - remove_files(TESTFN) - if TESTFN in sys.modules: - del sys.modules[TESTFN] - - def test_infinite_reload(self): - # Bug #742342 reports that Python segfaults (infinite recursion in C) - # when faced with self-recursive reload()ing. - - sys.path.insert(0, os.path.dirname(__file__)) - try: - import infinite_reload - finally: - sys.path.pop(0) - def test_import_name_binding(self): # import x.y.z binds x in the current namespace import test as x Modified: python/branches/p3yk/Lib/test/test_importhooks.py ============================================================================== --- python/branches/p3yk/Lib/test/test_importhooks.py (original) +++ python/branches/p3yk/Lib/test/test_importhooks.py Fri Jun 1 07:19:44 2007 @@ -190,10 +190,6 @@ import reloadmodule self.failIf(hasattr(reloadmodule,'reloaded')) - TestImporter.modules['reloadmodule'] = (False, reload_co) - reload(reloadmodule) - self.failUnless(hasattr(reloadmodule,'reloaded')) - import hooktestpackage.newrel self.assertEqual(hooktestpackage.newrel.get_name(), "hooktestpackage.newrel") Modified: python/branches/p3yk/Lib/test/test_pkg.py ============================================================================== --- python/branches/p3yk/Lib/test/test_pkg.py (original) +++ python/branches/p3yk/Lib/test/test_pkg.py Fri Jun 1 07:19:44 2007 @@ -120,9 +120,6 @@ """ import t3.sub.subsub print(t3.__name__, t3.sub.__name__, t3.sub.subsub.__name__) -reload(t3) -reload(t3.sub) -reload(t3.sub.subsub) """), ("t4", [ Modified: python/branches/p3yk/Lib/test/test_traceback.py ============================================================================== --- python/branches/p3yk/Lib/test/test_traceback.py (original) +++ python/branches/p3yk/Lib/test/test_traceback.py Fri Jun 1 07:19:44 2007 @@ -52,51 +52,6 @@ self.assert_("^" in err[2]) self.assert_(err[1].find(")") == err[2].find("^")) - def test_bug737473(self): - import sys, os, tempfile, time - - savedpath = sys.path[:] - testdir = tempfile.mkdtemp() - try: - sys.path.insert(0, testdir) - testfile = os.path.join(testdir, 'test_bug737473.py') - print(""" -def test(): - raise ValueError""", file=open(testfile, 'w')) - - if 'test_bug737473' in sys.modules: - del sys.modules['test_bug737473'] - import test_bug737473 - - try: - test_bug737473.test() - except ValueError: - # this loads source code to linecache - traceback.extract_tb(sys.exc_info()[2]) - - # If this test runs too quickly, test_bug737473.py's mtime - # attribute will remain unchanged even if the file is rewritten. - # Consequently, the file would not reload. So, added a sleep() - # delay to assure that a new, distinct timestamp is written. - # Since WinME with FAT32 has multisecond resolution, more than - # three seconds are needed for this test to pass reliably :-( - time.sleep(4) - - print(""" -def test(): - raise NotImplementedError""", file=open(testfile, 'w')) - reload(test_bug737473) - try: - test_bug737473.test() - except NotImplementedError: - src = traceback.extract_tb(sys.exc_info()[2])[-1][-1] - self.failUnlessEqual(src, 'raise NotImplementedError') - finally: - sys.path[:] = savedpath - for f in os.listdir(testdir): - os.unlink(os.path.join(testdir, f)) - os.rmdir(testdir) - def test_members(self): # Covers Python/structmember.c::listmembers() try: Modified: python/branches/p3yk/Lib/test/test_xmlrpc.py ============================================================================== --- python/branches/p3yk/Lib/test/test_xmlrpc.py (original) +++ python/branches/p3yk/Lib/test/test_xmlrpc.py Fri Jun 1 07:19:44 2007 @@ -17,7 +17,7 @@ 'ashortlong': 2, 'anotherlist': ['.zyx.41'], 'abase64': xmlrpclib.Binary("my dog has fleas"), - 'boolean': xmlrpclib.False, + 'boolean': False, 'unicode': u'\u4000\u6000\u8000', u'ukey\u4000': 'regular value', 'datetime1': xmlrpclib.DateTime('20050210T11:41:23'), @@ -133,10 +133,11 @@ """ # sys.setdefaultencoding() normally doesn't exist after site.py is - # loaded. reload(sys) is the way to get it back. + # loaded. Re-initializing sys again is the way to get it back. :-( old_encoding = sys.getdefaultencoding() setdefaultencoding_existed = hasattr(sys, "setdefaultencoding") - reload(sys) # ugh! + import imp + imp.init_builtin('sys') sys.setdefaultencoding("iso-8859-1") try: (s, d), m = xmlrpclib.loads(utf8) Modified: python/branches/p3yk/Misc/NEWS ============================================================================== --- python/branches/p3yk/Misc/NEWS (original) +++ python/branches/p3yk/Misc/NEWS Fri Jun 1 07:19:44 2007 @@ -139,7 +139,7 @@ backticks (ie, `x`), <> - Removed these Python builtins: - apply(), callable(), coerce(), file(), reduce() + apply(), callable(), coerce(), file(), reduce(), reload() - Removed these Python methods: {}.has_key Modified: python/branches/p3yk/Misc/cheatsheet ============================================================================== --- python/branches/p3yk/Misc/cheatsheet (original) +++ python/branches/p3yk/Misc/cheatsheet Fri Jun 1 07:19:44 2007 @@ -927,7 +927,6 @@ abs(x) Return the absolute value of number x. bool(x) Returns True when the argument x is true and False otherwise. buffer(obj) Creates a buffer reference to an object. -callable(x) Returns True if x callable, else False. chr(i) Returns one-character string whose ASCII code isinteger i classmethod(f) Converts a function f, into a method with the class as the first argument. Useful for creating alternative constructors. @@ -935,14 +934,14 @@ compile(string, from which the code was read, or eg. ''if not read filename, kind) from file.kind can be 'eval' if string is a single stmt, or 'single' which prints the output of expression statements - thatevaluate to something else than None, or be 'exec'. + that evaluate to something else than None, or be 'exec'. complex(real[, Builds a complex object (can also be done using J or j image]) suffix,e.g. 1+3J) delattr(obj, name) deletes attribute named name of object obj <=> del obj.name If no args, returns the list of names in current dict([items]) Create a new dictionary from the specified item list. -dir([object]) localsymbol table. With a module, class or class - instanceobject as arg, returns list of names in its attr. +dir([object]) local symbol table. With a module, class or class + instance object as arg, returns list of names in its attr. dict. divmod(a,b) Returns tuple of (a/b, a%b) enumerate(seq) Return a iterator giving: (0, seq[0]), (1, seq[1]), ... @@ -957,7 +956,7 @@ float(x) Converts a number or a string to floating point. getattr(object, [ arg added in 1.5.2]Gets attribute called name name[, default])) from object,e.g. getattr(x, 'f') <=> x.f). If not found, - raisesAttributeError or returns default if specified. + raises AttributeError or returns default if specified. globals() Returns a dictionary containing current global variables. hasattr(object, Returns true if object has attr called name. name) @@ -967,9 +966,7 @@ id(object) Returns a unique 'identity' integer for an object. int(x[, base]) base paramenter specifies base from which to convert string values. -intern(aString) Enters aString in the table of "interned strings" - andreturns the string. Interned strings are 'immortals'. -isinstance(obj, returns true if obj is an instance of class. Ifissubclass +isinstance(obj, Returns true if obj is an instance of class. Ifissubclass class) (A,B) then isinstance(x,A) => isinstance(x,B) issubclass(class1, returns true if class1 is derived from class2 class2) @@ -1002,26 +999,24 @@ [, buffering]]) pow(x, y [, z]) Returns x to power y [modulo z]. See also ** operator. property() Created a property with access controlled by functions. -range(start [,end Returns list of ints from >= start and < end.With 1 arg, -[, step]]) list from 0..arg-1With 2 args, list from start..end-1With 3 - args, list from start up to end by step -reload(module) after fixing it. If module was syntacticallycorrect but had - an error in initialization, mustimport it one more time - before calling reload(). - Returns a string containing a printable and if possible -repr(object) evaluable representation of an object. +range(start [,end Returns list of ints from >= start and < end. With 1 arg, +[, step]]) list from 0..arg-1. With 2 args, list from start..end-1. + With 3 args, list from start up to end by step + after fixing it. +repr(object) Returns a string containing a printable and if possible + evaluable representation of an object. Class redefinable (__repr__). See also str(). round(x, n=0) Returns the floating point value x rounded to n digitsafter the decimal point. -setattr(object, This is the counterpart of getattr().setattr(o, 'foobar', -name, value) 3) <=> o.foobar = 3Creates attribute if it doesn't exist! +setattr(object, This is the counterpart of getattr(). setattr(o, 'foobar', +name, value) 3) <=> o.foobar = 3. Creates attribute if it doesn't exist! slice([start,] stop Returns a slice object representing a range, with R/ -[, step]) Oattributes: start, stop, step. - Returns a string containing a nicely +[, step]) O attributes: start, stop, step. staticmethod() Convert a function to method with no self or class argument. Useful for methods associated with a class that do not need access to an object's internal state. -str(object) printablerepresentation of an object. Class overridable +str(object) Returns a string containing a nicely + printable representation of an object. Class overridable (__str__).See also repr(). super(type) Create an unbound super object. Used to call cooperative superclass methods. @@ -1043,12 +1038,8 @@ vars([object]) instance object as argumentreturns a dictionary corresponding to the object'ssymbol table. Useful with "%" formatting operator. -xrange(start [, end Like range(), but doesn't actually store entire listall at -[, step]]) once. Good to use in "for" loops when there is abig range - and little memory. -zip(seq1[, seq2, Returns a list of tuples where each tuple contains the nth -...]) element of each of the argument sequences. - +zip(seq1[, seq2, Returns an iterator of tuples where each tuple contains +...]) the nth element of each of the argument sequences. Modified: python/branches/p3yk/Python/bltinmodule.c ============================================================================== --- python/branches/p3yk/Python/bltinmodule.c (original) +++ python/branches/p3yk/Python/bltinmodule.c Fri Jun 1 07:19:44 2007 @@ -1683,17 +1683,6 @@ On Unix, GNU readline is used if enabled. The prompt string, if given,\n\ is printed without a trailing newline before reading."); -static PyObject * -builtin_reload(PyObject *self, PyObject *v) -{ - return PyImport_ReloadModule(v); -} - -PyDoc_STRVAR(reload_doc, -"reload(module) -> module\n\ -\n\ -Reload the module. The module must have been successfully imported before."); - static PyObject * builtin_repr(PyObject *self, PyObject *v) @@ -1991,7 +1980,6 @@ {"ord", builtin_ord, METH_O, ord_doc}, {"pow", builtin_pow, METH_VARARGS, pow_doc}, {"print", (PyCFunction)builtin_print, METH_VARARGS | METH_KEYWORDS, print_doc}, - {"reload", builtin_reload, METH_O, reload_doc}, {"repr", builtin_repr, METH_O, repr_doc}, {"round", (PyCFunction)builtin_round, METH_VARARGS | METH_KEYWORDS, round_doc}, {"setattr", builtin_setattr, METH_VARARGS, setattr_doc}, From python-3000-checkins at python.org Fri Jun 1 07:51:37 2007 From: python-3000-checkins at python.org (neal.norwitz) Date: Fri, 1 Jun 2007 07:51:37 +0200 (CEST) Subject: [Python-3000-checkins] r55729 - in python/branches/p3yk: Doc/howto/functional.rst Doc/lib/libpickle.tex Lib/ctypes/wintypes.py Lib/plat-mac/buildtools.py Lib/sha.py Lib/test/test_hmac.py Lib/uuid.py Misc/build.sh Modules/_ctypes/callbacks.c Python/import.c Message-ID: <20070601055137.C6A161E4004@bag.python.org> Author: neal.norwitz Date: Fri Jun 1 07:51:30 2007 New Revision: 55729 Modified: python/branches/p3yk/ (props changed) python/branches/p3yk/Doc/howto/functional.rst python/branches/p3yk/Doc/lib/libpickle.tex python/branches/p3yk/Lib/ctypes/wintypes.py python/branches/p3yk/Lib/plat-mac/buildtools.py python/branches/p3yk/Lib/sha.py python/branches/p3yk/Lib/test/test_hmac.py python/branches/p3yk/Lib/uuid.py python/branches/p3yk/Misc/build.sh python/branches/p3yk/Modules/_ctypes/callbacks.c python/branches/p3yk/Python/import.c Log: Merged revisions 55636-55728 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r55637 | georg.brandl | 2007-05-29 00:16:47 -0700 (Tue, 29 May 2007) | 2 lines Fix rst markup. ........ r55638 | neal.norwitz | 2007-05-29 00:51:39 -0700 (Tue, 29 May 2007) | 1 line Fix typo in doc ........ r55671 | neal.norwitz | 2007-05-29 21:53:41 -0700 (Tue, 29 May 2007) | 1 line Fix indentation (whitespace only). ........ r55676 | thomas.heller | 2007-05-29 23:58:30 -0700 (Tue, 29 May 2007) | 1 line Fix compiler warnings. ........ r55677 | thomas.heller | 2007-05-30 00:01:25 -0700 (Wed, 30 May 2007) | 2 lines Correct the name of a field in the WIN32_FIND_DATAA and WIN32_FIND_DATAW structures. Closes bug #1726026. ........ r55686 | brett.cannon | 2007-05-30 13:46:26 -0700 (Wed, 30 May 2007) | 2 lines Have MimeWriter raise a DeprecationWarning as per PEP 4 and its documentation. ........ r55690 | brett.cannon | 2007-05-30 14:48:58 -0700 (Wed, 30 May 2007) | 3 lines Have mimify raise a DeprecationWarning. The docs and PEP 4 have listed the module as deprecated for a while. ........ r55696 | brett.cannon | 2007-05-30 15:24:28 -0700 (Wed, 30 May 2007) | 2 lines Have md5 raise a DeprecationWarning as per PEP 4. ........ r55705 | neal.norwitz | 2007-05-30 21:14:22 -0700 (Wed, 30 May 2007) | 1 line Add some spaces in the example code. ........ r55716 | brett.cannon | 2007-05-31 12:20:00 -0700 (Thu, 31 May 2007) | 2 lines Have the sha module raise a DeprecationWarning as specified in PEP 4. ........ r55719 | brett.cannon | 2007-05-31 12:40:42 -0700 (Thu, 31 May 2007) | 2 lines Cause buildtools to raise a DeprecationWarning. ........ r55721 | brett.cannon | 2007-05-31 13:01:11 -0700 (Thu, 31 May 2007) | 2 lines Have cfmfile raise a DeprecationWarning as per PEP 4. ........ r55726 | neal.norwitz | 2007-05-31 21:56:47 -0700 (Thu, 31 May 2007) | 1 line Mail if there is an installation failure. ........ Modified: python/branches/p3yk/Doc/howto/functional.rst ============================================================================== --- python/branches/p3yk/Doc/howto/functional.rst (original) +++ python/branches/p3yk/Doc/howto/functional.rst Fri Jun 1 07:51:30 2007 @@ -980,7 +980,7 @@ that's a slice of the iterator. With a single ``stop`` argument, it will return the first ``stop`` elements. If you supply a starting index, you'll get ``stop-start`` -elements, and if you supply a value for ``step`, elements will be +elements, and if you supply a value for ``step``, elements will be skipped accordingly. Unlike Python's string and list slicing, you can't use negative values for ``start``, ``stop``, or ``step``. Modified: python/branches/p3yk/Doc/lib/libpickle.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libpickle.tex (original) +++ python/branches/p3yk/Doc/lib/libpickle.tex Fri Jun 1 07:51:30 2007 @@ -799,7 +799,7 @@ del odict['fh'] # remove filehandle entry return odict - def __setstate__(self,dict): + def __setstate__(self, dict): fh = open(dict['file']) # reopen file count = dict['lineno'] # read from file... while count: # until line count is restored @@ -820,7 +820,7 @@ ... obj.readline() '7: class TextReader:' >>> import pickle ->>> pickle.dump(obj,open('save.p','w')) +>>> pickle.dump(obj,open('save.p', 'wb')) \end{verbatim} If you want to see that \refmodule{pickle} works across Python @@ -829,7 +829,7 @@ \begin{verbatim} >>> import pickle ->>> reader = pickle.load(open('save.p')) +>>> reader = pickle.load(open('save.p', 'rb')) >>> reader.readline() '8: "Print and number lines in a text file."' \end{verbatim} Modified: python/branches/p3yk/Lib/ctypes/wintypes.py ============================================================================== --- python/branches/p3yk/Lib/ctypes/wintypes.py (original) +++ python/branches/p3yk/Lib/ctypes/wintypes.py Fri Jun 1 07:51:30 2007 @@ -147,7 +147,7 @@ ("dwReserved0", DWORD), ("dwReserved1", DWORD), ("cFileName", c_char * MAX_PATH), - ("cAlternameFileName", c_char * 14)] + ("cAlternateFileName", c_char * 14)] class WIN32_FIND_DATAW(Structure): _fields_ = [("dwFileAttributes", DWORD), @@ -159,7 +159,7 @@ ("dwReserved0", DWORD), ("dwReserved1", DWORD), ("cFileName", c_wchar * MAX_PATH), - ("cAlternameFileName", c_wchar * 14)] + ("cAlternateFileName", c_wchar * 14)] __all__ = ['ATOM', 'BOOL', 'BOOLEAN', 'BYTE', 'COLORREF', 'DOUBLE', 'DWORD', 'FILETIME', 'HACCEL', 'HANDLE', 'HBITMAP', 'HBRUSH', Modified: python/branches/p3yk/Lib/plat-mac/buildtools.py ============================================================================== --- python/branches/p3yk/Lib/plat-mac/buildtools.py (original) +++ python/branches/p3yk/Lib/plat-mac/buildtools.py Fri Jun 1 07:51:30 2007 @@ -13,6 +13,9 @@ import EasyDialogs import shutil +import warnings +warnings.warn("the buildtools module is deprecated", DeprecationWarning, 2) + BuildError = "BuildError" Modified: python/branches/p3yk/Lib/sha.py ============================================================================== --- python/branches/p3yk/Lib/sha.py (original) +++ python/branches/p3yk/Lib/sha.py Fri Jun 1 07:51:30 2007 @@ -3,6 +3,10 @@ # Copyright (C) 2005 Gregory P. Smith (greg at electricrain.com) # Licensed to PSF under a Contributor Agreement. +import warnings +warnings.warn("the sha module is deprecated; use the hashlib module instead", + DeprecationWarning, 2) + from hashlib import sha1 as sha new = sha Modified: python/branches/p3yk/Lib/test/test_hmac.py ============================================================================== --- python/branches/p3yk/Lib/test/test_hmac.py (original) +++ python/branches/p3yk/Lib/test/test_hmac.py Fri Jun 1 07:51:30 2007 @@ -1,5 +1,5 @@ import hmac -import sha +from hashlib import sha1 import unittest from test import test_support @@ -43,7 +43,7 @@ def test_sha_vectors(self): def shatest(key, data, digest): - h = hmac.HMAC(key, data, digestmod=sha) + h = hmac.HMAC(key, data, digestmod=sha1) self.assertEqual(h.hexdigest().upper(), digest.upper()) shatest(chr(0x0b) * 20, @@ -95,11 +95,11 @@ def test_withmodule(self): # Constructor call with text and digest module. - import sha + from hashlib import sha1 try: - h = hmac.HMAC("key", "", sha) + h = hmac.HMAC("key", "", sha1) except: - self.fail("Constructor call with sha module raised exception.") + self.fail("Constructor call with hashlib.sha1 raised exception.") class SanityTestCase(unittest.TestCase): Modified: python/branches/p3yk/Lib/uuid.py ============================================================================== --- python/branches/p3yk/Lib/uuid.py (original) +++ python/branches/p3yk/Lib/uuid.py Fri Jun 1 07:51:30 2007 @@ -535,8 +535,8 @@ def uuid3(namespace, name): """Generate a UUID from the MD5 hash of a namespace UUID and a name.""" - import hashlib - hash = hashlib.md5(namespace.bytes + name).digest() + from hashlib import md5 + hash = md5(namespace.bytes + name).digest() return UUID(bytes=hash[:16], version=3) def uuid4(): @@ -558,8 +558,8 @@ def uuid5(namespace, name): """Generate a UUID from the SHA-1 hash of a namespace UUID and a name.""" - import sha - hash = sha.sha(namespace.bytes + name).digest() + from hashlib import sha1 + hash = sha1(namespace.bytes + name).digest() return UUID(bytes=hash[:16], version=5) # The following standard UUIDs are for use with uuid3() or uuid5(). Modified: python/branches/p3yk/Misc/build.sh ============================================================================== --- python/branches/p3yk/Misc/build.sh (original) +++ python/branches/p3yk/Misc/build.sh Fri Jun 1 07:51:30 2007 @@ -170,6 +170,7 @@ start=`current_time` make install >& build/$F update_status "Installing" "$F" $start + mail_on_failure "install" build/$F if [ ! -x $PYTHON ]; then ln -s ${PYTHON}3.* $PYTHON Modified: python/branches/p3yk/Modules/_ctypes/callbacks.c ============================================================================== --- python/branches/p3yk/Modules/_ctypes/callbacks.c (original) +++ python/branches/p3yk/Modules/_ctypes/callbacks.c Fri Jun 1 07:51:30 2007 @@ -385,8 +385,8 @@ } { - PyObject *py_rclsid = PyLong_FromVoidPtr(rclsid); - PyObject *py_riid = PyLong_FromVoidPtr(riid); + PyObject *py_rclsid = PyLong_FromVoidPtr((void *)rclsid); + PyObject *py_riid = PyLong_FromVoidPtr((void *)riid); PyObject *py_ppv = PyLong_FromVoidPtr(ppv); if (!py_rclsid || !py_riid || !py_ppv) { Py_XDECREF(py_rclsid); Modified: python/branches/p3yk/Python/import.c ============================================================================== --- python/branches/p3yk/Python/import.c (original) +++ python/branches/p3yk/Python/import.c Fri Jun 1 07:51:30 2007 @@ -2429,7 +2429,7 @@ if (modules_reloading == NULL) { Py_FatalError("PyImport_ReloadModule: " - "no modules_reloading dictionary!"); + "no modules_reloading dictionary!"); return NULL; } @@ -2473,7 +2473,7 @@ "reload(): parent %.200s not in sys.modules", PyString_AS_STRING(parentname)); Py_DECREF(parentname); - imp_modules_reloading_clear(); + imp_modules_reloading_clear(); return NULL; } Py_DECREF(parentname); From python-3000-checkins at python.org Fri Jun 1 08:22:14 2007 From: python-3000-checkins at python.org (neal.norwitz) Date: Fri, 1 Jun 2007 08:22:14 +0200 (CEST) Subject: [Python-3000-checkins] r55730 - in python/branches/p3yk: Lib/sha.py Modules/md5.c Modules/md5.h Modules/md5module.c Modules/shamodule.c setup.py Message-ID: <20070601062214.C68401E4003@bag.python.org> Author: neal.norwitz Date: Fri Jun 1 08:22:07 2007 New Revision: 55730 Removed: python/branches/p3yk/Lib/sha.py python/branches/p3yk/Modules/md5.c python/branches/p3yk/Modules/md5.h python/branches/p3yk/Modules/md5module.c python/branches/p3yk/Modules/shamodule.c Modified: python/branches/p3yk/setup.py Log: Remove the code that was missed in rev 55303. Deleted: /python/branches/p3yk/Lib/sha.py ============================================================================== --- /python/branches/p3yk/Lib/sha.py Fri Jun 1 08:22:07 2007 +++ (empty file) @@ -1,15 +0,0 @@ -# $Id$ -# -# Copyright (C) 2005 Gregory P. Smith (greg at electricrain.com) -# Licensed to PSF under a Contributor Agreement. - -import warnings -warnings.warn("the sha module is deprecated; use the hashlib module instead", - DeprecationWarning, 2) - -from hashlib import sha1 as sha -new = sha - -blocksize = 1 # legacy value (wrong in any useful sense) -digest_size = 20 -digestsize = 20 Deleted: /python/branches/p3yk/Modules/md5.c ============================================================================== --- /python/branches/p3yk/Modules/md5.c Fri Jun 1 08:22:07 2007 +++ (empty file) @@ -1,381 +0,0 @@ -/* - Copyright (C) 1999, 2000, 2002 Aladdin Enterprises. All rights reserved. - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - L. Peter Deutsch - ghost at aladdin.com - - */ -/* $Id: md5.c,v 1.6 2002/04/13 19:20:28 lpd Exp $ */ -/* - Independent implementation of MD5 (RFC 1321). - - This code implements the MD5 Algorithm defined in RFC 1321, whose - text is available at - http://www.ietf.org/rfc/rfc1321.txt - The code is derived from the text of the RFC, including the test suite - (section A.5) but excluding the rest of Appendix A. It does not include - any code or documentation that is identified in the RFC as being - copyrighted. - - The original and principal author of md5.c is L. Peter Deutsch - . Other authors are noted in the change history - that follows (in reverse chronological order): - - 2002-04-13 lpd Clarified derivation from RFC 1321; now handles byte order - either statically or dynamically; added missing #include - in library. - 2002-03-11 lpd Corrected argument list for main(), and added int return - type, in test program and T value program. - 2002-02-21 lpd Added missing #include in test program. - 2000-07-03 lpd Patched to eliminate warnings about "constant is - unsigned in ANSI C, signed in traditional"; made test program - self-checking. - 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. - 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5). - 1999-05-03 lpd Original version. - */ - -#include "md5.h" -#include - -#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */ -#ifdef ARCH_IS_BIG_ENDIAN -# define BYTE_ORDER (ARCH_IS_BIG_ENDIAN ? 1 : -1) -#else -# define BYTE_ORDER 0 -#endif - -#define T_MASK ((md5_word_t)~0) -#define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87) -#define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9) -#define T3 0x242070db -#define T4 /* 0xc1bdceee */ (T_MASK ^ 0x3e423111) -#define T5 /* 0xf57c0faf */ (T_MASK ^ 0x0a83f050) -#define T6 0x4787c62a -#define T7 /* 0xa8304613 */ (T_MASK ^ 0x57cfb9ec) -#define T8 /* 0xfd469501 */ (T_MASK ^ 0x02b96afe) -#define T9 0x698098d8 -#define T10 /* 0x8b44f7af */ (T_MASK ^ 0x74bb0850) -#define T11 /* 0xffff5bb1 */ (T_MASK ^ 0x0000a44e) -#define T12 /* 0x895cd7be */ (T_MASK ^ 0x76a32841) -#define T13 0x6b901122 -#define T14 /* 0xfd987193 */ (T_MASK ^ 0x02678e6c) -#define T15 /* 0xa679438e */ (T_MASK ^ 0x5986bc71) -#define T16 0x49b40821 -#define T17 /* 0xf61e2562 */ (T_MASK ^ 0x09e1da9d) -#define T18 /* 0xc040b340 */ (T_MASK ^ 0x3fbf4cbf) -#define T19 0x265e5a51 -#define T20 /* 0xe9b6c7aa */ (T_MASK ^ 0x16493855) -#define T21 /* 0xd62f105d */ (T_MASK ^ 0x29d0efa2) -#define T22 0x02441453 -#define T23 /* 0xd8a1e681 */ (T_MASK ^ 0x275e197e) -#define T24 /* 0xe7d3fbc8 */ (T_MASK ^ 0x182c0437) -#define T25 0x21e1cde6 -#define T26 /* 0xc33707d6 */ (T_MASK ^ 0x3cc8f829) -#define T27 /* 0xf4d50d87 */ (T_MASK ^ 0x0b2af278) -#define T28 0x455a14ed -#define T29 /* 0xa9e3e905 */ (T_MASK ^ 0x561c16fa) -#define T30 /* 0xfcefa3f8 */ (T_MASK ^ 0x03105c07) -#define T31 0x676f02d9 -#define T32 /* 0x8d2a4c8a */ (T_MASK ^ 0x72d5b375) -#define T33 /* 0xfffa3942 */ (T_MASK ^ 0x0005c6bd) -#define T34 /* 0x8771f681 */ (T_MASK ^ 0x788e097e) -#define T35 0x6d9d6122 -#define T36 /* 0xfde5380c */ (T_MASK ^ 0x021ac7f3) -#define T37 /* 0xa4beea44 */ (T_MASK ^ 0x5b4115bb) -#define T38 0x4bdecfa9 -#define T39 /* 0xf6bb4b60 */ (T_MASK ^ 0x0944b49f) -#define T40 /* 0xbebfbc70 */ (T_MASK ^ 0x4140438f) -#define T41 0x289b7ec6 -#define T42 /* 0xeaa127fa */ (T_MASK ^ 0x155ed805) -#define T43 /* 0xd4ef3085 */ (T_MASK ^ 0x2b10cf7a) -#define T44 0x04881d05 -#define T45 /* 0xd9d4d039 */ (T_MASK ^ 0x262b2fc6) -#define T46 /* 0xe6db99e5 */ (T_MASK ^ 0x1924661a) -#define T47 0x1fa27cf8 -#define T48 /* 0xc4ac5665 */ (T_MASK ^ 0x3b53a99a) -#define T49 /* 0xf4292244 */ (T_MASK ^ 0x0bd6ddbb) -#define T50 0x432aff97 -#define T51 /* 0xab9423a7 */ (T_MASK ^ 0x546bdc58) -#define T52 /* 0xfc93a039 */ (T_MASK ^ 0x036c5fc6) -#define T53 0x655b59c3 -#define T54 /* 0x8f0ccc92 */ (T_MASK ^ 0x70f3336d) -#define T55 /* 0xffeff47d */ (T_MASK ^ 0x00100b82) -#define T56 /* 0x85845dd1 */ (T_MASK ^ 0x7a7ba22e) -#define T57 0x6fa87e4f -#define T58 /* 0xfe2ce6e0 */ (T_MASK ^ 0x01d3191f) -#define T59 /* 0xa3014314 */ (T_MASK ^ 0x5cfebceb) -#define T60 0x4e0811a1 -#define T61 /* 0xf7537e82 */ (T_MASK ^ 0x08ac817d) -#define T62 /* 0xbd3af235 */ (T_MASK ^ 0x42c50dca) -#define T63 0x2ad7d2bb -#define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e) - - -static void -md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) -{ - md5_word_t - a = pms->abcd[0], b = pms->abcd[1], - c = pms->abcd[2], d = pms->abcd[3]; - md5_word_t t; -#if BYTE_ORDER > 0 - /* Define storage only for big-endian CPUs. */ - md5_word_t X[16]; -#else - /* Define storage for little-endian or both types of CPUs. */ - md5_word_t xbuf[16]; - const md5_word_t *X; -#endif - - { -#if BYTE_ORDER == 0 - /* - * Determine dynamically whether this is a big-endian or - * little-endian machine, since we can use a more efficient - * algorithm on the latter. - */ - static const int w = 1; - - if (*((const md5_byte_t *)&w)) /* dynamic little-endian */ -#endif -#if BYTE_ORDER <= 0 /* little-endian */ - { - /* - * On little-endian machines, we can process properly aligned - * data without copying it. - */ - if (!((data - (const md5_byte_t *)0) & 3)) { - /* data are properly aligned */ - X = (const md5_word_t *)data; - } else { - /* not aligned */ - memcpy(xbuf, data, 64); - X = xbuf; - } - } -#endif -#if BYTE_ORDER == 0 - else /* dynamic big-endian */ -#endif -#if BYTE_ORDER >= 0 /* big-endian */ - { - /* - * On big-endian machines, we must arrange the bytes in the - * right order. - */ - const md5_byte_t *xp = data; - int i; - -# if BYTE_ORDER == 0 - X = xbuf; /* (dynamic only) */ -# else -# define xbuf X /* (static only) */ -# endif - for (i = 0; i < 16; ++i, xp += 4) - xbuf[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24); - } -#endif - } - -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) - - /* Round 1. */ - /* Let [abcd k s i] denote the operation - a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */ -#define F(x, y, z) (((x) & (y)) | (~(x) & (z))) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + F(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b - /* Do the following 16 operations. */ - SET(a, b, c, d, 0, 7, T1); - SET(d, a, b, c, 1, 12, T2); - SET(c, d, a, b, 2, 17, T3); - SET(b, c, d, a, 3, 22, T4); - SET(a, b, c, d, 4, 7, T5); - SET(d, a, b, c, 5, 12, T6); - SET(c, d, a, b, 6, 17, T7); - SET(b, c, d, a, 7, 22, T8); - SET(a, b, c, d, 8, 7, T9); - SET(d, a, b, c, 9, 12, T10); - SET(c, d, a, b, 10, 17, T11); - SET(b, c, d, a, 11, 22, T12); - SET(a, b, c, d, 12, 7, T13); - SET(d, a, b, c, 13, 12, T14); - SET(c, d, a, b, 14, 17, T15); - SET(b, c, d, a, 15, 22, T16); -#undef SET - - /* Round 2. */ - /* Let [abcd k s i] denote the operation - a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */ -#define G(x, y, z) (((x) & (z)) | ((y) & ~(z))) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + G(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b - /* Do the following 16 operations. */ - SET(a, b, c, d, 1, 5, T17); - SET(d, a, b, c, 6, 9, T18); - SET(c, d, a, b, 11, 14, T19); - SET(b, c, d, a, 0, 20, T20); - SET(a, b, c, d, 5, 5, T21); - SET(d, a, b, c, 10, 9, T22); - SET(c, d, a, b, 15, 14, T23); - SET(b, c, d, a, 4, 20, T24); - SET(a, b, c, d, 9, 5, T25); - SET(d, a, b, c, 14, 9, T26); - SET(c, d, a, b, 3, 14, T27); - SET(b, c, d, a, 8, 20, T28); - SET(a, b, c, d, 13, 5, T29); - SET(d, a, b, c, 2, 9, T30); - SET(c, d, a, b, 7, 14, T31); - SET(b, c, d, a, 12, 20, T32); -#undef SET - - /* Round 3. */ - /* Let [abcd k s t] denote the operation - a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */ -#define H(x, y, z) ((x) ^ (y) ^ (z)) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + H(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b - /* Do the following 16 operations. */ - SET(a, b, c, d, 5, 4, T33); - SET(d, a, b, c, 8, 11, T34); - SET(c, d, a, b, 11, 16, T35); - SET(b, c, d, a, 14, 23, T36); - SET(a, b, c, d, 1, 4, T37); - SET(d, a, b, c, 4, 11, T38); - SET(c, d, a, b, 7, 16, T39); - SET(b, c, d, a, 10, 23, T40); - SET(a, b, c, d, 13, 4, T41); - SET(d, a, b, c, 0, 11, T42); - SET(c, d, a, b, 3, 16, T43); - SET(b, c, d, a, 6, 23, T44); - SET(a, b, c, d, 9, 4, T45); - SET(d, a, b, c, 12, 11, T46); - SET(c, d, a, b, 15, 16, T47); - SET(b, c, d, a, 2, 23, T48); -#undef SET - - /* Round 4. */ - /* Let [abcd k s t] denote the operation - a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */ -#define I(x, y, z) ((y) ^ ((x) | ~(z))) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + I(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b - /* Do the following 16 operations. */ - SET(a, b, c, d, 0, 6, T49); - SET(d, a, b, c, 7, 10, T50); - SET(c, d, a, b, 14, 15, T51); - SET(b, c, d, a, 5, 21, T52); - SET(a, b, c, d, 12, 6, T53); - SET(d, a, b, c, 3, 10, T54); - SET(c, d, a, b, 10, 15, T55); - SET(b, c, d, a, 1, 21, T56); - SET(a, b, c, d, 8, 6, T57); - SET(d, a, b, c, 15, 10, T58); - SET(c, d, a, b, 6, 15, T59); - SET(b, c, d, a, 13, 21, T60); - SET(a, b, c, d, 4, 6, T61); - SET(d, a, b, c, 11, 10, T62); - SET(c, d, a, b, 2, 15, T63); - SET(b, c, d, a, 9, 21, T64); -#undef SET - - /* Then perform the following additions. (That is increment each - of the four registers by the value it had before this block - was started.) */ - pms->abcd[0] += a; - pms->abcd[1] += b; - pms->abcd[2] += c; - pms->abcd[3] += d; -} - -void -md5_init(md5_state_t *pms) -{ - pms->count[0] = pms->count[1] = 0; - pms->abcd[0] = 0x67452301; - pms->abcd[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476; - pms->abcd[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301; - pms->abcd[3] = 0x10325476; -} - -void -md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes) -{ - const md5_byte_t *p = data; - int left = nbytes; - int offset = (pms->count[0] >> 3) & 63; - md5_word_t nbits = (md5_word_t)(nbytes << 3); - - if (nbytes <= 0) - return; - - /* Update the message length. */ - pms->count[1] += nbytes >> 29; - pms->count[0] += nbits; - if (pms->count[0] < nbits) - pms->count[1]++; - - /* Process an initial partial block. */ - if (offset) { - int copy = (offset + nbytes > 64 ? 64 - offset : nbytes); - - memcpy(pms->buf + offset, p, copy); - if (offset + copy < 64) - return; - p += copy; - left -= copy; - md5_process(pms, pms->buf); - } - - /* Process full blocks. */ - for (; left >= 64; p += 64, left -= 64) - md5_process(pms, p); - - /* Process a final partial block. */ - if (left) - memcpy(pms->buf, p, left); -} - -void -md5_finish(md5_state_t *pms, md5_byte_t digest[16]) -{ - static const md5_byte_t pad[64] = { - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - md5_byte_t data[8]; - int i; - - /* Save the length before padding. */ - for (i = 0; i < 8; ++i) - data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3)); - /* Pad to 56 bytes mod 64. */ - md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1); - /* Append the length. */ - md5_append(pms, data, 8); - for (i = 0; i < 16; ++i) - digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3)); -} Deleted: /python/branches/p3yk/Modules/md5.h ============================================================================== --- /python/branches/p3yk/Modules/md5.h Fri Jun 1 08:22:07 2007 +++ (empty file) @@ -1,91 +0,0 @@ -/* - Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved. - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - L. Peter Deutsch - ghost at aladdin.com - - */ -/* $Id$ */ -/* - Independent implementation of MD5 (RFC 1321). - - This code implements the MD5 Algorithm defined in RFC 1321, whose - text is available at - http://www.ietf.org/rfc/rfc1321.txt - The code is derived from the text of the RFC, including the test suite - (section A.5) but excluding the rest of Appendix A. It does not include - any code or documentation that is identified in the RFC as being - copyrighted. - - The original and principal author of md5.h is L. Peter Deutsch - . Other authors are noted in the change history - that follows (in reverse chronological order): - - 2002-04-13 lpd Removed support for non-ANSI compilers; removed - references to Ghostscript; clarified derivation from RFC 1321; - now handles byte order either statically or dynamically. - 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. - 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5); - added conditionalization for C++ compilation from Martin - Purschke . - 1999-05-03 lpd Original version. - */ - -#ifndef md5_INCLUDED -# define md5_INCLUDED - -/* - * This package supports both compile-time and run-time determination of CPU - * byte order. If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be - * compiled to run only on little-endian CPUs; if ARCH_IS_BIG_ENDIAN is - * defined as non-zero, the code will be compiled to run only on big-endian - * CPUs; if ARCH_IS_BIG_ENDIAN is not defined, the code will be compiled to - * run on either big- or little-endian CPUs, but will run slightly less - * efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined. - */ - -typedef unsigned char md5_byte_t; /* 8-bit byte */ -typedef unsigned int md5_word_t; /* 32-bit word */ - -/* Define the state of the MD5 Algorithm. */ -typedef struct md5_state_s { - md5_word_t count[2]; /* message length in bits, lsw first */ - md5_word_t abcd[4]; /* digest buffer */ - md5_byte_t buf[64]; /* accumulate block */ -} md5_state_t; - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* Initialize the algorithm. */ -void md5_init(md5_state_t *pms); - -/* Append a string to the message. */ -void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes); - -/* Finish the message and return the digest. */ -void md5_finish(md5_state_t *pms, md5_byte_t digest[16]); - -#ifdef __cplusplus -} /* end extern "C" */ -#endif - -#endif /* md5_INCLUDED */ Deleted: /python/branches/p3yk/Modules/md5module.c ============================================================================== --- /python/branches/p3yk/Modules/md5module.c Fri Jun 1 08:22:07 2007 +++ (empty file) @@ -1,312 +0,0 @@ - -/* MD5 module */ - -/* This module provides an interface to the RSA Data Security, - Inc. MD5 Message-Digest Algorithm, described in RFC 1321. - It requires the files md5c.c and md5.h (which are slightly changed - from the versions in the RFC to avoid the "global.h" file.) */ - - -/* MD5 objects */ - -#include "Python.h" -#include "structmember.h" -#include "md5.h" - -typedef struct { - PyObject_HEAD - md5_state_t md5; /* the context holder */ -} md5object; - -static PyTypeObject MD5type; - -#define is_md5object(v) ((v)->ob_type == &MD5type) - -static md5object * -newmd5object(void) -{ - md5object *md5p; - - md5p = PyObject_New(md5object, &MD5type); - if (md5p == NULL) - return NULL; - - md5_init(&md5p->md5); /* actual initialisation */ - return md5p; -} - - -/* MD5 methods */ - -static void -md5_dealloc(md5object *md5p) -{ - PyObject_Del(md5p); -} - - -/* MD5 methods-as-attributes */ - -static PyObject * -md5_update(md5object *self, PyObject *args) -{ - unsigned char *cp; - int len; - - if (!PyArg_ParseTuple(args, "s#:update", &cp, &len)) - return NULL; - - md5_append(&self->md5, cp, len); - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(update_doc, -"update (arg)\n\ -\n\ -Update the md5 object with the string arg. Repeated calls are\n\ -equivalent to a single call with the concatenation of all the\n\ -arguments."); - - -static PyObject * -md5_digest(md5object *self) -{ - md5_state_t mdContext; - unsigned char aDigest[16]; - - /* make a temporary copy, and perform the final */ - mdContext = self->md5; - md5_finish(&mdContext, aDigest); - - return PyString_FromStringAndSize((char *)aDigest, 16); -} - -PyDoc_STRVAR(digest_doc, -"digest() -> string\n\ -\n\ -Return the digest of the strings passed to the update() method so\n\ -far. This is a 16-byte string which may contain non-ASCII characters,\n\ -including null bytes."); - - -static PyObject * -md5_hexdigest(md5object *self) -{ - md5_state_t mdContext; - unsigned char digest[16]; - unsigned char hexdigest[32]; - int i, j; - - /* make a temporary copy, and perform the final */ - mdContext = self->md5; - md5_finish(&mdContext, digest); - - /* Make hex version of the digest */ - for(i=j=0; i<16; i++) { - char c; - c = (digest[i] >> 4) & 0xf; - c = (c>9) ? c+'a'-10 : c + '0'; - hexdigest[j++] = c; - c = (digest[i] & 0xf); - c = (c>9) ? c+'a'-10 : c + '0'; - hexdigest[j++] = c; - } - return PyString_FromStringAndSize((char*)hexdigest, 32); -} - - -PyDoc_STRVAR(hexdigest_doc, -"hexdigest() -> string\n\ -\n\ -Like digest(), but returns the digest as a string of hexadecimal digits."); - - -static PyObject * -md5_copy(md5object *self) -{ - md5object *md5p; - - if ((md5p = newmd5object()) == NULL) - return NULL; - - md5p->md5 = self->md5; - - return (PyObject *)md5p; -} - -PyDoc_STRVAR(copy_doc, -"copy() -> md5 object\n\ -\n\ -Return a copy (``clone'') of the md5 object."); - - -static PyMethodDef md5_methods[] = { - {"update", (PyCFunction)md5_update, METH_VARARGS, update_doc}, - {"digest", (PyCFunction)md5_digest, METH_NOARGS, digest_doc}, - {"hexdigest", (PyCFunction)md5_hexdigest, METH_NOARGS, hexdigest_doc}, - {"copy", (PyCFunction)md5_copy, METH_NOARGS, copy_doc}, - {NULL, NULL} /* sentinel */ -}; - -static PyObject * -md5_get_block_size(PyObject *self, void *closure) -{ - return PyInt_FromLong(64); -} - -static PyObject * -md5_get_digest_size(PyObject *self, void *closure) -{ - return PyInt_FromLong(16); -} - -static PyObject * -md5_get_name(PyObject *self, void *closure) -{ - return PyString_FromStringAndSize("MD5", 3); -} - -static PyGetSetDef md5_getseters[] = { - {"digest_size", - (getter)md5_get_digest_size, NULL, - NULL, - NULL}, - {"block_size", - (getter)md5_get_block_size, NULL, - NULL, - NULL}, - {"name", - (getter)md5_get_name, NULL, - NULL, - NULL}, - /* the old md5 and sha modules support 'digest_size' as in PEP 247. - * the old sha module also supported 'digestsize'. ugh. */ - {"digestsize", - (getter)md5_get_digest_size, NULL, - NULL, - NULL}, - {NULL} /* Sentinel */ -}; - - -PyDoc_STRVAR(module_doc, -"This module implements the interface to RSA's MD5 message digest\n\ -algorithm (see also Internet RFC 1321). Its use is quite\n\ -straightforward: use the new() to create an md5 object. You can now\n\ -feed this object with arbitrary strings using the update() method, and\n\ -at any point you can ask it for the digest (a strong kind of 128-bit\n\ -checksum, a.k.a. ``fingerprint'') of the concatenation of the strings\n\ -fed to it so far using the digest() method.\n\ -\n\ -Functions:\n\ -\n\ -new([arg]) -- return a new md5 object, initialized with arg if provided\n\ -md5([arg]) -- DEPRECATED, same as new, but for compatibility\n\ -\n\ -Special Objects:\n\ -\n\ -MD5Type -- type object for md5 objects"); - -PyDoc_STRVAR(md5type_doc, -"An md5 represents the object used to calculate the MD5 checksum of a\n\ -string of information.\n\ -\n\ -Methods:\n\ -\n\ -update() -- updates the current digest with an additional string\n\ -digest() -- return the current digest value\n\ -hexdigest() -- return the current digest as a string of hexadecimal digits\n\ -copy() -- return a copy of the current md5 object"); - -static PyTypeObject MD5type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "_md5.md5", /*tp_name*/ - sizeof(md5object), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)md5_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - md5type_doc, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - md5_methods, /*tp_methods*/ - 0, /*tp_members*/ - md5_getseters, /*tp_getset*/ -}; - - -/* MD5 functions */ - -static PyObject * -MD5_new(PyObject *self, PyObject *args) -{ - md5object *md5p; - unsigned char *cp = NULL; - int len = 0; - - if (!PyArg_ParseTuple(args, "|s#:new", &cp, &len)) - return NULL; - - if ((md5p = newmd5object()) == NULL) - return NULL; - - if (cp) - md5_append(&md5p->md5, cp, len); - - return (PyObject *)md5p; -} - -PyDoc_STRVAR(new_doc, -"new([arg]) -> md5 object\n\ -\n\ -Return a new md5 object. If arg is present, the method call update(arg)\n\ -is made."); - - -/* List of functions exported by this module */ - -static PyMethodDef md5_functions[] = { - {"new", (PyCFunction)MD5_new, METH_VARARGS, new_doc}, - {NULL, NULL} /* Sentinel */ -}; - - -/* Initialize this module. */ - -PyMODINIT_FUNC -init_md5(void) -{ - PyObject *m, *d; - - MD5type.ob_type = &PyType_Type; - if (PyType_Ready(&MD5type) < 0) - return; - m = Py_InitModule3("_md5", md5_functions, module_doc); - if (m == NULL) - return; - d = PyModule_GetDict(m); - PyDict_SetItemString(d, "MD5Type", (PyObject *)&MD5type); - PyModule_AddIntConstant(m, "digest_size", 16); - /* No need to check the error here, the caller will do that */ -} Deleted: /python/branches/p3yk/Modules/shamodule.c ============================================================================== --- /python/branches/p3yk/Modules/shamodule.c Fri Jun 1 08:22:07 2007 +++ (empty file) @@ -1,593 +0,0 @@ -/* SHA module */ - -/* This module provides an interface to NIST's Secure Hash Algorithm */ - -/* See below for information about the original code this module was - based upon. Additional work performed by: - - Andrew Kuchling (amk at amk.ca) - Greg Stein (gstein at lyra.org) - - Copyright (C) 2005 Gregory P. Smith (greg at electricrain.com) - Licensed to PSF under a Contributor Agreement. - -*/ - -/* SHA objects */ - -#include "Python.h" -#include "structmember.h" - - -/* Endianness testing and definitions */ -#define TestEndianness(variable) {int i=1; variable=PCT_BIG_ENDIAN;\ - if (*((char*)&i)==1) variable=PCT_LITTLE_ENDIAN;} - -#define PCT_LITTLE_ENDIAN 1 -#define PCT_BIG_ENDIAN 0 - -/* Some useful types */ - -typedef unsigned char SHA_BYTE; - -#if SIZEOF_INT == 4 -typedef unsigned int SHA_INT32; /* 32-bit integer */ -#else -/* not defined. compilation will die. */ -#endif - -/* The SHA block size and message digest sizes, in bytes */ - -#define SHA_BLOCKSIZE 64 -#define SHA_DIGESTSIZE 20 - -/* The structure for storing SHS info */ - -typedef struct { - PyObject_HEAD - SHA_INT32 digest[5]; /* Message digest */ - SHA_INT32 count_lo, count_hi; /* 64-bit bit count */ - SHA_BYTE data[SHA_BLOCKSIZE]; /* SHA data buffer */ - int Endianness; - int local; /* unprocessed amount in data */ -} SHAobject; - -/* When run on a little-endian CPU we need to perform byte reversal on an - array of longwords. */ - -static void longReverse(SHA_INT32 *buffer, int byteCount, int Endianness) -{ - SHA_INT32 value; - - if ( Endianness == PCT_BIG_ENDIAN ) - return; - - byteCount /= sizeof(*buffer); - while (byteCount--) { - value = *buffer; - value = ( ( value & 0xFF00FF00L ) >> 8 ) | \ - ( ( value & 0x00FF00FFL ) << 8 ); - *buffer++ = ( value << 16 ) | ( value >> 16 ); - } -} - -static void SHAcopy(SHAobject *src, SHAobject *dest) -{ - dest->Endianness = src->Endianness; - dest->local = src->local; - dest->count_lo = src->count_lo; - dest->count_hi = src->count_hi; - memcpy(dest->digest, src->digest, sizeof(src->digest)); - memcpy(dest->data, src->data, sizeof(src->data)); -} - - -/* ------------------------------------------------------------------------ - * - * This code for the SHA algorithm was noted as public domain. The original - * headers are pasted below. - * - * Several changes have been made to make it more compatible with the - * Python environment and desired interface. - * - */ - -/* NIST Secure Hash Algorithm */ -/* heavily modified by Uwe Hollerbach */ -/* from Peter C. Gutmann's implementation as found in */ -/* Applied Cryptography by Bruce Schneier */ -/* Further modifications to include the "UNRAVEL" stuff, below */ - -/* This code is in the public domain */ - -/* UNRAVEL should be fastest & biggest */ -/* UNROLL_LOOPS should be just as big, but slightly slower */ -/* both undefined should be smallest and slowest */ - -#define UNRAVEL -/* #define UNROLL_LOOPS */ - -/* The SHA f()-functions. The f1 and f3 functions can be optimized to - save one boolean operation each - thanks to Rich Schroeppel, - rcs at cs.arizona.edu for discovering this */ - -/*#define f1(x,y,z) ((x & y) | (~x & z)) // Rounds 0-19 */ -#define f1(x,y,z) (z ^ (x & (y ^ z))) /* Rounds 0-19 */ -#define f2(x,y,z) (x ^ y ^ z) /* Rounds 20-39 */ -/*#define f3(x,y,z) ((x & y) | (x & z) | (y & z)) // Rounds 40-59 */ -#define f3(x,y,z) ((x & y) | (z & (x | y))) /* Rounds 40-59 */ -#define f4(x,y,z) (x ^ y ^ z) /* Rounds 60-79 */ - -/* SHA constants */ - -#define CONST1 0x5a827999L /* Rounds 0-19 */ -#define CONST2 0x6ed9eba1L /* Rounds 20-39 */ -#define CONST3 0x8f1bbcdcL /* Rounds 40-59 */ -#define CONST4 0xca62c1d6L /* Rounds 60-79 */ - -/* 32-bit rotate */ - -#define R32(x,n) ((x << n) | (x >> (32 - n))) - -/* the generic case, for when the overall rotation is not unraveled */ - -#define FG(n) \ - T = R32(A,5) + f##n(B,C,D) + E + *WP++ + CONST##n; \ - E = D; D = C; C = R32(B,30); B = A; A = T - -/* specific cases, for when the overall rotation is unraveled */ - -#define FA(n) \ - T = R32(A,5) + f##n(B,C,D) + E + *WP++ + CONST##n; B = R32(B,30) - -#define FB(n) \ - E = R32(T,5) + f##n(A,B,C) + D + *WP++ + CONST##n; A = R32(A,30) - -#define FC(n) \ - D = R32(E,5) + f##n(T,A,B) + C + *WP++ + CONST##n; T = R32(T,30) - -#define FD(n) \ - C = R32(D,5) + f##n(E,T,A) + B + *WP++ + CONST##n; E = R32(E,30) - -#define FE(n) \ - B = R32(C,5) + f##n(D,E,T) + A + *WP++ + CONST##n; D = R32(D,30) - -#define FT(n) \ - A = R32(B,5) + f##n(C,D,E) + T + *WP++ + CONST##n; C = R32(C,30) - -/* do SHA transformation */ - -static void -sha_transform(SHAobject *sha_info) -{ - int i; - SHA_INT32 T, A, B, C, D, E, W[80], *WP; - - memcpy(W, sha_info->data, sizeof(sha_info->data)); - longReverse(W, (int)sizeof(sha_info->data), sha_info->Endianness); - - for (i = 16; i < 80; ++i) { - W[i] = W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16]; - - /* extra rotation fix */ - W[i] = R32(W[i], 1); - } - A = sha_info->digest[0]; - B = sha_info->digest[1]; - C = sha_info->digest[2]; - D = sha_info->digest[3]; - E = sha_info->digest[4]; - WP = W; -#ifdef UNRAVEL - FA(1); FB(1); FC(1); FD(1); FE(1); FT(1); FA(1); FB(1); FC(1); FD(1); - FE(1); FT(1); FA(1); FB(1); FC(1); FD(1); FE(1); FT(1); FA(1); FB(1); - FC(2); FD(2); FE(2); FT(2); FA(2); FB(2); FC(2); FD(2); FE(2); FT(2); - FA(2); FB(2); FC(2); FD(2); FE(2); FT(2); FA(2); FB(2); FC(2); FD(2); - FE(3); FT(3); FA(3); FB(3); FC(3); FD(3); FE(3); FT(3); FA(3); FB(3); - FC(3); FD(3); FE(3); FT(3); FA(3); FB(3); FC(3); FD(3); FE(3); FT(3); - FA(4); FB(4); FC(4); FD(4); FE(4); FT(4); FA(4); FB(4); FC(4); FD(4); - FE(4); FT(4); FA(4); FB(4); FC(4); FD(4); FE(4); FT(4); FA(4); FB(4); - sha_info->digest[0] += E; - sha_info->digest[1] += T; - sha_info->digest[2] += A; - sha_info->digest[3] += B; - sha_info->digest[4] += C; -#else /* !UNRAVEL */ -#ifdef UNROLL_LOOPS - FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); - FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); - FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); - FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); - FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); - FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); - FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); - FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); -#else /* !UNROLL_LOOPS */ - for (i = 0; i < 20; ++i) { FG(1); } - for (i = 20; i < 40; ++i) { FG(2); } - for (i = 40; i < 60; ++i) { FG(3); } - for (i = 60; i < 80; ++i) { FG(4); } -#endif /* !UNROLL_LOOPS */ - sha_info->digest[0] += A; - sha_info->digest[1] += B; - sha_info->digest[2] += C; - sha_info->digest[3] += D; - sha_info->digest[4] += E; -#endif /* !UNRAVEL */ -} - -/* initialize the SHA digest */ - -static void -sha_init(SHAobject *sha_info) -{ - TestEndianness(sha_info->Endianness) - - sha_info->digest[0] = 0x67452301L; - sha_info->digest[1] = 0xefcdab89L; - sha_info->digest[2] = 0x98badcfeL; - sha_info->digest[3] = 0x10325476L; - sha_info->digest[4] = 0xc3d2e1f0L; - sha_info->count_lo = 0L; - sha_info->count_hi = 0L; - sha_info->local = 0; -} - -/* update the SHA digest */ - -static void -sha_update(SHAobject *sha_info, SHA_BYTE *buffer, int count) -{ - int i; - SHA_INT32 clo; - - clo = sha_info->count_lo + ((SHA_INT32) count << 3); - if (clo < sha_info->count_lo) { - ++sha_info->count_hi; - } - sha_info->count_lo = clo; - sha_info->count_hi += (SHA_INT32) count >> 29; - if (sha_info->local) { - i = SHA_BLOCKSIZE - sha_info->local; - if (i > count) { - i = count; - } - memcpy(((SHA_BYTE *) sha_info->data) + sha_info->local, buffer, i); - count -= i; - buffer += i; - sha_info->local += i; - if (sha_info->local == SHA_BLOCKSIZE) { - sha_transform(sha_info); - } - else { - return; - } - } - while (count >= SHA_BLOCKSIZE) { - memcpy(sha_info->data, buffer, SHA_BLOCKSIZE); - buffer += SHA_BLOCKSIZE; - count -= SHA_BLOCKSIZE; - sha_transform(sha_info); - } - memcpy(sha_info->data, buffer, count); - sha_info->local = count; -} - -/* finish computing the SHA digest */ - -static void -sha_final(unsigned char digest[20], SHAobject *sha_info) -{ - int count; - SHA_INT32 lo_bit_count, hi_bit_count; - - lo_bit_count = sha_info->count_lo; - hi_bit_count = sha_info->count_hi; - count = (int) ((lo_bit_count >> 3) & 0x3f); - ((SHA_BYTE *) sha_info->data)[count++] = 0x80; - if (count > SHA_BLOCKSIZE - 8) { - memset(((SHA_BYTE *) sha_info->data) + count, 0, - SHA_BLOCKSIZE - count); - sha_transform(sha_info); - memset((SHA_BYTE *) sha_info->data, 0, SHA_BLOCKSIZE - 8); - } - else { - memset(((SHA_BYTE *) sha_info->data) + count, 0, - SHA_BLOCKSIZE - 8 - count); - } - - /* GJS: note that we add the hi/lo in big-endian. sha_transform will - swap these values into host-order. */ - sha_info->data[56] = (hi_bit_count >> 24) & 0xff; - sha_info->data[57] = (hi_bit_count >> 16) & 0xff; - sha_info->data[58] = (hi_bit_count >> 8) & 0xff; - sha_info->data[59] = (hi_bit_count >> 0) & 0xff; - sha_info->data[60] = (lo_bit_count >> 24) & 0xff; - sha_info->data[61] = (lo_bit_count >> 16) & 0xff; - sha_info->data[62] = (lo_bit_count >> 8) & 0xff; - sha_info->data[63] = (lo_bit_count >> 0) & 0xff; - sha_transform(sha_info); - digest[ 0] = (unsigned char) ((sha_info->digest[0] >> 24) & 0xff); - digest[ 1] = (unsigned char) ((sha_info->digest[0] >> 16) & 0xff); - digest[ 2] = (unsigned char) ((sha_info->digest[0] >> 8) & 0xff); - digest[ 3] = (unsigned char) ((sha_info->digest[0] ) & 0xff); - digest[ 4] = (unsigned char) ((sha_info->digest[1] >> 24) & 0xff); - digest[ 5] = (unsigned char) ((sha_info->digest[1] >> 16) & 0xff); - digest[ 6] = (unsigned char) ((sha_info->digest[1] >> 8) & 0xff); - digest[ 7] = (unsigned char) ((sha_info->digest[1] ) & 0xff); - digest[ 8] = (unsigned char) ((sha_info->digest[2] >> 24) & 0xff); - digest[ 9] = (unsigned char) ((sha_info->digest[2] >> 16) & 0xff); - digest[10] = (unsigned char) ((sha_info->digest[2] >> 8) & 0xff); - digest[11] = (unsigned char) ((sha_info->digest[2] ) & 0xff); - digest[12] = (unsigned char) ((sha_info->digest[3] >> 24) & 0xff); - digest[13] = (unsigned char) ((sha_info->digest[3] >> 16) & 0xff); - digest[14] = (unsigned char) ((sha_info->digest[3] >> 8) & 0xff); - digest[15] = (unsigned char) ((sha_info->digest[3] ) & 0xff); - digest[16] = (unsigned char) ((sha_info->digest[4] >> 24) & 0xff); - digest[17] = (unsigned char) ((sha_info->digest[4] >> 16) & 0xff); - digest[18] = (unsigned char) ((sha_info->digest[4] >> 8) & 0xff); - digest[19] = (unsigned char) ((sha_info->digest[4] ) & 0xff); -} - -/* - * End of copied SHA code. - * - * ------------------------------------------------------------------------ - */ - -static PyTypeObject SHAtype; - - -static SHAobject * -newSHAobject(void) -{ - return (SHAobject *)PyObject_New(SHAobject, &SHAtype); -} - -/* Internal methods for a hashing object */ - -static void -SHA_dealloc(PyObject *ptr) -{ - PyObject_Del(ptr); -} - - -/* External methods for a hashing object */ - -PyDoc_STRVAR(SHA_copy__doc__, "Return a copy of the hashing object."); - -static PyObject * -SHA_copy(SHAobject *self, PyObject *unused) -{ - SHAobject *newobj; - - if ( (newobj = newSHAobject())==NULL) - return NULL; - - SHAcopy(self, newobj); - return (PyObject *)newobj; -} - -PyDoc_STRVAR(SHA_digest__doc__, -"Return the digest value as a string of binary data."); - -static PyObject * -SHA_digest(SHAobject *self, PyObject *unused) -{ - unsigned char digest[SHA_DIGESTSIZE]; - SHAobject temp; - - SHAcopy(self, &temp); - sha_final(digest, &temp); - return PyString_FromStringAndSize((const char *)digest, sizeof(digest)); -} - -PyDoc_STRVAR(SHA_hexdigest__doc__, -"Return the digest value as a string of hexadecimal digits."); - -static PyObject * -SHA_hexdigest(SHAobject *self, PyObject *unused) -{ - unsigned char digest[SHA_DIGESTSIZE]; - SHAobject temp; - PyObject *retval; - char *hex_digest; - int i, j; - - /* Get the raw (binary) digest value */ - SHAcopy(self, &temp); - sha_final(digest, &temp); - - /* Create a new string */ - retval = PyString_FromStringAndSize(NULL, sizeof(digest) * 2); - if (!retval) - return NULL; - hex_digest = PyString_AsString(retval); - if (!hex_digest) { - Py_DECREF(retval); - return NULL; - } - - /* Make hex version of the digest */ - for(i=j=0; i> 4) & 0xf; - c = (c>9) ? c+'a'-10 : c + '0'; - hex_digest[j++] = c; - c = (digest[i] & 0xf); - c = (c>9) ? c+'a'-10 : c + '0'; - hex_digest[j++] = c; - } - return retval; -} - -PyDoc_STRVAR(SHA_update__doc__, -"Update this hashing object's state with the provided string."); - -static PyObject * -SHA_update(SHAobject *self, PyObject *args) -{ - unsigned char *cp; - int len; - - if (!PyArg_ParseTuple(args, "s#:update", &cp, &len)) - return NULL; - - sha_update(self, cp, len); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyMethodDef SHA_methods[] = { - {"copy", (PyCFunction)SHA_copy, METH_NOARGS, SHA_copy__doc__}, - {"digest", (PyCFunction)SHA_digest, METH_NOARGS, SHA_digest__doc__}, - {"hexdigest", (PyCFunction)SHA_hexdigest, METH_NOARGS, SHA_hexdigest__doc__}, - {"update", (PyCFunction)SHA_update, METH_VARARGS, SHA_update__doc__}, - {NULL, NULL} /* sentinel */ -}; - -static PyObject * -SHA_get_block_size(PyObject *self, void *closure) -{ - return PyInt_FromLong(SHA_BLOCKSIZE); -} - -static PyObject * -SHA_get_digest_size(PyObject *self, void *closure) -{ - return PyInt_FromLong(SHA_DIGESTSIZE); -} - -static PyObject * -SHA_get_name(PyObject *self, void *closure) -{ - return PyString_FromStringAndSize("SHA1", 4); -} - -static PyGetSetDef SHA_getseters[] = { - {"digest_size", - (getter)SHA_get_digest_size, NULL, - NULL, - NULL}, - {"block_size", - (getter)SHA_get_block_size, NULL, - NULL, - NULL}, - {"name", - (getter)SHA_get_name, NULL, - NULL, - NULL}, - /* the old md5 and sha modules support 'digest_size' as in PEP 247. - * the old sha module also supported 'digestsize'. ugh. */ - {"digestsize", - (getter)SHA_get_digest_size, NULL, - NULL, - NULL}, - {NULL} /* Sentinel */ -}; - -static PyTypeObject SHAtype = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "_sha.sha", /*tp_name*/ - sizeof(SHAobject), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods */ - SHA_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - SHA_methods, /* tp_methods */ - 0, /* tp_members */ - SHA_getseters, /* tp_getset */ -}; - - -/* The single module-level function: new() */ - -PyDoc_STRVAR(SHA_new__doc__, -"Return a new SHA hashing object. An optional string argument\n\ -may be provided; if present, this string will be automatically\n\ -hashed."); - -static PyObject * -SHA_new(PyObject *self, PyObject *args, PyObject *kwdict) -{ - static char *kwlist[] = {"string", NULL}; - SHAobject *new; - unsigned char *cp = NULL; - int len; - - if (!PyArg_ParseTupleAndKeywords(args, kwdict, "|s#:new", kwlist, - &cp, &len)) { - return NULL; - } - - if ((new = newSHAobject()) == NULL) - return NULL; - - sha_init(new); - - if (PyErr_Occurred()) { - Py_DECREF(new); - return NULL; - } - if (cp) - sha_update(new, cp, len); - - return (PyObject *)new; -} - - -/* List of functions exported by this module */ - -static struct PyMethodDef SHA_functions[] = { - {"new", (PyCFunction)SHA_new, METH_VARARGS|METH_KEYWORDS, SHA_new__doc__}, - {NULL, NULL} /* Sentinel */ -}; - - -/* Initialize this module. */ - -#define insint(n,v) { PyModule_AddIntConstant(m,n,v); } - -PyMODINIT_FUNC -init_sha(void) -{ - PyObject *m; - - SHAtype.ob_type = &PyType_Type; - if (PyType_Ready(&SHAtype) < 0) - return; - m = Py_InitModule("_sha", SHA_functions); - if (m == NULL) - return; - - /* Add some symbolic constants to the module */ - insint("blocksize", 1); /* For future use, in case some hash - functions require an integral number of - blocks */ - insint("digestsize", 20); - insint("digest_size", 20); -} Modified: python/branches/p3yk/setup.py ============================================================================== --- python/branches/p3yk/setup.py (original) +++ python/branches/p3yk/setup.py Fri Jun 1 08:22:07 2007 @@ -620,16 +620,7 @@ include_dirs = ssl_incs, library_dirs = ssl_libs, libraries = ['ssl', 'crypto']) ) - missing.extend(['_sha', '_md5']) else: - # The _sha module implements the SHA1 hash algorithm. - exts.append( Extension('_sha', ['shamodule.c']) ) - # The _md5 module implements the RSA Data Security, Inc. MD5 - # Message-Digest Algorithm, described in RFC 1321. The - # necessary files md5.c and md5.h are included here. - exts.append( Extension('_md5', - sources = ['md5module.c', 'md5.c'], - depends = ['md5.h']) ) missing.append('_hashlib') if (openssl_ver < 0x00908000): From python-3000-checkins at python.org Sat Jun 2 04:10:45 2007 From: python-3000-checkins at python.org (neal.norwitz) Date: Sat, 2 Jun 2007 04:10:45 +0200 (CEST) Subject: [Python-3000-checkins] r55738 - python/branches/p3yk/Doc/ext/extending.tex Message-ID: <20070602021045.74D151E4003@bag.python.org> Author: neal.norwitz Date: Sat Jun 2 04:10:43 2007 New Revision: 55738 Modified: python/branches/p3yk/Doc/ext/extending.tex Log: Fix doc breakage Modified: python/branches/p3yk/Doc/ext/extending.tex ============================================================================== --- python/branches/p3yk/Doc/ext/extending.tex (original) +++ python/branches/p3yk/Doc/ext/extending.tex Sat Jun 2 04:10:43 2007 @@ -399,7 +399,7 @@ following a \cfunction{fork()} without an intervening \cfunction{exec()}) can create problems for some extension modules. Extension module authors should exercise caution when initializing -internal data structures. +internal data structures.} A more substantial example module is included in the Python source distribution as \file{Modules/xxmodule.c}. This file may be used as a From python-3000-checkins at python.org Sat Jun 2 09:42:02 2007 From: python-3000-checkins at python.org (neal.norwitz) Date: Sat, 2 Jun 2007 09:42:02 +0200 (CEST) Subject: [Python-3000-checkins] r55741 - in python/branches/p3yk: Doc/lib/libundoc.tex Lib/test/regrtest.py Misc/BeOS-setup.py Misc/NEWS Modules/Setup.dist Modules/timing.h Modules/timingmodule.c PC/os2emx/Makefile PC/os2emx/config.c PC/os2emx/python25.def PC/os2vacpp/makefile PC/os2vacpp/makefile.omk PCbuild/pythoncore.vcproj README setup.py Message-ID: <20070602074202.DB0B41E4003@bag.python.org> Author: neal.norwitz Date: Sat Jun 2 09:41:58 2007 New Revision: 55741 Removed: python/branches/p3yk/Modules/timing.h python/branches/p3yk/Modules/timingmodule.c Modified: python/branches/p3yk/Doc/lib/libundoc.tex python/branches/p3yk/Lib/test/regrtest.py python/branches/p3yk/Misc/BeOS-setup.py python/branches/p3yk/Misc/NEWS python/branches/p3yk/Modules/Setup.dist python/branches/p3yk/PC/os2emx/Makefile python/branches/p3yk/PC/os2emx/config.c python/branches/p3yk/PC/os2emx/python25.def python/branches/p3yk/PC/os2vacpp/makefile python/branches/p3yk/PC/os2vacpp/makefile.omk python/branches/p3yk/PCbuild/pythoncore.vcproj python/branches/p3yk/README python/branches/p3yk/setup.py Log: Remove timing module (plus some remnants of other modules). Modified: python/branches/p3yk/Doc/lib/libundoc.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libundoc.tex (original) +++ python/branches/p3yk/Doc/lib/libundoc.tex Sat Jun 2 09:41:58 2007 @@ -88,7 +88,4 @@ % XXX need Windows instructions! \begin{description} -\item[\module{timing}] ---- Measure time intervals to high resolution (use \function{time.clock()} - instead). \end{description} Modified: python/branches/p3yk/Lib/test/regrtest.py ============================================================================== --- python/branches/p3yk/Lib/test/regrtest.py (original) +++ python/branches/p3yk/Lib/test/regrtest.py Sat Jun 2 09:41:58 2007 @@ -842,7 +842,6 @@ test_signal test_sunaudiodev test_threadsignals - test_timing test_wait3 test_wait4 """, @@ -895,7 +894,6 @@ test_sunaudiodev test_sundry test_tarfile - test_timing """, 'unixware7': """ @@ -993,7 +991,6 @@ test_threaded_import test_threadedtempfile test_threading - test_timing """, 'darwin': """ Modified: python/branches/p3yk/Misc/BeOS-setup.py ============================================================================== --- python/branches/p3yk/Misc/BeOS-setup.py (original) +++ python/branches/p3yk/Misc/BeOS-setup.py Sat Jun 2 09:41:58 2007 @@ -168,8 +168,6 @@ if platform in ['Darwin1.2', 'beos']: math_libs = [] - # XXX Omitted modules: gl, pure, dl, SGI-specific modules - # # The following modules are all pretty straightforward, and compile # on pretty much any POSIXish platform. @@ -242,9 +240,6 @@ # Lance Ellinghaus's syslog daemon interface exts.append( Extension('syslog', ['syslogmodule.c']) ) - # George Neville-Neil's timing module: - exts.append( Extension('timing', ['timingmodule.c']) ) - # # Here ends the simple stuff. From here on, modules need certain # libraries, are platform-specific, or present other surprises. @@ -340,15 +335,8 @@ if self.compiler.find_library_file(lib_dirs, 'db'): dblib = ['db'] - db185_incs = find_file('db_185.h', inc_dirs, - ['/usr/include/db3', '/usr/include/db2']) db_inc = find_file('db.h', inc_dirs, ['/usr/include/db1']) - if db185_incs is not None: - exts.append( Extension('bsddb', ['bsddbmodule.c'], - include_dirs = db185_incs, - define_macros=[('HAVE_DB_185_H',1)], - libraries = dblib ) ) - elif db_inc is not None: + db_inc is not None: exts.append( Extension('bsddb', ['bsddbmodule.c'], include_dirs = db_inc, libraries = dblib) ) Modified: python/branches/p3yk/Misc/NEWS ============================================================================== --- python/branches/p3yk/Misc/NEWS (original) +++ python/branches/p3yk/Misc/NEWS Sat Jun 2 09:41:58 2007 @@ -176,7 +176,7 @@ - Removed these modules: * Bastion, bsddb185, exceptions, md5, MimeWriter, mimify, popen2, rexec, - sets, sha, stringold, strop, xmllib. + sets, sha, stringold, strop, timing, xmllib. - Remove obsolete IRIX modules: al/AL, cd/CD, cddb, cdplayer, cl/CL, DEVICE, ERRNO, FILE, fl/FL, flp, fm, GET, gl/GL, GLWS, IN, imgfile, IOCTL, jpeg, Modified: python/branches/p3yk/Modules/Setup.dist ============================================================================== --- python/branches/p3yk/Modules/Setup.dist (original) +++ python/branches/p3yk/Modules/Setup.dist Sat Jun 2 09:41:58 2007 @@ -246,11 +246,6 @@ #linuxaudiodev linuxaudiodev.c -# George Neville-Neil's timing module: - -#timing timingmodule.c - - # The _tkinter module. # # The command for _tkinter is long and site specific. Please Deleted: /python/branches/p3yk/Modules/timing.h ============================================================================== --- /python/branches/p3yk/Modules/timing.h Sat Jun 2 09:41:58 2007 +++ (empty file) @@ -1,67 +0,0 @@ -/* - * Copyright (c) 1993 George V. Neville-Neil - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by George V. Neville-Neil - * 4. The name, George Neville-Neil may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _TIMING_H_ -#define _TIMING_H_ - -#ifdef TIME_WITH_SYS_TIME -#include -#include -#else /* !TIME_WITH_SYS_TIME */ -#ifdef HAVE_SYS_TIME_H -#include -#else /* !HAVE_SYS_TIME_H */ -#include -#endif /* !HAVE_SYS_TIME_H */ -#endif /* !TIME_WITH_SYS_TIME */ - -static struct timeval aftertp, beforetp; - -#define BEGINTIMING gettimeofday(&beforetp, NULL) - -#define ENDTIMING gettimeofday(&aftertp, NULL); \ - if(beforetp.tv_usec > aftertp.tv_usec) \ - { \ - aftertp.tv_usec += 1000000; \ - aftertp.tv_sec--; \ - } - -#define TIMINGUS (((aftertp.tv_sec - beforetp.tv_sec) * 1000000) + \ - (aftertp.tv_usec - beforetp.tv_usec)) - -#define TIMINGMS (((aftertp.tv_sec - beforetp.tv_sec) * 1000) + \ - ((aftertp.tv_usec - beforetp.tv_usec) / 1000)) - -#define TIMINGS ((aftertp.tv_sec - beforetp.tv_sec) + \ - (aftertp.tv_usec - beforetp.tv_usec) / 1000000) - -#endif /* _TIMING_H_ */ Deleted: /python/branches/p3yk/Modules/timingmodule.c ============================================================================== --- /python/branches/p3yk/Modules/timingmodule.c Sat Jun 2 09:41:58 2007 +++ (empty file) @@ -1,58 +0,0 @@ -/* - * Author: George V. Neville-Neil - */ - -#include "Python.h" - -/* Our stuff... */ -#include "timing.h" - -static PyObject * -start_timing(PyObject *self) -{ - Py_INCREF(Py_None); - BEGINTIMING; - return Py_None; -} - -static PyObject * -finish_timing(PyObject *self) -{ - ENDTIMING - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -seconds(PyObject *self) -{ - return PyInt_FromLong(TIMINGS); -} - -static PyObject * -milli(PyObject *self) -{ - return PyInt_FromLong(TIMINGMS); -} - -static PyObject * -micro(PyObject *self) -{ - return PyInt_FromLong(TIMINGUS); -} - - -static PyMethodDef timing_methods[] = { - {"start", (PyCFunction)start_timing, METH_NOARGS}, - {"finish", (PyCFunction)finish_timing, METH_NOARGS}, - {"seconds", (PyCFunction)seconds, METH_NOARGS}, - {"milli", (PyCFunction)milli, METH_NOARGS}, - {"micro", (PyCFunction)micro, METH_NOARGS}, - {NULL, NULL} -}; - - -PyMODINIT_FUNC inittiming(void) -{ - (void)Py_InitModule("timing", timing_methods); -} Modified: python/branches/p3yk/PC/os2emx/Makefile ============================================================================== --- python/branches/p3yk/PC/os2emx/Makefile (original) +++ python/branches/p3yk/PC/os2emx/Makefile Sat Jun 2 09:41:58 2007 @@ -300,12 +300,8 @@ Modules/itertoolsmodule.c \ Modules/_localemodule.c \ Modules/mathmodule.c \ - Modules/md5.c \ - Modules/md5module.c \ Modules/operator.c \ Modules/_randommodule.c \ - Modules/rgbimgmodule.c \ - Modules/shamodule.c \ Modules/sha256module.c \ Modules/sha512module.c \ Modules/_sre.c \ @@ -313,7 +309,6 @@ Modules/symtablemodule.c \ Modules/termios.c \ Modules/timemodule.c \ - Modules/timingmodule.c \ Modules/_weakref.c \ Modules/xxsubtype.c \ Modules/zipimport.c) Modified: python/branches/p3yk/PC/os2emx/config.c ============================================================================== --- python/branches/p3yk/PC/os2emx/config.c (original) +++ python/branches/p3yk/PC/os2emx/config.c Sat Jun 2 09:41:58 2007 @@ -65,14 +65,12 @@ extern void initmath(); extern void init_md5(); extern void initoperator(); -extern void initrgbimg(); extern void init_sha(); extern void init_sha256(); extern void init_sha512(); extern void init_struct(); extern void inittermios(); extern void inittime(); -extern void inittiming(); extern void initxxsubtype(); extern void initzipimport(); #if !HAVE_DYNAMIC_LOADING @@ -127,16 +125,12 @@ {"imageop", initimageop}, {"itertools", inititertools}, {"math", initmath}, - {"_md5", init_md5}, {"operator", initoperator}, - {"rgbimg", initrgbimg}, - {"_sha", init_sha}, {"_sha256", init_sha256}, {"_sha512", init_sha512}, {"_struct", init_struct}, {"termios", inittermios}, {"time", inittime}, - {"timing", inittiming}, {"xxsubtype", initxxsubtype}, {"zipimport", initzipimport}, #if !HAVE_DYNAMIC_LOADING Modified: python/branches/p3yk/PC/os2emx/python25.def ============================================================================== --- python/branches/p3yk/PC/os2emx/python25.def (original) +++ python/branches/p3yk/PC/os2emx/python25.def Sat Jun 2 09:41:58 2007 @@ -1255,26 +1255,12 @@ ; From python25_s.lib(mathmodule) ; "initmath" -; From python25_s.lib(md5) - "md5_finish" - "md5_init" - "md5_append" - -; From python25_s.lib(md5module) -; "init_md5" - ; From python25_s.lib(operator) ; "initoperator" ; From python25_s.lib(_randommodule) ; "init_random" -; From python25_s.lib(rgbimgmodule) -; "initrgbimg" - -; From python25_s.lib(shamodule) -; "init_sha" - ; From python25_s.lib(sha256module) ; "init_sha256" @@ -1298,9 +1284,6 @@ "_PyTime_DoubleToTimet" ; "inittimezone" -; From python25_s.lib(timingmodule) -; "inittiming" - ; From python25_s.lib(_weakref) ; "init_weakref" Modified: python/branches/p3yk/PC/os2vacpp/makefile ============================================================================== --- python/branches/p3yk/PC/os2vacpp/makefile (original) +++ python/branches/p3yk/PC/os2vacpp/makefile Sat Jun 2 09:41:58 2007 @@ -371,19 +371,6 @@ $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h -almodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - arraymodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ @@ -439,46 +426,6 @@ $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ $(PY_INCLUDE)\tupleobject.h -cdmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -cgensupport.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_MODULES)\cgensupport.h $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h \ - $(PY_INCLUDE)\complexobject.h pyconfig.h $(PY_INCLUDE)\dictobject.h \ - $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h \ - $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h \ - $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -clmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - cmathmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ @@ -616,33 +563,6 @@ $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ $(PY_INCLUDE)\tupleobject.h -flmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\structmember.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -fmmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - fpectlmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ @@ -700,20 +620,6 @@ $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ $(PY_INCLUDE)\tupleobject.h -glmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_MODULES)\cgensupport.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - grpmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ @@ -741,19 +647,6 @@ $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h -imgfile.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - main.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ @@ -781,21 +674,6 @@ $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ $(PY_INCLUDE)\tupleobject.h -md5c.obj: pyconfig.h $(PY_MODULES)\md5.h - -md5module.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_MODULES)\md5.h $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - mpzmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ @@ -852,20 +730,6 @@ $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\token.h \ $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h -pcremodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_MODULES)\pcre-internal.h \ - $(PY_MODULES)\pcre.h $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h \ - $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h \ - $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - posix.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ @@ -894,19 +758,6 @@ $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ $(PY_INCLUDE)\tupleobject.h -puremodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - pwdmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ @@ -921,20 +772,6 @@ $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ $(PY_INCLUDE)\tupleobject.h -pypcre.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\graminit.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_MODULES)\pcre-internal.h $(PY_MODULES)\pcre.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - readline.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ @@ -962,20 +799,6 @@ $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ $(PY_INCLUDE)\tupleobject.h -rgbimgmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - selectmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ @@ -990,19 +813,6 @@ $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h -sgimodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - signalmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ @@ -1032,33 +842,6 @@ $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ $(PY_INCLUDE)\tupleobject.h -soundex.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -stdwinmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - structmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ @@ -1087,21 +870,6 @@ $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\structmember.h \ $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h -svmodule.obj: $(PY_INCLUDE)\abstract.h $(OS2TCPIP)\Include\sys\time.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\compile.h \ - $(PY_INCLUDE)\complexobject.h pyconfig.h $(PY_INCLUDE)\dictobject.h \ - $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h \ - $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h \ - $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h \ - $(PY_MODULES)\yuv.h - syslogmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ @@ -1157,20 +925,6 @@ $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ $(PY_INCLUDE)\tupleobject.h -timingmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_MODULES)\timing.h \ - $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - xxmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ Modified: python/branches/p3yk/PC/os2vacpp/makefile.omk ============================================================================== --- python/branches/p3yk/PC/os2vacpp/makefile.omk (original) +++ python/branches/p3yk/PC/os2vacpp/makefile.omk Sat Jun 2 09:41:58 2007 @@ -170,45 +170,30 @@ # Omitted Modules (and Description/Reason): # # Multimedia: - # almodule.c -- Non-OS/2 Audio Channel Facility (?) - # cdmodule.c -- Wrapper of Non-OS/2 CD Audio Functions # audioop.c -- Various Compute Operations on Audio Samples # imageop.c -- Various Compute Operations on Video Samples - # imgfile.c -- Wrapper of SGI ImageLib API - # rgbimgmodule.c -- Non-OS/2 Image Read/Write Capability (Primitive) # sunaudiodev.c -- Wrapper of Sun Audio Device API - # clmodule.c -- Wrapper of SGI Image/Audio Compression API # Database: # dbmmodule.c -- Wrapper of DBM Database API (Generic Flavor) - # bsddbmodule.c -- Wrapper of DBM Database API (BSD Flavor) # gdbmmodule.c -- Wrapper of DBM Database API (GNU Flavor) # Cryptography: # cryptmodule.c -- Simple Wrapper for crypt() Function - # rotormodule.c -- Implementation of Enigma Crypto Based on Rotors -# cgensupport.obj \ # fcntlmodule.obj \ -# fmmodule.obj \ # fpectlmodule.obj \ # fpetestmodule.obj \ # Unix-Specific getpath.obj \ -# glmodule.obj \ # grpmodule.obj \ # mpzmodule.obj \ # nismodule.obj \ # parsermodule.obj \ -# pcremodule.obj \ # pwdmodule.obj \ -# pypcre.obj \ # readline.obj \ # resource.obj \ -# sgimodule.obj \ -# svmodule.obj \ # syslogmodule.obj \ # termios.obj \ -# timingmodule.obj \ # User Interface: # _tkinter.obj \ @@ -358,14 +343,6 @@ pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ traceback.h tupleobject.h -almodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - arraymodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ import.h intobject.h intrcheck.h listobject.h longobject.h \ @@ -398,30 +375,6 @@ pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ traceback.h tupleobject.h -cdmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -cgensupport.obj: abstract.h ceval.h cgensupport.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -clmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - cmathmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ import.h intobject.h intrcheck.h listobject.h longobject.h \ @@ -502,22 +455,6 @@ pyerrors.h pyfpe.h pystate.h python.h pythonrun.h rangeobject.h \ sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h -flmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h \ - structmember.h sysmodule.h traceback.h tupleobject.h - -fmmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - fpectlmodule.obj: abstract.h ceval.h classobject.h cobject.h \ complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ funcobject.h import.h intobject.h intrcheck.h listobject.h \ @@ -552,14 +489,6 @@ python.h pythonrun.h rangeobject.h sliceobject.h stringobject.h \ sysmodule.h traceback.h tupleobject.h -glmodule.obj: abstract.h ceval.h cgensupport.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - grpmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ grp.h import.h intobject.h intrcheck.h listobject.h longobject.h \ @@ -576,14 +505,6 @@ pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ traceback.h tupleobject.h -imgfile.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - main.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ import.h intobject.h intrcheck.h listobject.h longobject.h \ @@ -600,16 +521,6 @@ pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ stringobject.h sysmodule.h traceback.h tupleobject.h -md5c.obj: pyconfig.h md5.h - -md5module.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h md5.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - mpzmodule.obj: abstract.h ceval.h classobject.h cobject.h \ complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ funcobject.h import.h intobject.h intrcheck.h listobject.h \ @@ -643,14 +554,6 @@ rangeobject.h sliceobject.h stringobject.h sysmodule.h token.h \ traceback.h tupleobject.h -pcremodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pcre-internal.h pcre.h pydebug.h pyerrors.h \ - pyfpe.h pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - posix.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ import.h intobject.h intrcheck.h listobject.h longobject.h \ @@ -667,14 +570,6 @@ python.h pythonrun.h rangeobject.h sliceobject.h stringobject.h \ sysmodule.h traceback.h tupleobject.h -puremodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - pwdmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ import.h intobject.h intrcheck.h listobject.h longobject.h \ @@ -683,14 +578,6 @@ python.h pythonrun.h rangeobject.h sliceobject.h stringobject.h \ sysmodule.h traceback.h tupleobject.h -pypcre.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - graminit.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pcre-internal.h pcre.h pydebug.h \ - pyerrors.h pyfpe.h pystate.h python.h pythonrun.h rangeobject.h \ - sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h - readline.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ import.h intobject.h intrcheck.h listobject.h longobject.h \ @@ -707,22 +594,6 @@ pyerrors.h pyfpe.h pystate.h python.h pythonrun.h rangeobject.h \ sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h -rgbimgmodule.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -rotormodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h mymath.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - selectmodule.obj: abstract.h ceval.h classobject.h cobject.h \ complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ funcobject.h import.h intobject.h intrcheck.h listobject.h \ @@ -731,14 +602,6 @@ pyerrors.h pyfpe.h pystate.h python.h pythonrun.h rangeobject.h \ sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h -sgimodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - signalmodule.obj: abstract.h ceval.h classobject.h cobject.h \ complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ funcobject.h import.h intobject.h intrcheck.h listobject.h \ @@ -756,22 +619,6 @@ pyfpe.h pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ stringobject.h sysmodule.h traceback.h tupleobject.h -soundex.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -stdwinmodule.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - structmodule.obj: abstract.h ceval.h classobject.h cobject.h \ complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ funcobject.h import.h intobject.h intrcheck.h listobject.h \ @@ -789,15 +636,6 @@ sliceobject.h stringobject.h structmember.h sysmodule.h \ traceback.h tupleobject.h -svmodule.obj: abstract.h c:\mptn\include\sys\time.h ceval.h classobject.h \ - cobject.h compile.h complexobject.h pyconfig.h dictobject.h \ - fileobject.h floatobject.h funcobject.h import.h intobject.h \ - intrcheck.h listobject.h longobject.h methodobject.h modsupport.h \ - moduleobject.h mymalloc.h myproto.h object.h objimpl.h pydebug.h \ - pyerrors.h pyfpe.h pystate.h python.h pythonrun.h rangeobject.h \ - sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h \ - yuv.h - syslogmodule.obj: abstract.h ceval.h classobject.h cobject.h \ complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ funcobject.h import.h intobject.h intrcheck.h listobject.h \ @@ -830,14 +668,6 @@ python.h pythonrun.h rangeobject.h sliceobject.h stringobject.h \ sysmodule.h traceback.h tupleobject.h -timingmodule.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h timing.h traceback.h tupleobject.h - xxmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ import.h intobject.h intrcheck.h listobject.h longobject.h \ Modified: python/branches/p3yk/PCbuild/pythoncore.vcproj ============================================================================== --- python/branches/p3yk/PCbuild/pythoncore.vcproj (original) +++ python/branches/p3yk/PCbuild/pythoncore.vcproj Sat Jun 2 09:41:58 2007 @@ -626,12 +626,6 @@ RelativePath="..\Modules\mathmodule.c"> - - - - - - Author: neal.norwitz Date: Sat Jun 2 09:51:44 2007 New Revision: 55742 Removed: python/branches/p3yk/Doc/lib/libposixfile.tex python/branches/p3yk/Lib/posixfile.py Modified: python/branches/p3yk/Doc/Makefile.deps python/branches/p3yk/Doc/lib/lib.tex python/branches/p3yk/Lib/test/test_sundry.py python/branches/p3yk/Misc/cheatsheet Log: Remove posixfile module (plus some remnants of other modules). Modified: python/branches/p3yk/Doc/Makefile.deps ============================================================================== --- python/branches/p3yk/Doc/Makefile.deps (original) +++ python/branches/p3yk/Doc/Makefile.deps Sat Jun 2 09:51:44 2007 @@ -171,7 +171,6 @@ lib/libgdbm.tex \ lib/libtermios.tex \ lib/libfcntl.tex \ - lib/libposixfile.tex \ lib/libsyslog.tex \ lib/liblogging.tex \ lib/libpdb.tex \ Modified: python/branches/p3yk/Doc/lib/lib.tex ============================================================================== --- python/branches/p3yk/Doc/lib/lib.tex (original) +++ python/branches/p3yk/Doc/lib/lib.tex Sat Jun 2 09:51:44 2007 @@ -263,7 +263,6 @@ \input{libpty} \input{libfcntl} \input{libpipes} -\input{libposixfile} \input{libresource} \input{libnis} \input{libsyslog} Deleted: /python/branches/p3yk/Doc/lib/libposixfile.tex ============================================================================== --- /python/branches/p3yk/Doc/lib/libposixfile.tex Sat Jun 2 09:51:44 2007 +++ (empty file) @@ -1,174 +0,0 @@ -% Manual text and implementation by Jaap Vermeulen -\section{\module{posixfile} --- - File-like objects with locking support} - -\declaremodule{builtin}{posixfile} - \platform{Unix} -\modulesynopsis{A file-like object with support for locking.} -\moduleauthor{Jaap Vermeulen}{} -\sectionauthor{Jaap Vermeulen}{} - - -\indexii{\POSIX}{file object} - -\deprecated{1.5}{The locking operation that this module provides is -done better and more portably by the -\function{\refmodule{fcntl}.lockf()} call. -\withsubitem{(in module fcntl)}{\ttindex{lockf()}}} - -This module implements some additional functionality over the built-in -file objects. In particular, it implements file locking, control over -the file flags, and an easy interface to duplicate the file object. -The module defines a new file object, the posixfile object. It -has all the standard file object methods and adds the methods -described below. This module only works for certain flavors of -\UNIX, since it uses \function{fcntl.fcntl()} for file locking.% -\withsubitem{(in module fcntl)}{\ttindex{fcntl()}} - -To instantiate a posixfile object, use the \function{open()} function -in the \module{posixfile} module. The resulting object looks and -feels roughly the same as a standard file object. - -The \module{posixfile} module defines the following constants: - - -\begin{datadesc}{SEEK_SET} -Offset is calculated from the start of the file. -\end{datadesc} - -\begin{datadesc}{SEEK_CUR} -Offset is calculated from the current position in the file. -\end{datadesc} - -\begin{datadesc}{SEEK_END} -Offset is calculated from the end of the file. -\end{datadesc} - -The \module{posixfile} module defines the following functions: - - -\begin{funcdesc}{open}{filename\optional{, mode\optional{, bufsize}}} - Create a new posixfile object with the given filename and mode. The - \var{filename}, \var{mode} and \var{bufsize} arguments are - interpreted the same way as by the built-in \function{open()} - function. -\end{funcdesc} - -\begin{funcdesc}{fileopen}{fileobject} - Create a new posixfile object with the given standard file object. - The resulting object has the same filename and mode as the original - file object. -\end{funcdesc} - -The posixfile object defines the following additional methods: - -\begin{methoddesc}[posixfile]{lock}{fmt, \optional{len\optional{, start\optional{, whence}}}} - Lock the specified section of the file that the file object is - referring to. The format is explained - below in a table. The \var{len} argument specifies the length of the - section that should be locked. The default is \code{0}. \var{start} - specifies the starting offset of the section, where the default is - \code{0}. The \var{whence} argument specifies where the offset is - relative to. It accepts one of the constants \constant{SEEK_SET}, - \constant{SEEK_CUR} or \constant{SEEK_END}. The default is - \constant{SEEK_SET}. For more information about the arguments refer - to the \manpage{fcntl}{2} manual page on your system. -\end{methoddesc} - -\begin{methoddesc}[posixfile]{flags}{\optional{flags}} - Set the specified flags for the file that the file object is referring - to. The new flags are ORed with the old flags, unless specified - otherwise. The format is explained below in a table. Without - the \var{flags} argument - a string indicating the current flags is returned (this is - the same as the \samp{?} modifier). For more information about the - flags refer to the \manpage{fcntl}{2} manual page on your system. -\end{methoddesc} - -\begin{methoddesc}[posixfile]{dup}{} - Duplicate the file object and the underlying file pointer and file - descriptor. The resulting object behaves as if it were newly - opened. -\end{methoddesc} - -\begin{methoddesc}[posixfile]{dup2}{fd} - Duplicate the file object and the underlying file pointer and file - descriptor. The new object will have the given file descriptor. - Otherwise the resulting object behaves as if it were newly opened. -\end{methoddesc} - -\begin{methoddesc}[posixfile]{file}{} - Return the standard file object that the posixfile object is based - on. This is sometimes necessary for functions that insist on a - standard file object. -\end{methoddesc} - -All methods raise \exception{IOError} when the request fails. - -Format characters for the \method{lock()} method have the following -meaning: - -\begin{tableii}{c|l}{samp}{Format}{Meaning} - \lineii{u}{unlock the specified region} - \lineii{r}{request a read lock for the specified section} - \lineii{w}{request a write lock for the specified section} -\end{tableii} - -In addition the following modifiers can be added to the format: - -\begin{tableiii}{c|l|c}{samp}{Modifier}{Meaning}{Notes} - \lineiii{|}{wait until the lock has been granted}{} - \lineiii{?}{return the first lock conflicting with the requested lock, or - \code{None} if there is no conflict.}{(1)} -\end{tableiii} - -\noindent -Note: - -\begin{description} -\item[(1)] The lock returned is in the format \code{(\var{mode}, \var{len}, -\var{start}, \var{whence}, \var{pid})} where \var{mode} is a character -representing the type of lock ('r' or 'w'). This modifier prevents a -request from being granted; it is for query purposes only. -\end{description} - -Format characters for the \method{flags()} method have the following -meanings: - -\begin{tableii}{c|l}{samp}{Format}{Meaning} - \lineii{a}{append only flag} - \lineii{c}{close on exec flag} - \lineii{n}{no delay flag (also called non-blocking flag)} - \lineii{s}{synchronization flag} -\end{tableii} - -In addition the following modifiers can be added to the format: - -\begin{tableiii}{c|l|c}{samp}{Modifier}{Meaning}{Notes} - \lineiii{!}{turn the specified flags 'off', instead of the default 'on'}{(1)} - \lineiii{=}{replace the flags, instead of the default 'OR' operation}{(1)} - \lineiii{?}{return a string in which the characters represent the flags that - are set.}{(2)} -\end{tableiii} - -\noindent -Notes: - -\begin{description} -\item[(1)] The \samp{!} and \samp{=} modifiers are mutually exclusive. - -\item[(2)] This string represents the flags after they may have been altered -by the same call. -\end{description} - -Examples: - -\begin{verbatim} -import posixfile - -file = posixfile.open('/tmp/test', 'w') -file.lock('w|') -... -file.lock('u') -file.close() -\end{verbatim} Deleted: /python/branches/p3yk/Lib/posixfile.py ============================================================================== --- /python/branches/p3yk/Lib/posixfile.py Sat Jun 2 09:51:44 2007 +++ (empty file) @@ -1,237 +0,0 @@ -"""Extended file operations available in POSIX. - -f = posixfile.open(filename, [mode, [bufsize]]) - will create a new posixfile object - -f = posixfile.fileopen(fileobject) - will create a posixfile object from a builtin file object - -f.file() - will return the original builtin file object - -f.dup() - will return a new file object based on a new filedescriptor - -f.dup2(fd) - will return a new file object based on the given filedescriptor - -f.flags(mode) - will turn on the associated flag (merge) - mode can contain the following characters: - - (character representing a flag) - a append only flag - c close on exec flag - n no delay flag - s synchronization flag - (modifiers) - ! turn flags 'off' instead of default 'on' - = copy flags 'as is' instead of default 'merge' - ? return a string in which the characters represent the flags - that are set - - note: - the '!' and '=' modifiers are mutually exclusive. - - the '?' modifier will return the status of the flags after they - have been changed by other characters in the mode string - -f.lock(mode [, len [, start [, whence]]]) - will (un)lock a region - mode can contain the following characters: - - (character representing type of lock) - u unlock - r read lock - w write lock - (modifiers) - | wait until the lock can be granted - ? return the first lock conflicting with the requested lock - or 'None' if there is no conflict. The lock returned is in the - format (mode, len, start, whence, pid) where mode is a - character representing the type of lock ('r' or 'w') - - note: - the '?' modifier prevents a region from being locked; it is - query only -""" -import warnings -warnings.warn("The posixfile module is deprecated; " - "fcntl.lockf() provides better locking", DeprecationWarning, 2) - -class _posixfile_: - """File wrapper class that provides extra POSIX file routines.""" - - states = ['open', 'closed'] - - # - # Internal routines - # - def __repr__(self): - file = self._file_ - return "<%s posixfile '%s', mode '%s' at %s>" % \ - (self.states[file.closed], file.name, file.mode, \ - hex(id(self))[2:]) - - # - # Initialization routines - # - def open(self, name, mode='r', bufsize=-1): - import __builtin__ - return self.fileopen(__builtin__.open(name, mode, bufsize)) - - def fileopen(self, file): - import types - if repr(type(file)) != "": - raise TypeError, 'posixfile.fileopen() arg must be file object' - self._file_ = file - # Copy basic file methods - for maybemethod in dir(file): - if not maybemethod.startswith('_'): - attr = getattr(file, maybemethod) - if isinstance(attr, types.BuiltinMethodType): - setattr(self, maybemethod, attr) - return self - - # - # New methods - # - def file(self): - return self._file_ - - def dup(self): - import posix - - if not hasattr(posix, 'fdopen'): - raise AttributeError, 'dup() method unavailable' - - return posix.fdopen(posix.dup(self._file_.fileno()), self._file_.mode) - - def dup2(self, fd): - import posix - - if not hasattr(posix, 'fdopen'): - raise AttributeError, 'dup() method unavailable' - - posix.dup2(self._file_.fileno(), fd) - return posix.fdopen(fd, self._file_.mode) - - def flags(self, *which): - import fcntl, os - - if which: - if len(which) > 1: - raise TypeError, 'Too many arguments' - which = which[0] - else: which = '?' - - l_flags = 0 - if 'n' in which: l_flags = l_flags | os.O_NDELAY - if 'a' in which: l_flags = l_flags | os.O_APPEND - if 's' in which: l_flags = l_flags | os.O_SYNC - - file = self._file_ - - if '=' not in which: - cur_fl = fcntl.fcntl(file.fileno(), fcntl.F_GETFL, 0) - if '!' in which: l_flags = cur_fl & ~ l_flags - else: l_flags = cur_fl | l_flags - - l_flags = fcntl.fcntl(file.fileno(), fcntl.F_SETFL, l_flags) - - if 'c' in which: - arg = ('!' not in which) # 0 is don't, 1 is do close on exec - l_flags = fcntl.fcntl(file.fileno(), fcntl.F_SETFD, arg) - - if '?' in which: - which = '' # Return current flags - l_flags = fcntl.fcntl(file.fileno(), fcntl.F_GETFL, 0) - if os.O_APPEND & l_flags: which = which + 'a' - if fcntl.fcntl(file.fileno(), fcntl.F_GETFD, 0) & 1: - which = which + 'c' - if os.O_NDELAY & l_flags: which = which + 'n' - if os.O_SYNC & l_flags: which = which + 's' - return which - - def lock(self, how, *args): - import struct, fcntl - - if 'w' in how: l_type = fcntl.F_WRLCK - elif 'r' in how: l_type = fcntl.F_RDLCK - elif 'u' in how: l_type = fcntl.F_UNLCK - else: raise TypeError, 'no type of lock specified' - - if '|' in how: cmd = fcntl.F_SETLKW - elif '?' in how: cmd = fcntl.F_GETLK - else: cmd = fcntl.F_SETLK - - l_whence = 0 - l_start = 0 - l_len = 0 - - if len(args) == 1: - l_len = args[0] - elif len(args) == 2: - l_len, l_start = args - elif len(args) == 3: - l_len, l_start, l_whence = args - elif len(args) > 3: - raise TypeError, 'too many arguments' - - # Hack by davem at magnet.com to get locking to go on freebsd; - # additions for AIX by Vladimir.Marangozov at imag.fr - import sys, os - if sys.platform in ('netbsd1', - 'openbsd2', - 'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5', - 'freebsd6', 'freebsd7', - 'bsdos2', 'bsdos3', 'bsdos4'): - flock = struct.pack('lxxxxlxxxxlhh', \ - l_start, l_len, os.getpid(), l_type, l_whence) - elif sys.platform in ('aix3', 'aix4'): - flock = struct.pack('hhlllii', \ - l_type, l_whence, l_start, l_len, 0, 0, 0) - else: - flock = struct.pack('hhllhh', \ - l_type, l_whence, l_start, l_len, 0, 0) - - flock = fcntl.fcntl(self._file_.fileno(), cmd, flock) - - if '?' in how: - if sys.platform in ('netbsd1', - 'openbsd2', - 'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5', - 'bsdos2', 'bsdos3', 'bsdos4'): - l_start, l_len, l_pid, l_type, l_whence = \ - struct.unpack('lxxxxlxxxxlhh', flock) - elif sys.platform in ('aix3', 'aix4'): - l_type, l_whence, l_start, l_len, l_sysid, l_pid, l_vfs = \ - struct.unpack('hhlllii', flock) - elif sys.platform == "linux2": - l_type, l_whence, l_start, l_len, l_pid, l_sysid = \ - struct.unpack('hhllhh', flock) - else: - l_type, l_whence, l_start, l_len, l_sysid, l_pid = \ - struct.unpack('hhllhh', flock) - - if l_type != fcntl.F_UNLCK: - if l_type == fcntl.F_RDLCK: - return 'r', l_len, l_start, l_whence, l_pid - else: - return 'w', l_len, l_start, l_whence, l_pid - -def open(name, mode='r', bufsize=-1): - """Public routine to open a file as a posixfile object.""" - return _posixfile_().open(name, mode, bufsize) - -def fileopen(file): - """Public routine to get a posixfile object from a Python file object.""" - return _posixfile_().fileopen(file) - -# -# Constants -# -SEEK_SET = 0 -SEEK_CUR = 1 -SEEK_END = 2 - -# -# End of posixfile.py -# Modified: python/branches/p3yk/Lib/test/test_sundry.py ============================================================================== --- python/branches/p3yk/Lib/test/test_sundry.py (original) +++ python/branches/p3yk/Lib/test/test_sundry.py Sat Jun 2 09:51:44 2007 @@ -4,9 +4,6 @@ import warnings with guard_warnings_filter(): - warnings.filterwarnings('ignore', r".*posixfile", - DeprecationWarning) - from test.test_support import verbose import BaseHTTPServer @@ -41,7 +38,6 @@ import pdb import pipes #import poplib - import posixfile import pstats import py_compile import pydoc Modified: python/branches/p3yk/Misc/cheatsheet ============================================================================== --- python/branches/p3yk/Misc/cheatsheet (original) +++ python/branches/p3yk/Misc/cheatsheet Sat Jun 2 09:51:44 2007 @@ -1845,7 +1845,6 @@ dumbdbm A dumb and slow but simple dbm clone. [DEL:dump:DEL] [DEL:Print python code that reconstructs a variable.:DEL] email Comprehensive support for internet email. -exceptions Class based built-in exception hierarchy. filecmp File comparison. fileinput Helper class to quickly write a loop over all standard input files. @@ -1860,7 +1859,6 @@ www.pauahtun.org/pub/getargspy.zip getpass Utilities to get a password and/or the current user name. glob filename globbing. -gopherlib Gopher protocol client interface. [DEL:grep:DEL] [DEL:'grep' utilities.:DEL] gzip Read & write gzipped files. heapq Priority queue implemented using lists organized as heaps. @@ -1875,7 +1873,6 @@ imputil Privides a way of writing customised import hooks. inspect Tool for probing live Python objects. keyword List of Python keywords. -knee A Python re-implementation of hierarchical module import. linecache Cache lines from files. linuxaudiodev Lunix /dev/audio support. locale Support for number formatting using the current locale @@ -1888,8 +1885,6 @@ mhlib MH (mailbox) interface. mimetools Various tools used by MIME-reading or MIME-writing programs. mimetypes Guess the MIME type of a file. -MimeWriter Generic MIME writer. -mimify Mimification and unmimification of mail messages. mmap Interface to memory-mapped files - they behave like mutable strings./font> multifile Class to make multi-file messages easier to handle. @@ -1908,7 +1903,6 @@ pipes Conversion pipeline templates. pkgunil Utilities for working with Python packages. poplib A POP3 client class. Based on the J. Myers POP3 draft. -posixfile Extended (posix) file operations. posixpath Common operations on POSIX pathnames. pprint Support to pretty-print lists, tuples, & dictionaries recursively. @@ -1921,7 +1915,6 @@ pyclbr Parse a Python file and retrieve classes and methods. Queue A multi-producer, multi-consumer queue. quopri Conversions to/from quoted-printable transport encoding. -rand Don't use unless you want compatibility with C's rand(). random Random variable generators re Regular Expressions. repr Redo repr() but with limits on most sizes. @@ -1930,7 +1923,6 @@ rlcompleter Word completion for GNU readline 2.0. robotparser Parse robots.txt files, useful for web spiders. sched A generally useful event scheduler class. -sets Module for a set datatype. sgmllib A parser for SGML. shelve Manage shelves of pickled objects. shlex Lexical analyzer class for simple shell-like syntaxes. @@ -1942,7 +1934,6 @@ sndhdr Several routines that help recognizing sound. SocketServer Generic socket server classes. stat Constants and functions for interpreting stat/lstat struct. -statcache Maintain a cache of file stats. statvfs Constants for interpreting statvfs struct as returned by os.statvfs()and os.fstatvfs() (if they exist). string A collection of string operations. From nnorwitz at gmail.com Sat Jun 2 16:04:13 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sat, 2 Jun 2007 10:04:13 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures doc (1) Message-ID: <20070602140413.GA2693@python.psfb.org> [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] [13844 refs] TEXINPUTS=/home/neal/python/py3k/Doc/commontex: /home/neal/python/py3k/Doc/../python /home/neal/python/py3k/Doc/tools/mkhowto --html --about html/stdabout.dat --iconserver ../icons --favicon ../icons/pyfav.png --address "See About this document... for information on suggesting changes." --up-link ../index.html --up-title "Python Documentation Index" --global-module-index "../modindex.html" --dvips-safe --dir html/ext ext/ext.tex +++ TEXINPUTS=/home/neal/python/py3k/Doc/ext:/home/neal/python/py3k/Doc/commontex:/home/neal/python/py3k/Doc/paper-letter:/home/neal/python/py3k/Doc/texinputs: +++ latex ext +++ latex2html -init_file ext.l2h -dir /home/neal/python/py3k/Doc/html/ext /home/neal/python/py3k/Doc/ext/ext.tex +++ perl /home/neal/python/py3k/Doc/tools/node2label.pl *.html [15531 refs] TEXINPUTS=/home/neal/python/py3k/Doc/commontex: /home/neal/python/py3k/Doc/../python /home/neal/python/py3k/Doc/tools/mkhowto --html --about html/stdabout.dat --iconserver ../icons --favicon ../icons/pyfav.png --address "See About this document... for information on suggesting changes." --up-link ../index.html --up-title "Python Documentation Index" --global-module-index "../modindex.html" --dvips-safe --dir html/lib lib/lib.tex *** Session transcript and error messages are in /home/neal/python/py3k/Doc/html/lib/lib.how. *** Exited with status 1. The relevant lines from the transcript are: ------------------------------------------------------------------------ +++ latex lib This is TeX, Version 3.14159 (Web2C 7.4.5) (/home/neal/python/py3k/Doc/lib/lib.tex LaTeX2e <2001/06/01> Babel and hyphenation patterns for american, french, german, ngerman, n ohyphenation, loaded. (/home/neal/python/py3k/Doc/texinputs/manual.cls Document Class: manual 1998/03/03 Document class (Python manual) (/home/neal/python/py3k/Doc/texinputs/pypaper.sty (/usr/share/texmf/tex/latex/psnfss/times.sty) Using Times instead of Computer Modern. ) (/usr/share/texmf/tex/latex/misc/fancybox.sty Style option: `fancybox' v1.3 <2000/09/19> (tvz) ) (/usr/share/texmf/tex/latex/base/report.cls Document Class: report 2001/04/21 v1.4e Standard LaTeX document class (/usr/share/texmf/tex/latex/base/size10.clo)) (/home/neal/python/py3k/Doc/texinputs/fancyhdr.sty) Using fancier footers than usual. (/home/neal/python/py3k/Doc/texinputs/fncychap.sty) Using fancy chapter headings. (/home/neal/python/py3k/Doc/texinputs/python.sty (/usr/share/texmf/tex/latex/tools/longtable.sty) (/home/neal/python/py3k/Doc/texinputs/underscore.sty) (/usr/share/texmf/tex/latex/tools/verbatim.sty) (/usr/share/texmf/tex/latex/base/alltt.sty))) (/home/neal/python/py3k/Doc/commontex/boilerplate.tex (/home/neal/python/py3k/Doc/commontex/patchlevel.tex)) Writing index file lib.idx No file lib.aux. (/usr/share/texmf/tex/latex/psnfss/ot1ptm.fd) (/usr/share/texmf/tex/latex/psnfss/ot1phv.fd) [1] (/home/neal/python/py3k/Doc/commontex/copyright.tex (/usr/share/texmf/tex/latex/psnfss/omsptm.fd)) [2] Adding blank page after the abstract. [1] [2] No file lib.toc. Adding blank page after the table of contents. [1] [2] (/home/neal/python/py3k/Doc/lib/libintro.tex Chapter 1. (/usr/share/texmf/tex/latex/psnfss/ot1pcr.fd) LaTeX Warning: Reference `builtin' on page 1 undefined on input line 49. ) (/home/neal/python/py3k/Doc/lib/libobjs.tex [1] [2] Chapter 2. ) (/home/neal/python/py3k/Doc/lib/libfuncs.tex [3] [4] [5] [6] [7] LaTeX Warning: Reference `bltin-file-objects' on page 8 undefined on input line 447. Underfull \hbox (badness 10000) in paragraph at lines 468--472 []\OT1/ptm/m/n/10 Note that \OT1/pcr/m/n/10 filter(function, \OT1/ptm/m/it/10 i t-er-able\OT1/pcr/m/n/10 ) \OT1/ptm/m/n/10 is equiv-a-lent to \OT1/pcr/m/n/10 [ item for item in \OT1/ptm/m/it/10 it-er-able \OT1/pcr/m/n/10 if [8] [9] [10] LaTeX Warning: Reference `bltin-file-objects' on page 11 undefined on input lin e 717. [11] [12] LaTeX Warning: Reference `typesseq-mutable' on page 13 undefined on input line 955. [13] [14] [15]) (/home/neal/python/py3k/Doc/lib/libexcs.tex Underfull \hbox (badness 10000) in paragraph at lines 68--72 \OT1/ptm/m/n/10 The base class for all built-in ex-cep-tions ex-cept \OT1/pcr/m /n/10 StopIteration\OT1/ptm/m/n/10 , \OT1/pcr/m/n/10 GeneratorExit\OT1/ptm/m/n/ 10 , [16] [17] [18] [19] No file ../../Lib/test/exception_hierarchy.txt. ) (/home/neal/python/py3k/Doc/lib/libconsts.tex) (/home/neal/python/py3k/Doc/lib/libstdtypes.tex [20] Chapter 3. [21] [22] LaTeX Warning: Reference `built-in-funcs' on page 23 undefined on input line 28 3. [23] [24] [25] [26] LaTeX Warning: Reference `codec-base-classes' on page 27 undefined on input lin e 587. LaTeX Warning: Reference `codec-base-classes' on page 27 undefined on input lin e 600. LaTeX Warning: Reference `standard-encodings' on page 27 undefined on input lin e 601. [27] [28] [29] [30] Overfull \hbox (8.48134pt too wide) in paragraph at lines 971--981 [] Overfull \hbox (141.78873pt too wide) in paragraph at lines 988--1013 [] [31] Overfull \hbox (44.61931pt too wide) in paragraph at lines 1097--1129 [] [32] [33] Overfull \hbox (98.60141pt too wide) in paragraph at lines 1309--1337 [] [34] Overfull \hbox (44.38484pt too wide) in paragraph at lines 1389--1445 [] [35] LaTeX Warning: Reference `built-in-funcs' on page 36 undefined on input line 15 15. LaTeX Warning: Reference `context-closing' on page 36 undefined on input line 1 567. [36] [37] [38] Underfull \hbox (badness 10000) in paragraph at lines 1815--1822 []\OT1/ptm/m/n/10 An ex-am-ple of a con-text man-ager that re-turns a re-lated ob-ject is the one re-turned by [39] [40] [41]) (/home/neal/python/py3k/Doc/lib/libstrings.tex [42] Chapter 4. LaTeX Warning: Reference `string-methods' on page 43 undefined on input line 10 . ) (/home/neal/python/py3k/Doc/lib/libstring.tex [43] [44] [45] LaTeX Warning: Reference `string-methods' on page 46 undefined on input line 23 7. [46] [47]) (/home/neal/python/py3k/Doc/lib/libre.tex [48] [49] [50] [51] [52] [53] [54] [55] [56] [57]) (/home/neal/python/py3k/Doc/lib/libstruct.tex [58] [59] [60] LaTeX Warning: Reference `module-array' on page 61 undefined on input line 227. LaTeX Warning: Reference `module-xdrlib' on page 61 undefined on input line 228 . ) (/home/neal/python/py3k/Doc/lib/libdifflib.tex [61] [62] [63] [64] [65] [66] [67] [68]) (/home/neal/python/py3k/Doc/lib/libstringio.tex [69] LaTeX Warning: Reference `bltin-file-objects' on page 70 undefined on input lin e 11. [70]) (/home/neal/python/py3k/Doc/lib/libtextwrap.tex [71] [72]) (/home/neal/python/py3k/Doc/lib/libcodecs.tex [73] Underfull \hbox (badness 5161) in paragraph at lines 52--56 []\OT1/ptm/m/n/10 The fac-tory func-tions must re-turn ob-jects pro-vid-ing the in-ter-faces de-fined by the base classes [74] [75] Overfull \hbox (405.07822pt too wide) in paragraph at lines 288--300 [] [76] [77] [78] [79] [80] [81] [82] Overfull \hbox (11.18082pt too wide) in alignment at lines 856--937 [] [] [] Overfull \hbox (11.18082pt too wide) in alignment at lines 937--1017 [] [] [] [83] Overfull \hbox (254.7505pt too wide) in alignment at lines 1017--1098 [] [] [] Overfull \hbox (254.7505pt too wide) in alignment at lines 1098--1178 [] [] [] Overfull \hbox (254.7505pt too wide) in alignment at lines 1178--1203 [] [] [] [84] Package longtable Warning: Column widths have changed (longtable) in table 4.1 on input line 1203. Overfull \hbox (465.03658pt too wide) in paragraph at lines 1215--1304 [] [85]) (/home/neal/python/py3k/Doc/lib/libunicodedata.tex [86] [87]) (/home/neal/python/py3k/Doc/lib/libstringprep.tex [88]) (/home/neal/python/py3k/Doc/lib/libfpformat.tex [89]) Underfull \hbox (badness 10000) in paragraph at lines 50--98 (/home/neal/python/py3k/Doc/lib/datatypes.tex [90] Chapter 5. ) (/home/neal/python/py3k/Doc/lib/libdatetime.tex LaTeX Warning: Reference `module-calendar' on page 91 undefined on input line 5 6. LaTeX Warning: Reference `module-time' on page 91 undefined on input line 57. [91] [92] Underfull \hbox (badness 10000) in paragraph at lines 185--187 \OT1/ptm/m/n/10 The small-est pos-si-ble dif-fer-ence be-tween non-equal \OT1/p cr/m/n/10 timedelta \OT1/ptm/m/n/10 ob-jects, (/usr/share/texmf/tex/latex/psnfss/omlptm.fd) Overfull \hbox (44.65097pt too wide) in paragraph at lines 204--235 [] [93] [94] Underfull \hbox (badness 10000) in paragraph at lines 430--439 \OT1/ptm/m/it/10 d\OT1/pcr/m/n/10 .month, \OT1/ptm/m/it/10 d\OT1/pcr/m/n/10 .da y, 0, 0, 0, \OT1/ptm/m/it/10 d\OT1/pcr/m/n/10 .weekday(), \OT1/ptm/m/it/10 d\OT 1/pcr/m/n/10 .toordinal() - date(\OT1/ptm/m/it/10 d\OT1/pcr/m/n/10 .year, 1, [95] Underfull \hbox (badness 10000) in paragraph at lines 464--467 []\OT1/ptm/m/n/10 The ISO cal-en-dar is a widely used vari-ant of the Gre-go-ri an cal-en-dar. See LaTeX Warning: Reference `strftime-behavior' on page 96 undefined on input line 507. [96] Underfull \hbox (badness 10000) in paragraph at lines 547--551 \OT1/ptm/m/n/10 Return the cur-rent lo-cal date-time, with \OT1/pcr/m/n/10 tzin fo None\OT1/ptm/m/n/10 . This is equiv-a-lent to Underfull \hbox (badness 10000) in paragraph at lines 561--566 []\OT1/ptm/m/n/10 Else \OT1/ptm/m/it/10 tz \OT1/ptm/m/n/10 must be an in-stance of a class \OT1/pcr/m/n/10 tzinfo \OT1/ptm/m/n/10 sub-class, and the cur-rent date Underfull \hbox (badness 10000) in paragraph at lines 561--566 \OT1/ptm/m/n/10 and time are con-verted to \OT1/ptm/m/it/10 tz\OT1/ptm/m/n/10 ' s time zone. In this case the re-sult is equiv-a-lent to Underfull \hbox (badness 10000) in paragraph at lines 582--586 []\OT1/ptm/m/n/10 Else \OT1/ptm/m/it/10 tz \OT1/ptm/m/n/10 must be an in-stance of a class \OT1/pcr/m/n/10 tzinfo \OT1/ptm/m/n/10 sub-class, and the times- Underfull \hbox (badness 10000) in paragraph at lines 582--586 \OT1/ptm/m/n/10 tamp is con-verted to \OT1/ptm/m/it/10 tz\OT1/ptm/m/n/10 's tim e zone. In this case the re-sult is equiv-a-lent to [97] Underfull \hbox (badness 5519) in paragraph at lines 646--648 \OT1/ptm/m/n/10 The lat-est rep-re-sentable \OT1/pcr/m/n/10 datetime\OT1/ptm/m/ n/10 , \OT1/pcr/m/n/10 datetime(MAXYEAR, 12, 31, 23, 59, 59, 999999, [98] [99] Underfull \hbox (badness 10000) in paragraph at lines 874--888 \OT1/ptm/m/it/10 d\OT1/pcr/m/n/10 .weekday(), \OT1/ptm/m/it/10 d\OT1/pcr/m/n/10 .toordinal() - date(\OT1/ptm/m/it/10 d\OT1/pcr/m/n/10 .year, 1, 1).toordinal() + 1, dst)) \OT1/ptm/m/n/10 The Underfull \hbox (badness 10000) in paragraph at lines 923--925 \OT1/ptm/m/n/10 Return a 3-tuple, (ISO year, ISO week num-ber, ISO week-day). T he same as [100] Underfull \hbox (badness 5064) in paragraph at lines 960--969 \OT1/ptm/m/n/10 Return a string rep-re-sent-ing the date and time, for ex-am-pl e \OT1/pcr/m/n/10 datetime(2002, 12, 4, 20, Underfull \hbox (badness 10000) in paragraph at lines 960--969 \OT1/pcr/m/n/10 30, 40).ctime() == 'Wed Dec 4 20:30:40 2002'\OT1/ptm/m/n/10 . \ OT1/pcr/m/n/10 d.ctime() \OT1/ptm/m/n/10 is equiv-a-lent to LaTeX Warning: Reference `strftime-behavior' on page 101 undefined on input lin e 973. [101] LaTeX Warning: Reference `strftime-behavior' on page 102 undefined on input lin e 1103. [102] [103] [104] [105] [106] [107]) (/home/neal/python/py3k/Doc/lib/libcalendar.tex [108] [109] [110] LaTeX Warning: Reference `module-datetime' on page 111 undefined on input line 302. LaTeX Warning: Reference `module-time' on page 111 undefined on input line 303. ) (/home/neal/python/py3k/Doc/lib/libcollections.tex [111] [112] [113] [114] [115] Overfull \hbox (6.89723pt too wide) in paragraph at lines 343--343 []\OT1/pcr/m/n/9 >>> s = [('red', 1), ('blue', 2), ('red', 3), ('blue', 4), ('r ed', 1), ('blue', 4)][] [116] Overfull \hbox (4.8973pt too wide) in paragraph at lines 376--376 []\OT1/pcr/m/n/9 >>> p = Point(11, y=22) # instantiate with positional or k eyword arguments[] Overfull \hbox (31.89726pt too wide) in paragraph at lines 390--390 []\OT1/pcr/m/n/9 EmployeeRecord = NamedTuple('EmployeeRecord', 'name age title department paygrade')[] Overfull \hbox (10.29729pt too wide) in paragraph at lines 390--390 []\OT1/pcr/m/n/9 for record in starmap(EmployeeRecord, csv.reader(open("employe es.csv", "rb"))):[] ) (/home/neal/python/py3k/Doc/lib/libheapq.tex [117] [118] [119]) (/home/neal/python/py3k/Doc/lib/libbisect.tex) (/home/neal/python/py3k/Doc/lib/libarray.tex [120] [121] [122] LaTeX Warning: Reference `module-struct' on page 123 undefined on input line 23 0. LaTeX Warning: Reference `module-xdrlib' on page 123 undefined on input line 23 3. [123]) (/home/neal/python/py3k/Doc/lib/libsched.tex [124]) (/home/neal/python/py3k/Doc/lib/libmutex.tex) (/home/neal/python/py3k/Doc/lib/libqueue.tex [125] [126]) (/home/neal/python/py3k/Doc/lib/libweakref.tex [127] [128] [129] [130]) (/home/neal/python/py3k/Doc/lib/libuserdict.tex [131] LaTeX Warning: Reference `typesmapping' on page 132 undefined on input line 40. LaTeX Warning: Reference `typesseq' on page 132 undefined on input line 97. [132] LaTeX Warning: Reference `string-methods' on page 133 undefined on input line 1 74. ) (/home/neal/python/py3k/Doc/lib/libtypes.tex [133] [134] Underfull \hbox (badness 10000) in paragraph at lines 196--201 \OT1/ptm/m/n/10 The type of ob-jects de-fined in ex-ten-sion mod-ules with \OT1 /pcr/m/n/10 PyMemberDef\OT1/ptm/m/n/10 , such as ) (/home/neal/python/py3k/Doc/lib/libnew.tex [135]) (/home/neal/python/py3k/Doc/lib/libcopy.tex [136] LaTeX Warning: Reference `module-pickle' on page 137 undefined on input line 96 . ) (/home/neal/python/py3k/Doc/lib/libpprint.tex [137] [138]) (/home/neal/python/py3k/Doc/lib/librepr.tex [139] [140]) Underfull \hbox (badness 10000) in paragraph at lines 120--120 (/home/neal/python/py3k/Doc/lib/numeric.tex [141] [142] Chapter 6. ) (/home/neal/python/py3k/Doc/lib/libmath.tex [143] [144] LaTeX Warning: Reference `module-cmath' on page 145 undefined on input line 208 . ) (/home/neal/python/py3k/Doc/lib/libcmath.tex [145] [146]) (/home/neal/python/py3k/Doc/lib/libdecimal.tex [147] [148] [149] [150] Overfull \hbox (21.09727pt too wide) in paragraph at lines 305--305 [] \OT1/pcr/m/n/9 digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6 ' | '7' | '8' | '9'[] [151] [152] [153] [154] [155] [156] [157] [158] [159] Overfull \vbox (959.57pt too high) has occurred while \output is active [160] [161] [162]) (/home/neal/python/py3k/Doc/lib/librandom.tex [163] Underfull \hbox (badness 6575) in paragraph at lines 119--124 \OT1/ptm/m/n/10 Return a ran-domly se-lected el-e-ment from \OT1/pcr/m/n/10 ran ge(\OT1/ptm/m/it/10 start\OT1/pcr/m/n/10 , \OT1/ptm/m/it/10 stop\OT1/pcr/m/n/10 , \OT1/ptm/m/it/10 step\OT1/pcr/m/n/10 )\OT1/ptm/m/n/10 . This is equiv-a-lent to [164] [165]) (/home/neal/python/py3k/Doc/lib/libitertools.tex [166] [167] [168] [169] [170] Overfull \hbox (15.69728pt too wide) in paragraph at lines 331--331 [] \OT1/pcr/m/n/9 yield counter() # yields the fillvalue, or raises IndexError[] [171] [172] [173]) (/home/neal/python/py3k/Doc/lib/libfunctools.tex [174] Overfull \vbox (222.57pt too high) has occurred while \output is active [175] [176]) (/home/neal/python/py3k/Doc/lib/liboperator.tex [177] [178] [179] [180] [181] [182]) (/home/neal/python/py3k/Doc/lib/netdata.tex [183] [184] Chapter 7. ) (/home/neal/python/py3k/Doc/lib/email.tex LaTeX Warning: Reference `module-smtplib' on page 185 undefined on input line 5 8. LaTeX Warning: Reference `module-nntplib' on page 185 undefined on input line 5 9. (/home/neal/python/py3k/Doc/lib/emailmessage.tex [185] [186] [187] [188] [189] [190]) (/home/neal/python/py3k/Doc/lib/emailparser.tex [191] [192] [193]) (/home/neal/python/py3k/Doc/lib/emailgenerator.tex [194]) (/home/neal/python/py3k/Doc/lib/emailmimebase.tex [195] [196]) (/home/neal/python/py3k/Doc/lib/emailheaders.tex [197] [198]) (/home/neal/python/py3k/Doc/lib/emailcharsets.tex [199] [200]) (/home/neal/python/py3k/Doc/lib/emailencoders.tex [201]) (/home/neal/python/py3k/Doc/lib/emailexc.tex [202]) (/home/neal/python/py3k/Doc/lib/emailutil.tex [203] [204]) (/home/neal/python/py3k/Doc/lib/emailiter.tex [205]) [206] [207] [208] [209] [210] [211] [212]) (/home/neal/python/py3k/Doc/lib/libmailcap.tex [213]) (/home/neal/python/py3k/Doc/lib/libmailbox.tex [214] LaTeX Warning: Reference `module-email' on page 215 undefined on input line 18. Underfull \hbox (badness 10000) in paragraph at lines 72--73 [215] [216] [217] [218] [219] [220] (/usr/share/texmf/tex/latex/psnfss/omspcr.fd) [221] [222] [223] [224] [225] [226] [227] [228] [229] [230] [231]) (/home/neal/python/py3k/Doc/lib/libmhlib.tex [232] [233] [234]) (/home/neal/python/py3k/Doc/lib/libmimetools.tex [235] LaTeX Warning: Reference `module-email' on page 236 undefined on input line 61. LaTeX Warning: Reference `module-rfc822' on page 236 undefined on input line 63 . LaTeX Warning: Reference `module-multifile' on page 236 undefined on input line 65. ) (/home/neal/python/py3k/Doc/lib/libmimetypes.tex [236] [237] [238]) (/home/neal/python/py3k/Doc/lib/libmultifile.tex LaTeX Warning: Reference `module-email' on page 239 undefined on input line 43. [239]) (/home/neal/python/py3k/Doc/lib/librfc822.tex [240] [241] LaTeX Warning: Reference `module-email' on page 242 undefined on input line 133 . LaTeX Warning: Reference `module-mailbox' on page 242 undefined on input line 1 35. [242] LaTeX Warning: Reference `module-mimetools' on page 243 undefined on input line 137. [243] Underfull \hbox (badness 7379) in paragraph at lines 254--270 []\OT1/pcr/m/n/10 Message \OT1/ptm/m/n/10 in-stances also sup-port a lim-ited m ap-ping in-ter-face. In par-tic-u-lar: \OT1/ptm/m/it/10 m\OT1/pcr/m/n/10 [name] \OT1/ptm/m/n/10 is like [244]) (/home/neal/python/py3k/Doc/lib/libbase64.tex [245] LaTeX Warning: Reference `module-binascii' on page 246 undefined on input line 163. [246]) (/home/neal/python/py3k/Doc/lib/libbinhex.tex LaTeX Warning: Reference `module-binascii' on page 247 undefined on input line 41. ) (/home/neal/python/py3k/Doc/lib/libbinascii.tex [247] [248] LaTeX Warning: Reference `module-base64' on page 249 undefined on input line 14 0. LaTeX Warning: Reference `module-binhex' on page 249 undefined on input line 14 2. LaTeX Warning: Reference `module-uu' on page 249 undefined on input line 144. LaTeX Warning: Reference `module-quopri' on page 249 undefined on input line 14 6. ) (/home/neal/python/py3k/Doc/lib/libquopri.tex LaTeX Warning: Reference `module-mimify' on page 249 undefined on input line 59 . LaTeX Warning: Reference `module-base64' on page 249 undefined on input line 60 . [249]) (/home/neal/python/py3k/Doc/lib/libuu.tex LaTeX Warning: Reference `module-binascii' on page 250 undefined on input line 57. ) (/home/neal/python/py3k/Doc/lib/markup.tex [250] Chapter 8. ) (/home/neal/python/py3k/Doc/lib/libhtmlparser.tex [251] [252]) (/home/neal/python/py3k/Doc/lib/libsgmllib.tex [253] [254] [255]) (/home/neal/python/py3k/Doc/lib/libhtmllib.tex LaTeX Warning: Reference `module-formatter' on page 256 undefined on input line 81. LaTeX Warning: Reference `module-HTMLParser' on page 256 undefined on input lin e 87. [256] LaTeX Warning: Reference `module-htmlentitydefs' on page 257 undefined on input line 89. LaTeX Warning: Reference `module-sgmllib' on page 257 undefined on input line 9 0. Underfull \hbox (badness 7168) in paragraph at lines 158--165 \OT1/ptm/m/n/10 This mod-ule de-fines three dic-tio-nar-ies, \OT1/pcr/m/n/10 na me2codepoint\OT1/ptm/m/n/10 , \OT1/pcr/m/n/10 codepoint2name\OT1/ptm/m/n/10 , a nd \OT1/pcr/m/n/10 entitydefs\OT1/ptm/m/n/10 . [257]) (/home/neal/python/py3k/Doc/lib/libpyexpat.tex LaTeX Warning: Reference `expaterror-objects' on page 258 undefined on input li ne 36. [258] Underfull \hbox (badness 10000) in paragraph at lines 160--167 \OT1/ptm/m/n/10 Calling this with a true value for \OT1/ptm/m/it/10 flag \OT1/p tm/m/n/10 (the de-fault) will cause Ex-pat to call the [259] [260] [261] [262] [263] [264] [265]) (/home/neal/python/py3k/Doc/lib/xmldom.tex LaTeX Warning: Reference `dom-conformance' on page 266 undefined on input line 71. [266] [267] LaTeX Warning: Reference `dom-implementation-objects' on page 268 undefined on input line 181. LaTeX Warning: Reference `dom-node-objects' on page 268 undefined on input line 183. LaTeX Warning: Reference `dom-nodelist-objects' on page 268 undefined on input line 185. LaTeX Warning: Reference `dom-documenttype-objects' on page 268 undefined on in put line 187. LaTeX Warning: Reference `dom-document-objects' on page 268 undefined on input line 189. LaTeX Warning: Reference `dom-element-objects' on page 268 undefined on input l ine 191. LaTeX Warning: Reference `dom-attr-objects' on page 268 undefined on input line 193. LaTeX Warning: Reference `dom-comment-objects' on page 268 undefined on input l ine 195. LaTeX Warning: Reference `dom-text-objects' on page 268 undefined on input line 197. LaTeX Warning: Reference `dom-pi-objects' on page 268 undefined on input line 1 99. [268] [269] [270] [271] [272] [273] Underfull \hbox (badness 10000) in paragraph at lines 807--810 \OT1/ptm/m/n/10 Exception when a node does not ex-ist in the ref-er-enced con-t ext. For ex-am-ple, [274] [275]) (/home/neal/python/py3k/Doc/lib/xmldomminidom.tex [276] [277] [278] [279] Underfull \hbox (badness 10000) in paragraph at lines 242--246 []\OT1/pcr/m/n/10 const \OT1/ptm/m/n/10 dec-la-ra-tions map to vari-ables in th eir re-spec-tive scope (e.g. ) (/home/neal/python/py3k/Doc/lib/xmldompulldom.tex [280]) (/home/neal/python/py3k/Doc/lib/xmlsax.tex [281] LaTeX Warning: Reference `module-xml.sax.handler' on page 282 undefined on inpu t line 122. LaTeX Warning: Reference `module-xml.sax.saxutils' on page 282 undefined on inp ut line 125. LaTeX Warning: Reference `module-xml.sax.xmlreader' on page 282 undefined on in put line 128. [282]) (/home/neal/python/py3k/Doc/lib/xmlsaxhandler.tex [283] [284] [285] [286]) (/home/neal/python/py3k/Doc/lib/xmlsaxutils.tex [287]) (/home/neal/python/py3k/Doc/lib/xmlsaxreader.tex [288] LaTeX Warning: Reference `attributes-objects' on page 289 undefined on input li ne 74. LaTeX Warning: Reference `attributes-ns-objects' on page 289 undefined on input line 92. [289] Underfull \hbox (badness 10000) in paragraph at lines 159--163 \OT1/ptm/m/n/10 Return the cur-rent set-ting for fea-ture \OT1/ptm/m/it/10 fea- ture-name\OT1/ptm/m/n/10 . If the fea-ture is not rec-og-nized, Underfull \hbox (badness 6188) in paragraph at lines 173--177 \OT1/ptm/m/n/10 Return the cur-rent set-ting for prop-erty \OT1/ptm/m/it/10 pro p-er-ty-name\OT1/ptm/m/n/10 . If the prop-erty is not rec-og-nized, a [290] LaTeX Warning: Reference `attributes-objects' on page 291 undefined on input li ne 330. [291]) (/home/neal/python/py3k/Doc/lib/libetree.tex [292] [293] [294] [295]) (/home/neal/python/py3k/Doc/lib/fileformats.tex [296] Chapter 9. ) (/home/neal/python/py3k/Doc/lib/libcsv.tex LaTeX Warning: Reference `csv-examples' on page 297 undefined on input line 37. LaTeX Warning: Reference `csv-fmt-params' on page 297 undefined on input line 6 8. [297] LaTeX Warning: Reference `csv-fmt-params' on page 298 undefined on input line 1 01. LaTeX Warning: Reference `csv-fmt-params' on page 298 undefined on input line 1 17. [298] [299] LaTeX Warning: Reference `csv-contents' on page 300 undefined on input line 320 . [300] [301]) (/home/neal/python/py3k/Doc/lib/libcfgparser.tex [302] Overfull \vbox (35.57pt too high) has occurred while \output is active [303] Underfull \hbox (badness 10000) in paragraph at lines 22--23 [304] LaTeX Warning: Reference `module-shlex' on page 305 undefined on input line 150 . [305] [306]) (/home/neal/python/py3k/Doc/lib/librobotparser.tex Overfull \hbox (1.49724pt too wide) in paragraph at lines 66--66 []\OT1/pcr/m/n/9 >>> rp.can_fetch("*", "http://www.musi-cal.com/cgi-bin/search? city=San+Francisco")[] ) (/home/neal/python/py3k/Doc/lib/libnetrc.tex [307]) (/home/neal/python/py3k/Doc/lib/libxdrlib.tex [308] [309] [310]) Underfull \hbox (badness 10000) in paragraph at lines 244--179 (/home/neal/python/py3k/Doc/lib/libcrypto.tex [311] [312] Chapter 10. ) (/home/neal/python/py3k/Doc/lib/libhashlib.tex [313] LaTeX Warning: Reference `module-hmac' on page 314 undefined on input line 107. LaTeX Warning: Reference `module-base64' on page 314 undefined on input line 10 8. ) (/home/neal/python/py3k/Doc/lib/libhmac.tex [314] LaTeX Warning: Reference `module-hashlib' on page 315 undefined on input line 5 3. ) (/home/neal/python/py3k/Doc/lib/filesys.tex [315] [316] Chapter 11. LaTeX Warning: Reference `bltin-file-objects' on page 317 undefined on input li ne 12. LaTeX Warning: Reference `module-os' on page 317 undefined on input line 17. ) (/home/neal/python/py3k/Doc/lib/libposixpath.tex [317] (/usr/share/texmf/tex/latex/psnfss/omsphv.fd) [318] [319]) (/home/neal/python/py3k/Doc/lib/libfileinput.tex [320] [321] Underfull \hbox (badness 10000) in paragraph at lines 185--187 []\OT1/ptm/m/n/10 Usage ex-am-ple: `\OT1/pcr/m/n/10 fi = fileinput.FileInput(op enhook=fileinput.hook_- ) (/home/neal/python/py3k/Doc/lib/libstat.tex [322]) (/home/neal/python/py3k/Doc/lib/libstatvfs.tex [323] [324]) (/home/neal/python/py3k/Doc/lib/libfilecmp.tex [325]) (/home/neal/python/py3k/Doc/lib/libtempfile.tex [326] [327]) (/home/neal/python/py3k/Doc/lib/libglob.tex [328] LaTeX Warning: Reference `module-fnmatch' on page 329 undefined on input line 5 0. ) (/home/neal/python/py3k/Doc/lib/libfnmatch.tex [329] LaTeX Warning: Reference `module-glob' on page 330 undefined on input line 85. ) (/home/neal/python/py3k/Doc/lib/liblinecache.tex) (/home/neal/python/py3k/Doc/lib/libshutil.tex [330] [331]) (/home/neal/python/py3k/Doc/lib/libdircache.tex) Underfull \hbox (badness 10000) in paragraph at lines 37--200 [332] (/home/neal/python/py3k/Doc/lib/archiving.tex [333] [334] Chapter 12. ) (/home/neal/python/py3k/Doc/lib/libzlib.tex [335] [336] LaTeX Warning: Reference `module-gzip' on page 337 undefined on input line 193. ) (/home/neal/python/py3k/Doc/lib/libgzip.tex [337] LaTeX Warning: Reference `module-zlib' on page 338 undefined on input line 69. ) (/home/neal/python/py3k/Doc/lib/libbz2.tex Underfull \hbox (badness 5460) in paragraph at lines 19--22 []\OT1/pcr/m/n/10 BZ2File \OT1/ptm/m/n/10 class im-ple-ments a com-plete file i n-ter-face, in-clud-ing \OT1/pcr/m/n/10 readline()\OT1/ptm/m/n/10 , \OT1/pcr/m/ n/10 readlines()\OT1/ptm/m/n/10 , [338] [339]) (/home/neal/python/py3k/Doc/lib/libzipfile.tex LaTeX Warning: Reference `zipfile-objects' on page 340 undefined on input line 38. LaTeX Warning: Reference `zipinfo-objects' on page 340 undefined on input line 55. [340] [341] [342] [343]) (/home/neal/python/py3k/Doc/lib/libtarfile.tex LaTeX Warning: Reference `tarfile-objects' on page 344 undefined on input line 32. LaTeX Warning: Reference `tar-examples' on page 344 undefined on input line 69. [344] LaTeX Warning: Reference `tarfile-objects' on page 345 undefined on input line 85. LaTeX Warning: Reference `tar-formats' on page 345 undefined on input line 137. LaTeX Warning: Reference `module-zipfile' on page 345 undefined on input line 1 59. [345] LaTeX Warning: Reference `tarinfo-objects' on page 346 undefined on input line 177. LaTeX Warning: Reference `tar-unicode' on page 346 undefined on input line 232. LaTeX Warning: Reference `module-tarfile' on page 346 undefined on input line 2 43. [346] [347] [348] [349] [350] Underfull \hbox (badness 10000) in paragraph at lines 643--653 []\OT1/ptm/m/n/10 The de-fault value for \OT1/ptm/m/it/10 en-cod-ing \OT1/ptm/m /n/10 is the lo-cal char-ac-ter en-cod-ing. It is de-duced from LaTeX Warning: Reference `codec-base-classes' on page 351 undefined on input li ne 656. ) (/home/neal/python/py3k/Doc/lib/persistence.tex [351] [352] Chapter 13. ) (/home/neal/python/py3k/Doc/lib/libpickle.tex [353] Underfull \hbox (badness 10000) in paragraph at lines 94--95 [354] LaTeX Warning: Reference `pickle-sub' on page 355 undefined on input line 255. [355] LaTeX Warning: Reference `pickle-protocol' on page 356 undefined on input line 347. [356] LaTeX Warning: Reference `pickle-protocol' on page 357 undefined on input line 377. LaTeX Warning: Reference `pickle-sub' on page 357 undefined on input line 433. [357] Underfull \hbox (badness 10000) in paragraph at lines 495--496 [358] LaTeX Warning: Reference `pickle-inst' on page 359 undefined on input line 536. [359] [360] [361] [362] LaTeX Warning: Reference `module-copyreg' on page 363 undefined on input line 8 40. LaTeX Warning: Reference `module-shelve' on page 363 undefined on input line 84 2. LaTeX Warning: Reference `module-copy' on page 363 undefined on input line 844. LaTeX Warning: Reference `module-marshal' on page 363 undefined on input line 8 46. ) (/home/neal/python/py3k/Doc/lib/libcopyreg.tex [363]) (/home/neal/python/py3k/Doc/lib/libshelve.tex [364] [365] LaTeX Warning: Reference `module-anydbm' on page 366 undefined on input line 16 5. LaTeX Warning: Reference `module-bsddb' on page 366 undefined on input line 166 . LaTeX Warning: Reference `module-dbhash' on page 366 undefined on input line 16 8. LaTeX Warning: Reference `module-dbm' on page 366 undefined on input line 169. LaTeX Warning: Reference `module-dumbdbm' on page 366 undefined on input line 1 70. LaTeX Warning: Reference `module-gdbm' on page 366 undefined on input line 171. LaTeX Warning: Reference `module-pickle' on page 366 undefined on input line 17 2. LaTeX Warning: Reference `module-cPickle' on page 366 undefined on input line 1 73. ) (/home/neal/python/py3k/Doc/lib/libmarshal.tex [366] Underfull \hbox (badness 10000) in paragraph at lines 38--39 [367]) (/home/neal/python/py3k/Doc/lib/libanydbm.tex [368] LaTeX Warning: Reference `module-dbhash' on page 369 undefined on input line 77 . LaTeX Warning: Reference `module-dbm' on page 369 undefined on input line 78. LaTeX Warning: Reference `module-dumbdbm' on page 369 undefined on input line 7 9. LaTeX Warning: Reference `module-gdbm' on page 369 undefined on input line 80. LaTeX Warning: Reference `module-shelve' on page 369 undefined on input line 82 . LaTeX Warning: Reference `module-whichdb' on page 369 undefined on input line 8 4. ) (/home/neal/python/py3k/Doc/lib/libwhichdb.tex) (/home/neal/python/py3k/Doc/lib/libdbm.tex [369] LaTeX Warning: Reference `module-anydbm' on page 370 undefined on input line 57 . LaTeX Warning: Reference `module-gdbm' on page 370 undefined on input line 58. LaTeX Warning: Reference `module-whichdb' on page 370 undefined on input line 6 0. ) (/home/neal/python/py3k/Doc/lib/libgdbm.tex [370] LaTeX Warning: Reference `module-anydbm' on page 371 undefined on input line 97 . LaTeX Warning: Reference `module-whichdb' on page 371 undefined on input line 9 9. ) (/home/neal/python/py3k/Doc/lib/libdbhash.tex [371] LaTeX Warning: Reference `module-anydbm' on page 372 undefined on input line 43 . LaTeX Warning: Reference `module-bsddb' on page 372 undefined on input line 44. LaTeX Warning: Reference `module-whichdb' on page 372 undefined on input line 4 6. ) (/home/neal/python/py3k/Doc/lib/libbsddb.tex [372] LaTeX Warning: Reference `module-dbhash' on page 373 undefined on input line 98 . [373]) (/home/neal/python/py3k/Doc/lib/libdumbdbm.tex [374] [375] LaTeX Warning: Reference `module-anydbm' on page 376 undefined on input line 46 . LaTeX Warning: Reference `module-dbm' on page 376 undefined on input line 47. LaTeX Warning: Reference `module-gdbm' on page 376 undefined on input line 48. LaTeX Warning: Reference `module-shelve' on page 376 undefined on input line 49 . LaTeX Warning: Reference `module-whichdb' on page 376 undefined on input line 5 1. ) (/home/neal/python/py3k/Doc/lib/libsqlite3.tex [376] [377] LaTeX Warning: Reference `sqlite3-Connection-IsolationLevel' on page 378 undefi ned on input line 150. LaTeX Warning: Reference `sqlite3-Types' on page 378 undefined on input line 16 6. [378] No file sqlite3/complete_statement.py. LaTeX Warning: Reference `sqlite3-Controlling-Transactions' on page 379 undefin ed on input line 216. [379] No file sqlite3/collation_reverse.py. [380] No file sqlite3/row_factory.py. No file sqlite3/text_factory.py. No file sqlite3/execute_1.py. No file sqlite3/execute_2.py. [381] No file sqlite3/executemany_1.py. No file sqlite3/executemany_2.py. [382] No file sqlite3/adapter_point_1.py. [383] No file sqlite3/adapter_point_2.py. Underfull \hbox (badness 10000) in paragraph at lines 518--522 []\OT1/ptm/m/n/10 The \OT1/pcr/m/n/10 sqlite3 \OT1/ptm/m/n/10 mod-ule has two d e-fault adapters for Python's built-in \OT1/pcr/m/n/10 datetime.date \OT1/ptm/m /n/10 and No file sqlite3/adapter_datetime.py. LaTeX Warning: Reference `sqlite3-Module-Contents' on page 384 undefined on inp ut line 563. No file sqlite3/converter_point.py. No file sqlite3/pysqlite_datetime.py. [384] No file sqlite3/shortcut_methods.py. ) (/home/neal/python/py3k/Doc/lib/liballos.tex [385] [386] Chapter 14. ) (/home/neal/python/py3k/Doc/lib/libos.tex [387] LaTeX Warning: Reference `os-file-dir' on page 388 undefined on input line 124. [388] [389] [390] [391] [392] [393] [394] [395] [396] [397] LaTeX Warning: Reference `os-newstreams' on page 398 undefined on input line 11 28. LaTeX Warning: Reference `os-newstreams' on page 398 undefined on input line 11 40. [398] [399] [400] [401] LaTeX Warning: Reference `os-newstreams' on page 402 undefined on input line 15 17. [402] [403] [404] [405]) (/home/neal/python/py3k/Doc/lib/libtime.tex [406] [407] [408] [409] [410] LaTeX Warning: Reference `module-datetime' on page 411 undefined on input line 460. LaTeX Warning: Reference `module-locale' on page 411 undefined on input line 46 3. LaTeX Warning: Reference `module-calendar' on page 411 undefined on input line 466. ) (/home/neal/python/py3k/Doc/lib/liboptparse.tex [411] [412] [413] [414] [415] LaTeX Warning: Reference `optparse-extending-optparse' on page 416 undefined on input line 311. [416] LaTeX Warning: Reference `optparse-extending-optparse' on page 417 undefined on input line 376. LaTeX Warning: Reference `optparse-reference-guide' on page 417 undefined on in put line 413. LaTeX Warning: Reference `optparse-option-callbacks' on page 417 undefined on i nput line 413. [417] [418] Underfull \hbox (badness 5726) in paragraph at lines 516--519 []\OT1/pcr/m/n/10 optparse \OT1/ptm/m/n/10 ex-pands \OT1/pcr/m/n/10 "%prog" \OT 1/ptm/m/n/10 in the us-age string to the name of the cur-rent pro-gram, i.e. [419] [420] [421] LaTeX Warning: Reference `optparse-conflicts-between-options' on page 422 undef ined on input line 704. LaTeX Warning: Reference `optparse-tutorial' on page 422 undefined on input lin e 728. [422] [423] [424] [425] LaTeX Warning: Reference `optparse-option-callbacks' on page 426 undefined on i nput line 1008. [426] LaTeX Warning: Reference `optparse-option-callbacks' on page 427 undefined on i nput line 1121. [427] LaTeX Warning: Reference `optparse-tutorial' on page 428 undefined on input lin e 1142. LaTeX Warning: Reference `optparse-extending-optparse' on page 428 undefined on input line 1151. [428] [429] [430] [431] [432] [433] [434] [435] [436] [437]) (/home/neal/python/py3k/Doc/lib/libgetopt.tex [438] [439] LaTeX Warning: Reference `module-optparse' on page 440 undefined on input line 153. ) (/home/neal/python/py3k/Doc/lib/liblogging.tex [440] [441] [442] Overfull \hbox (10.29729pt too wide) in paragraph at lines 213--213 []\OT1/pcr/m/n/9 2006-02-08 22:20:02,165 192.168.0.1 fbloggs Protocol problem: connection reset[] [443] Overfull \hbox (240.35738pt too wide) in paragraph at lines 317--328 [] [444] Overfull \hbox (10.29729pt too wide) in paragraph at lines 441--441 []\OT1/pcr/m/n/9 2006-02-08 22:20:02,165 192.168.0.1 fbloggs Protocol problem: connection reset[] [445] [446] LaTeX Warning: Reference `typesseq-strings' on page 447 undefined on input line 599. Overfull \hbox (367.90819pt too wide) in paragraph at lines 603--614 [] [447] [448] [449] [450] Overfull \vbox (288.57pt too high) has occurred while \output is active [451] [452] [453] [454] [455] [456] [457] LaTeX Warning: Reference `typesseq-strings' on page 458 undefined on input line 1417. Overfull \hbox (403.90819pt too wide) in paragraph at lines 1422--1454 [] [458] [459] [460] [461] [462] [463]) (/home/neal/python/py3k/Doc/lib/libgetpass.tex) (/home/neal/python/py3k/Doc/lib/libcurses.tex LaTeX Warning: Reference `module-curses.ascii' on page 464 undefined on input l ine 26. LaTeX Warning: Reference `module-curses.panel' on page 464 undefined on input l ine 28. LaTeX Warning: Reference `module-curses.textpad' on page 464 undefined on input line 30. LaTeX Warning: Reference `module-curses.wrapper' on page 464 undefined on input line 33. [464] [465] [466] [467] [468] [469] [470] [471] [472] [473] [474] [475] [476] Package longtable Warning: Column widths have changed (longtable) in table 14.1 on input line 1181. [477] Package longtable Warning: Column widths have changed (longtable) in table 14.2 on input line 1253. [478] [479]) (/home/neal/python/py3k/Doc/lib/libascii.tex [480] [481] [482]) (/home/neal/python/py3k/Doc/lib/libcursespanel.tex [483]) (/home/neal/python/py3k/Doc/lib/libplatform.tex [484] [485]) (/home/neal/python/py3k/Doc/lib/liberrno.tex [486] [487] [488] [489] [490] [491]) (/home/neal/python/py3k/Doc/lib/libctypes.tex [492] [493] [494] [495] Overfull \hbox (6.48393pt too wide) in paragraph at lines 227--390 [] [496] Overfull \hbox (28.49721pt too wide) in paragraph at lines 459--459 []\OT1/pcr/m/n/9 >>> p = create_string_buffer(3) # create a 3 byte buffer, initialized to NUL bytes[] Overfull \hbox (71.69716pt too wide) in paragraph at lines 459--459 []\OT1/pcr/m/n/9 >>> p = create_string_buffer("Hello") # create a buffer c ontaining a NUL terminated string[] [497] Overfull \hbox (23.09721pt too wide) in paragraph at lines 489--489 []\OT1/pcr/m/n/9 ArgumentError: argument 2: exceptions.TypeError: Don't know ho w to convert parameter 2[] [498] [499] [500] [501] [502] [503] [504] [505] Overfull \hbox (12.29723pt too wide) in paragraph at lines 979--979 []\OT1/pcr/m/n/9 TypeError: incompatible types, c_byte_Array_4 instance instead of LP_c_long instance[] [506] [507] [508] Overfull \hbox (17.69722pt too wide) in paragraph at lines 1142--1142 []\OT1/pcr/m/n/9 py_cmp_func [] Overfull \hbox (17.69722pt too wide) in paragraph at lines 1142--1142 []\OT1/pcr/m/n/9 py_cmp_func [] Overfull \hbox (17.69722pt too wide) in paragraph at lines 1142--1142 []\OT1/pcr/m/n/9 py_cmp_func [] Overfull \hbox (17.69722pt too wide) in paragraph at lines 1142--1142 []\OT1/pcr/m/n/9 py_cmp_func [] Overfull \hbox (17.69722pt too wide) in paragraph at lines 1142--1142 []\OT1/pcr/m/n/9 py_cmp_func [] Overfull \hbox (17.69722pt too wide) in paragraph at lines 1142--1142 []\OT1/pcr/m/n/9 py_cmp_func [] Overfull \hbox (17.69722pt too wide) in paragraph at lines 1142--1142 []\OT1/pcr/m/n/9 py_cmp_func [] Overfull \hbox (17.69722pt too wide) in paragraph at lines 1142--1142 []\OT1/pcr/m/n/9 py_cmp_func [] Overfull \hbox (17.69722pt too wide) in paragraph at lines 1142--1142 []\OT1/pcr/m/n/9 py_cmp_func [] Overfull \hbox (17.69722pt too wide) in paragraph at lines 1142--1142 []\OT1/pcr/m/n/9 py_cmp_func [] [509] [510] [511] [512] [513] [514] [515] [516] [517] [518] Overfull \hbox (89.29726pt too wide) in paragraph at lines 1827--1827 []\OT1/pcr/m/n/9 >>> paramflags = (1, "hwnd", 0), (1, "text", "Hi"), (1, "capti on", None), (1, "flags", 0)[] Overfull \hbox (13.69734pt too wide) in paragraph at lines 1856--1856 []\OT1/pcr/m/n/9 >>> GetWindowRect = prototype(("GetWindowRect", windll.user32) , paramflags)[] [519] [520] [521] [522] [523] [524] [525] LaTeX Warning: Reference `ctypes-pointers' on page 526 undefined on input line 2448. LaTeX Warning: Reference `ctypes-arrays' on page 526 undefined on input line 24 49. ) (/home/neal/python/py3k/Doc/lib/libsomeos.tex [526] Chapter 15. ) (/home/neal/python/py3k/Doc/lib/libselect.tex LaTeX Warning: Reference `poll-objects' on page 527 undefined on input line 29. [527]) (/home/neal/python/py3k/Doc/lib/libthread.tex [528] [529]) (/home/neal/python/py3k/Doc/lib/libthreading.tex [530] [531] [532] [533] [534] [535] [536] [537]) (/home/neal/python/py3k/Doc/lib/libdummythread.tex) (/home/neal/python/py3k/Doc/lib/libdummythreading.tex [538]) (/home/neal/python/py3k/Doc/lib/libmmap.tex [539] [540]) (/home/neal/python/py3k/Doc/lib/libreadline.tex [541] LaTeX Warning: Reference `module-rlcompleter' on page 542 undefined on input li ne 145. ) (/home/neal/python/py3k/Doc/lib/librlcompleter.tex [542] [543]) (/home/neal/python/py3k/Doc/lib/libunix.tex [544] Chapter 16. ) (/home/neal/python/py3k/Doc/lib/libposix.tex [545]) (/home/neal/python/py3k/Doc/lib/libpwd.tex LaTeX Warning: Reference `module-grp' on page 546 undefined on input line 55. LaTeX Warning: Reference `module-spwd' on page 546 undefined on input line 56. [546]) (/home/neal/python/py3k/Doc/lib/libspwd.tex LaTeX Warning: Reference `module-grp' on page 547 undefined on input line 46. LaTeX Warning: Reference `module-pwd' on page 547 undefined on input line 47. ) (/home/neal/python/py3k/Doc/lib/libgrp.tex [547] LaTeX Warning: Reference `module-pwd' on page 548 undefined on input line 47. LaTeX Warning: Reference `module-spwd' on page 548 undefined on input line 48. ) (/home/neal/python/py3k/Doc/lib/libcrypt.tex) (/home/neal/python/py3k/Doc/lib/libdl.tex [548] [549]) (/home/neal/python/py3k/Doc/lib/libtermios.tex [550] LaTeX Warning: Reference `module-tty' on page 551 undefined on input line 81. ) (/home/neal/python/py3k/Doc/lib/libtty.tex [551] LaTeX Warning: Reference `module-termios' on page 552 undefined on input line 3 3. ) (/home/neal/python/py3k/Doc/lib/libpty.tex) (/home/neal/python/py3k/Doc/lib/libfcntl.tex [552] [553] LaTeX Warning: Reference `module-os' on page 554 undefined on input line 173. ) (/home/neal/python/py3k/Doc/lib/libpipes.tex [554]) (/home/neal/python/py3k/Doc/lib/libresource.tex [555] [556] [557]) (/home/neal/python/py3k/Doc/lib/libnis.tex) (/home/neal/python/py3k/Doc/lib/libsyslog.tex [558] Underfull \hbox (badness 10000) in paragraph at lines 72--75 []\OT1/pcr/m/n/10 LOG_-PID\OT1/ptm/m/n/10 , \OT1/pcr/m/n/10 LOG_-CONS\OT1/ptm/m /n/10 , \OT1/pcr/m/n/10 LOG_-NDELAY\OT1/ptm/m/n/10 , \OT1/pcr/m/n/10 LOG_-NOWAI T \OT1/ptm/m/n/10 and \OT1/pcr/m/n/10 LOG_-PERROR \OT1/ptm/m/n/10 if de-fined i n ) (/home/neal/python/py3k/Doc/lib/libcommands.tex [559] LaTeX Warning: Reference `module-subprocess' on page 560 undefined on input lin e 53. ) (/home/neal/python/py3k/Doc/lib/ipc.tex [560] Chapter 17. ) (/home/neal/python/py3k/Doc/lib/libsubprocess.tex [561] [562] [563] [564]) (/home/neal/python/py3k/Doc/lib/libsocket.tex [565] [566] [567] Underfull \hbox (badness 5302) in paragraph at lines 246--255 \OT1/ptm/m/n/10 Return a string con-tain-ing the host-name of the ma-chine wher e the Python in-ter-preter is cur- [568] [569] LaTeX Warning: Reference `module-SocketServer' on page 570 undefined on input l ine 457. [570] LaTeX Warning: Reference `bltin-file-objects' on page 571 undefined on input li ne 556. LaTeX Warning: Reference `built-in-funcs' on page 571 undefined on input line 5 64. [571] [572] [573] Overfull \hbox (109.49712pt too wide) in paragraph at lines 848--848 []\OT1/pcr/m/n/9 for res in socket.getaddrinfo(HOST, PORT, socket.AF_UNSPEC, so cket.SOCK_STREAM, 0, socket.AI_PASSIVE):[] [574] [575]) (/home/neal/python/py3k/Doc/lib/libsignal.tex [576] [577]) (/home/neal/python/py3k/Doc/lib/libasyncore.tex [578] [579] [580]) (/home/neal/python/py3k/Doc/lib/libasynchat.tex [581] [582] [583] [584]) (/home/neal/python/py3k/Doc/lib/internet.tex [585] [586] Chapter 18. ) (/home/neal/python/py3k/Doc/lib/libwebbrowser.tex [587] [588]) (/home/neal/python/py3k/Doc/lib/libcgi.tex [589] Underfull \hbox (badness 10000) in paragraph at lines 122--129 []\OT1/ptm/m/n/10 Here the fields, ac-cessed through `\OT1/pcr/m/n/10 form[\OT1 /ptm/m/it/10 key\OT1/pcr/m/n/10 ]\OT1/ptm/m/n/10 ', are them-selves in-stances of \OT1/pcr/m/n/10 FieldStorage \OT1/ptm/m/n/10 (or [590] [591] [592] [593] [594] [595]) (/home/neal/python/py3k/Doc/lib/libcgitb.tex [596]) (/home/neal/python/py3k/Doc/lib/libwsgiref.tex [597] [598] [599] [600] [601] [602] [603]) (/home/neal/python/py3k/Doc/lib/liburllib.tex LaTeX Warning: Reference `bltin-file-objects' on page 604 undefined on input li ne 39. [604] [605] [606] [607] [608]) (/home/neal/python/py3k/Doc/lib/liburllib2.tex [609] [610] LaTeX Warning: Reference `http-password-mgr' on page 611 undefined on input lin e 178. LaTeX Warning: Reference `http-password-mgr' on page 611 undefined on input lin e 185. LaTeX Warning: Reference `http-password-mgr' on page 611 undefined on input lin e 192. LaTeX Warning: Reference `http-password-mgr' on page 611 undefined on input lin e 200. LaTeX Warning: Reference `http-password-mgr' on page 611 undefined on input lin e 207. LaTeX Warning: Reference `http-password-mgr' on page 611 undefined on input lin e 214. [611] [612] [613] [614] [615] [616] [617] [618]) (/home/neal/python/py3k/Doc/lib/libhttplib.tex [619] [620] [621] [622]) (/home/neal/python/py3k/Doc/lib/libftplib.tex [623] LaTeX Warning: Reference `module-netrc' on page 624 undefined on input line 81. [624] [625] [626]) (/home/neal/python/py3k/Doc/lib/libpoplib.tex LaTeX Warning: Reference `module-imaplib' on page 627 undefined on input line 5 9. [627] [628]) (/home/neal/python/py3k/Doc/lib/libimaplib.tex [629] [630] [631] [632] [633]) (/home/neal/python/py3k/Doc/lib/libnntplib.tex [634] [635] [636] [637]) (/home/neal/python/py3k/Doc/lib/libsmtplib.tex [638] [639] [640]) (/home/neal/python/py3k/Doc/lib/libsmtpd.tex [641] [642]) (/home/neal/python/py3k/Doc/lib/libtelnetlib.tex [643] [644]) (/home/neal/python/py3k/Doc/lib/libuuid.tex [645] [646] [647]) (/home/neal/python/py3k/Doc/lib/liburlparse.tex [648] [649] LaTeX Warning: Reference `urlparse-result-object' on page 650 undefined on inpu t line 83. LaTeX Warning: Reference `urlparse-result-object' on page 650 undefined on inpu t line 125. [650] [651]) (/home/neal/python/py3k/Doc/lib/libsocksvr.tex [652] [653] [654]) (/home/neal/python/py3k/Doc/lib/libbasehttp.tex [655] [656] [657] LaTeX Warning: Reference `module-CGIHTTPServer' on page 658 undefined on input line 241. LaTeX Warning: Reference `module-SimpleHTTPServer' on page 658 undefined on inp ut line 244. ) (/home/neal/python/py3k/Doc/lib/libsimplehttp.tex Underfull \hbox (badness 10000) in paragraph at lines 10--13 \OT1/ptm/m/n/10 The \OT1/pcr/m/n/10 SimpleHTTPServer \OT1/ptm/m/n/10 mod-ule de -fines a request-handler class, interface-compatible with Underfull \hbox (badness 10000) in paragraph at lines 20--23 []\OT1/ptm/m/n/10 A lot of the work, such as pars-ing the re-quest, is done by the base class [658] LaTeX Warning: Reference `module-BaseHTTPServer' on page 659 undefined on input line 85. ) (/home/neal/python/py3k/Doc/lib/libcgihttp.tex Underfull \hbox (badness 10000) in paragraph at lines 11--16 \OT1/ptm/m/n/10 The \OT1/pcr/m/n/10 CGIHTTPServer \OT1/ptm/m/n/10 mod-ule de-fi nes a request-handler class, in-ter-face com-pat-i- Underfull \hbox (badness 10000) in paragraph at lines 11--16 \OT1/ptm/m/n/10 ble with \OT1/pcr/m/n/10 BaseHTTPServer.BaseHTTPRequestHandler \OT1/ptm/m/n/10 and in-her-its be-hav-ior from LaTeX Warning: Reference `module-BaseHTTPServer' on page 659 undefined on input line 69. [659]) (/home/neal/python/py3k/Doc/lib/libcookielib.tex LaTeX Warning: Reference `file-cookie-jar-classes' on page 660 undefined on inp ut line 68. Underfull \hbox (badness 10000) in paragraph at lines 88--88 [] \OT1/ptm/m/it/10 blocked[]-do-mains=\OT1/pcr/m/sl/10 None\OT1/ptm/m/it/10 , al-lowed[]-do-mains=\OT1/pcr/m/sl/10 None\OT1/ptm/m/it/10 , netscape=\OT1/pcr/m /sl/10 True\OT1/ptm/m/it/10 , Underfull \hbox (badness 10000) in paragraph at lines 88--88 \OT1/ptm/m/it/10 strict[]-ns[]-do-main=\OT1/pcr/m/sl/10 DefaultCookiePolicy.Dom ainLiberal\OT1/ptm/m/it/10 , strict[]-ns[]- [660] LaTeX Warning: Reference `module-urllib2' on page 661 undefined on input line 1 19. LaTeX Warning: Reference `module-Cookie' on page 661 undefined on input line 12 3. [661] [662] [663] [664] [665] [666]) (/home/neal/python/py3k/Doc/lib/libcookie.tex [667] LaTeX Warning: Reference `module-cookielib' on page 668 undefined on input line 73. [668] [669]) (/home/neal/python/py3k/Doc/lib/libxmlrpclib.tex [670] Overfull \vbox (118.57pt too high) has occurred while \output is active [671] Overfull \hbox (399.34782pt too wide) in paragraph at lines 63--82 [] [672] [673] [674] [675]) (/home/neal/python/py3k/Doc/lib/libsimplexmlrpc.tex [676] Underfull \hbox (badness 10000) in paragraph at lines 104--105 [677] [678]) (/home/neal/python/py3k/Doc/lib/libdocxmlrpc.tex Underfull \hbox (badness 10000) in paragraph at lines 24--27 \OT1/ptm/m/n/10 Create a new server in-stance. All pa-ram-e-ters have the same mean-ing as Underfull \hbox (badness 10000) in paragraph at lines 24--27 \OT1/ptm/m/n/10 for \OT1/pcr/m/n/10 SimpleXMLRPCServer.SimpleXMLRPCServer\OT1/p tm/m/n/10 ; \OT1/ptm/m/it/10 re-questHandler \OT1/ptm/m/n/10 de-faults to [679] Overfull \hbox (40.33405pt too wide) in paragraph at lines 80--86 \OT1/ptm/m/n/10 The \OT1/pcr/m/n/10 DocCGIXMLRPCRequestHandler \OT1/ptm/m/n/10 class is de-rived from \OT1/pcr/m/n/10 SimpleXMLRPCServer.CGIXMLRPCRequestHandl er ) (/home/neal/python/py3k/Doc/lib/libmm.tex [680] Chapter 19. ) (/home/neal/python/py3k/Doc/lib/libaudioop.tex [681] [682]) (/home/neal/python/py3k/Doc/lib/libaifc.tex [683] [684] [685]) (/home/neal/python/py3k/Doc/lib/libsunau.tex [686] [687]) (/home/neal/python/py3k/Doc/lib/libwave.tex [688] [689]) (/home/neal/python/py3k/Doc/lib/libchunk.tex [690]) (/home/neal/python/py3k/Doc/lib/libcolorsys.tex [691]) (/home/neal/python/py3k/Doc/lib/libimghdr.tex [692]) (/home/neal/python/py3k/Doc/lib/libsndhdr.tex) (/home/neal/python/py3k/Doc/lib/libossaudiodev.tex [693] [694] [695] [696] [697]) (/home/neal/python/py3k/Doc/lib/tkinter.tex [698] Chapter 20. LaTeX Warning: Reference `other-gui-packages' on page 699 undefined on input li ne 22. [699] [700] [701] LaTeX Warning: Reference `tkinter-basic-mapping' on page 702 undefined on input line 292. [702] LaTeX Warning: Reference `tkinter-setting-options' on page 703 undefined on inp ut line 378. [703] [704] [705] [706] [707] [708] [709] [710] [711] [712] [713] [714] [715] (/home/neal/python/py3k/Doc/lib/libturtle.tex [716] [717] [718]) [719] [720] [721] [722]) (/home/neal/python/py3k/Doc/lib/i18n.tex [723] [724] Chapter 21. ) (/home/neal/python/py3k/Doc/lib/libgettext.tex [725] [726] [727] [728] [729] [730] [731] [732] [733]) (/home/neal/python/py3k/Doc/lib/liblocale.tex [734] Overfull \hbox (60.05505pt too wide) in paragraph at lines 64--104 [] [735] [736] [737] [738] Overfull \hbox (71.69716pt too wide) in paragraph at lines 449--449 []\OT1/pcr/m/n/9 >>> locale.setlocale(locale.LC_ALL, 'de_DE') # use German loca le; name might vary with platform[] [739]) [740] (/home/neal/python/py3k/Doc/lib/frameworks.tex [741] [742] Chapter 22. ) (/home/neal/python/py3k/Doc/lib/libcmd.tex [743] [744]) (/home/neal/python/py3k/Doc/lib/libshlex.tex LaTeX Warning: Reference `shlex-objects' on page 745 undefined on input line 50 . LaTeX Warning: Reference `module-ConfigParser' on page 745 undefined on input l ine 55. [745] [746] [747]) (/home/neal/python/py3k/Doc/lib/development.tex [748] Chapter 23. ) (/home/neal/python/py3k/Doc/lib/libpydoc.tex) (/home/neal/python/py3k/Doc/lib/libdoctest.tex [749] [750] [751] [752] [753] LaTeX Warning: Reference `doctest-basic-api' on page 754 undefined on input lin e 218. LaTeX Warning: Reference `doctest-basic-api' on page 754 undefined on input lin e 275. [754] LaTeX Warning: Reference `doctest-basic-api' on page 755 undefined on input lin e 296. [755] [756] [757] [758] [759] Overfull \hbox (47.4447pt too wide) in paragraph at lines 703--715 [][] Underfull \hbox (badness 10000) in paragraph at lines 703--715 [760] [761] [762] LaTeX Warning: Reference `doctest-simple-testmod' on page 763 undefined on inpu t line 888. LaTeX Warning: Reference `doctest-simple-testfile' on page 763 undefined on inp ut line 889. LaTeX Warning: Reference `doctest-options' on page 763 undefined on input line 958. [763] [764] LaTeX Warning: Reference `doctest-options' on page 765 undefined on input line 1150. [765] LaTeX Warning: Reference `doctest-options' on page 766 undefined on input line 1242. [766] [767] [768] [769] LaTeX Warning: Reference `doctest-options' on page 770 undefined on input line 1531. LaTeX Warning: Reference `doctest-options' on page 770 undefined on input line 1562. [770] LaTeX Warning: Reference `doctest-options' on page 771 undefined on input line 1666. [771] [772] [773] LaTeX Warning: Reference `doctest-advanced-api' on page 774 undefined on input line 1874. [774]) (/home/neal/python/py3k/Doc/lib/libunittest.tex [775] LaTeX Warning: Reference `module-doctest' on page 776 undefined on input line 8 6. [776] [777] [778] [779] [780] Underfull \hbox (badness 10000) in paragraph at lines 372--376 []\OT1/ptm/m/n/10 will cre-ate a test suite that will run \OT1/pcr/m/n/10 Widge tTestCase.testDefaultSize() \OT1/ptm/m/n/10 and [781] [782] [783] [784] [785] [786] Underfull \hbox (badness 10000) in paragraph at lines 927--937 \OT1/ptm/m/n/10 with three test meth-ods (\OT1/pcr/m/n/10 test_-one()\OT1/ptm/m /n/10 , \OT1/pcr/m/n/10 test_-two()\OT1/ptm/m/n/10 , and \OT1/pcr/m/n/10 test_- three()\OT1/ptm/m/n/10 ), the spec-i-fier ) (/home/neal/python/py3k/Doc/lib/libtest.tex LaTeX Warning: Reference `module-unittest' on page 787 undefined on input line 24. [787] LaTeX Warning: Reference `module-doctest' on page 788 undefined on input line 2 5. [788] [789] [790]) (/home/neal/python/py3k/Doc/lib/libpdb.tex [791] [792] Chapter 24. [793] [794] [795] [796] [797]) (/home/neal/python/py3k/Doc/lib/libprofile.tex [798] Chapter 25. [799] [800] [801] [802] *** MACRO stmodindex IS OBSOLETE -- USE declaremodule INSTEAD! [803] [804] [805] [806]) (/home/neal/python/py3k/Doc/lib/libhotshot.tex Underfull \hbox (badness 10000) in paragraph at lines 32--33 [807] LaTeX Warning: Reference `module-profile' on page 808 undefined on input line 1 08. ) (/home/neal/python/py3k/Doc/lib/libtimeit.tex [808] [809] [810]) (/home/neal/python/py3k/Doc/lib/libtrace.tex [811] [812]) Underfull \hbox (badness 10000) in paragraph at lines 108--357 (/home/neal/python/py3k/Doc/lib/libpython.tex [813] [814] Chapter 26. ) (/home/neal/python/py3k/Doc/lib/libsys.tex [815] [816] Underfull \hbox (badness 10000) in paragraph at lines 220--225 []\OT1/ptm/m/n/10 On Win-dows NT+, file names are Uni-code na-tively, so no con -ver-sion is per-formed. [817] LaTeX Warning: Reference `debugger' on page 818 undefined on input line 323. [818] LaTeX Warning: Reference `profile' on page 819 undefined on input line 446. [819] LaTeX Warning: Reference `debugger-hooks' on page 820 undefined on input line 4 73. [820] LaTeX Warning: Reference `module-site' on page 821 undefined on input line 581. ) (/home/neal/python/py3k/Doc/lib/libbltin.tex LaTeX Warning: Reference `builtin' on page 821 undefined on input line 10. ) (/home/neal/python/py3k/Doc/lib/libmain.tex [821]) (/home/neal/python/py3k/Doc/lib/libwarnings.tex Overfull \hbox (105.20143pt too wide) in paragraph at lines 55--82 [] [822] Overfull \hbox (4.07121pt too wide) in paragraph at lines 108--125 [] [823]) (/home/neal/python/py3k/Doc/lib/libcontextlib.tex [824] [825]) (/home/neal/python/py3k/Doc/lib/libatexit.tex LaTeX Warning: Reference `module-readline' on page 826 undefined on input line 54. [826]) (/home/neal/python/py3k/Doc/lib/libtraceback.tex [827] [828]) (/home/neal/python/py3k/Doc/lib/libfuture.tex [829] Underfull \hbox (badness 10000) in paragraph at lines 61--63 []\OT1/ptm/m/n/10 Instances of class \OT1/pcr/m/n/10 _-Feature \OT1/ptm/m/n/10 have two cor-re-spond-ing meth-ods, \OT1/pcr/m/n/10 getOptionalRelease() \OT1/p tm/m/n/10 and ) (/home/neal/python/py3k/Doc/lib/libgc.tex [830] [831] Underfull \hbox (badness 5490) in paragraph at lines 193--196 \OT1/ptm/m/n/10 The de-bug-ging flags nec-es-sary for the col-lec-tor to print in-for-ma-tion about a leak-ing pro-gram ) (/home/neal/python/py3k/Doc/lib/libinspect.tex [832] [833] [834] [835] Underfull \hbox (badness 10000) in paragraph at lines 342--350 Underfull \hbox (badness 10000) in paragraph at lines 350--351 [836]) (/home/neal/python/py3k/Doc/lib/libsite.tex [837]) (/home/neal/python/py3k/Doc/lib/libuser.tex LaTeX Warning: Reference `module-site' on page 838 undefined on input line 70. [838]) (/home/neal/python/py3k/Doc/lib/libfpectl.tex LaTeX Warning: Reference `fpectl-limitations' on page 839 undefined on input li ne 13. [839]) (/home/neal/python/py3k/Doc/lib/custominterp.tex [840] Chapter 27. ) (/home/neal/python/py3k/Doc/lib/libcode.tex Underfull \hbox (badness 10000) in paragraph at lines 25--29 \OT1/ptm/m/n/10 Closely em-u-late the be-hav-ior of the in-ter-ac-tive Python i n-ter-preter. This class builds on [841] Underfull \hbox (badness 10000) in paragraph at lines 79--84 []\OT1/ptm/m/n/10 The in-put is in-cor-rect; \OT1/pcr/m/n/10 compile_-command() \OT1/ptm/m/n/10 raised an ex-cep-tion (\OT1/pcr/m/n/10 SyntaxError \OT1/ptm/m/ n/10 or [842]) (/home/neal/python/py3k/Doc/lib/libcodeop.tex [843]) (/home/neal/python/py3k/Doc/lib/modules.tex [844] Chapter 28. ) (/home/neal/python/py3k/Doc/lib/libimp.tex [845] [846] [847]) (/home/neal/python/py3k/Doc/lib/libzipimport.tex LaTeX Warning: Reference `zipimporter-objects' on page 848 undefined on input l ine 42. [848]) (/home/neal/python/py3k/Doc/lib/libpkgutil.tex [849]) (/home/neal/python/py3k/Doc/lib/libmodulefinder.tex [850]) (/home/neal/python/py3k/Doc/lib/librunpy.tex [851]) (/home/neal/python/py3k/Doc/lib/language.tex [852] Chapter 29. ) (/home/neal/python/py3k/Doc/lib/libparser.tex [853] LaTeX Warning: Reference `module-symbol' on page 854 undefined on input line 98 . LaTeX Warning: Reference `module-token' on page 854 undefined on input line 100 . [854] [855] [856] [857] [858] [859] [860] [861]) (/home/neal/python/py3k/Doc/lib/libsymbol.tex LaTeX Warning: Reference `module-parser' on page 862 undefined on input line 29 . ) (/home/neal/python/py3k/Doc/lib/libtoken.tex [862] LaTeX Warning: Reference `module-parser' on page 863 undefined on input line 43 . ) (/home/neal/python/py3k/Doc/lib/libkeyword.tex) (/home/neal/python/py3k/Doc/lib/libtokenize.tex LaTeX Warning: Reference `bltin-file-objects' on page 863 undefined on input li ne 21. LaTeX Warning: Reference `bltin-file-objects' on page 863 undefined on input li ne 46. [863]) (/home/neal/python/py3k/Doc/lib/libtabnanny.tex [864] LaTeX Warning: Reference `module-tokenize' on page 865 undefined on input line 60. ) (/home/neal/python/py3k/Doc/lib/libpyclbr.tex [865]) (/home/neal/python/py3k/Doc/lib/libpycompile.tex [866] LaTeX Warning: Reference `module-compileall' on page 867 undefined on input lin e 52. ) (/home/neal/python/py3k/Doc/lib/libcompileall.tex LaTeX Warning: Reference `module-pycompile' on page 867 undefined on input line 62. ) (/home/neal/python/py3k/Doc/lib/libdis.tex [867] [868] [869] [870] [871] [872] [873] [874]) (/home/neal/python/py3k/Doc/lib/libpickletools.tex) (/home/neal/python/py3k/Doc/lib/distutils.tex) (/home/neal/python/py3k/Doc/lib/libast.tex [875] [876] Chapter 30. No file ../../Parser/Python.asdl. ) (/home/neal/python/py3k/Doc/lib/libmisc.tex [877] [878] Chapter 31. ) (/home/neal/python/py3k/Doc/lib/libformatter.tex [879] [880] [881]) (/home/neal/python/py3k/Doc/lib/libsun.tex [882] Chapter 32. ) (/home/neal/python/py3k/Doc/lib/libsunaudio.tex [883]) (/home/neal/python/py3k/Doc/lib/windows.tex [884] Chapter 33. ) (/home/neal/python/py3k/Doc/lib/libmsilib.tex [885] [886] Underfull \hbox (badness 10000) in paragraph at lines 166--173 \OT1/pcr/m/n/10 REFRESH\OT1/ptm/m/n/10 , \OT1/pcr/m/n/10 MSIMODIFY_-INSERT\OT1/ ptm/m/n/10 , \OT1/pcr/m/n/10 MSIMODIFY_-UPDATE\OT1/ptm/m/n/10 , \OT1/pcr/m/n/10 MSIMODIFY_-ASSIGN\OT1/ptm/m/n/10 , \OT1/pcr/m/n/10 MSIMODIFY_- Underfull \hbox (badness 10000) in paragraph at lines 166--173 \OT1/pcr/m/n/10 REPLACE\OT1/ptm/m/n/10 , \OT1/pcr/m/n/10 MSIMODIFY_-MERGE\OT1/p tm/m/n/10 , \OT1/pcr/m/n/10 MSIMODIFY_-DELETE\OT1/ptm/m/n/10 , \OT1/pcr/m/n/10 MSIMODIFY_-INSERT_-TEMPORARY\OT1/ptm/m/n/10 , Underfull \hbox (badness 10000) in paragraph at lines 166--173 \OT1/pcr/m/n/10 MSIMODIFY_-VALIDATE\OT1/ptm/m/n/10 , \OT1/pcr/m/n/10 MSIMODIFY_ -VALIDATE_-NEW\OT1/ptm/m/n/10 , \OT1/pcr/m/n/10 MSIMODIFY_-VALIDATE_-FIELD\OT1/ ptm/m/n/10 , or [887] [888] [889] [890]) (/home/neal/python/py3k/Doc/lib/libmsvcrt.tex [891]) (/home/neal/python/py3k/Doc/lib/libwinreg.tex [892] [893] [894] [895] [896]) (/home/neal/python/py3k/Doc/lib/libwinsound.tex [897]) (/home/neal/python/py3k/Doc/lib/libundoc.tex [898] Appendix A. [899] ! LaTeX Error: Something's wrong--perhaps a missing \item. See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ... l.91 \end{description} ? ! Emergency stop. ... l.91 \end{description} Output written on lib.dvi (905 pages, 3143112 bytes). Transcript written on lib.log. *** Session transcript and error messages are in /home/neal/python/py3k/Doc/html/lib/lib.how. *** Exited with status 1. +++ TEXINPUTS=/home/neal/python/py3k/Doc/lib:/home/neal/python/py3k/Doc/commontex:/home/neal/python/py3k/Doc/paper-letter:/home/neal/python/py3k/Doc/texinputs: +++ latex lib [15483 refs] make: *** [html/lib/lib.html] Error 1 From python-3000-checkins at python.org Sat Jun 2 19:18:56 2007 From: python-3000-checkins at python.org (neal.norwitz) Date: Sat, 2 Jun 2007 19:18:56 +0200 (CEST) Subject: [Python-3000-checkins] r55744 - python/branches/p3yk/Doc/lib/libundoc.tex Message-ID: <20070602171856.B33461E4004@bag.python.org> Author: neal.norwitz Date: Sat Jun 2 19:18:56 2007 New Revision: 55744 Modified: python/branches/p3yk/Doc/lib/libundoc.tex Log: Fix doc breakage. Modified: python/branches/p3yk/Doc/lib/libundoc.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libundoc.tex (original) +++ python/branches/p3yk/Doc/lib/libundoc.tex Sat Jun 2 19:18:56 2007 @@ -88,4 +88,6 @@ % XXX need Windows instructions! \begin{description} +\item +--- This section should be empty for Python 3.0. \end{description} From python-3000-checkins at python.org Sat Jun 2 20:32:17 2007 From: python-3000-checkins at python.org (neal.norwitz) Date: Sat, 2 Jun 2007 20:32:17 +0200 (CEST) Subject: [Python-3000-checkins] r55745 - in python/branches/p3yk/Doc: Makefile whatsnew/whatsnew30.tex Message-ID: <20070602183217.A0A751E4004@bag.python.org> Author: neal.norwitz Date: Sat Jun 2 20:32:16 2007 New Revision: 55745 Added: python/branches/p3yk/Doc/whatsnew/whatsnew30.tex Modified: python/branches/p3yk/Doc/Makefile Log: Make a whatsnew 3.0 template. Modified: python/branches/p3yk/Doc/Makefile ============================================================================== --- python/branches/p3yk/Doc/Makefile (original) +++ python/branches/p3yk/Doc/Makefile Sat Jun 2 20:32:16 2007 @@ -122,7 +122,7 @@ # The end of this should reflect the major/minor version numbers of # the release: -WHATSNEW=whatsnew26 +WHATSNEW=whatsnew30 # what's what MANDVIFILES= paper-$(PAPER)/api.dvi paper-$(PAPER)/ext.dvi \ Added: python/branches/p3yk/Doc/whatsnew/whatsnew30.tex ============================================================================== --- (empty file) +++ python/branches/p3yk/Doc/whatsnew/whatsnew30.tex Sat Jun 2 20:32:16 2007 @@ -0,0 +1,178 @@ +\documentclass{howto} +\usepackage{distutils} +% $Id: whatsnew26.tex 55506 2007-05-22 07:43:29Z 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. + +\title{What's New in Python 3.0} +\release{0.0} +\author{A.M. Kuchling} +\authoraddress{\email{amk at amk.ca}} + +\begin{document} +\maketitle +\tableofcontents + +This article explains the new features in Python 3.0. No release date +for Python 3.0 has been set; it will probably be released in mid 2008. + +% Compare with previous release in 2 - 3 sentences here. + +This article doesn't attempt to provide a complete specification of +the new features, but instead provides a convenient overview. For +full details, you should refer to the documentation for Python 3.0. +% add hyperlink when the documentation becomes available online. +If you want to understand the complete implementation and design +rationale, refer to the PEP for a particular new feature. + + +%====================================================================== + +% 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? +% sets module deprecated + +%====================================================================== +\section{Other Language Changes} + +Here are all of the changes that Python 2.6 makes to the core Python +language. + +\begin{itemize} + +\item Detailed changes are listed here. + +\end{itemize} + + +%====================================================================== +\subsection{Optimizations} + +\begin{itemize} + +\item Detailed changes are listed here. + +\end{itemize} + +The net result of the 3.0 optimizations is that Python 3.0 runs the +pystone benchmark around XX\% slower than Python 2.6. + + +%====================================================================== +\section{New, Improved, and Deprecated Modules} + +As usual, Python's standard library received a number of enhancements and +bug fixes. Here's a partial list of the most notable changes, sorted +alphabetically by module name. Consult the +\file{Misc/NEWS} file in the source tree for a more +complete list of changes, or look through the CVS logs for all the +details. + +\begin{itemize} + +\item Detailed changes are listed here. + +\end{itemize} + + +%====================================================================== +% whole new modules get described in \subsections here + + +% ====================================================================== +\section{Build and C API Changes} + +Changes to Python's build process and to the C API include: + +\begin{itemize} + +\item Detailed changes are listed here. + +\end{itemize} + + +%====================================================================== +\subsection{Port-Specific Changes} + +Platform-specific changes go here. + + +%====================================================================== +\section{Other Changes and Fixes \label{section-other}} + +As usual, there were a bunch of other improvements and bugfixes +scattered throughout the source tree. A search through the change +logs finds there were XXX patches applied and YYY bugs fixed between +Python 2.6 and 3.0. Both figures are likely to be underestimates. + +Some of the more notable changes are: + +\begin{itemize} + +\item Details go here. + +\end{itemize} + + +%====================================================================== +\section{Porting to Python 3.0} + +This section lists previously described changes that may require +changes to your code: + +\begin{itemize} + +\item Everything is all in the details! + +\end{itemize} + + +%====================================================================== +\section{Acknowledgements \label{acks}} + +The author would like to thank the following people for offering +suggestions, corrections and assistance with various drafts of this +article: . + +\end{document} From python-3000-checkins at python.org Mon Jun 4 08:24:23 2007 From: python-3000-checkins at python.org (neal.norwitz) Date: Mon, 4 Jun 2007 08:24:23 +0200 (CEST) Subject: [Python-3000-checkins] r55754 - in python/branches/p3yk/Lib: os.py test/test_os.py Message-ID: <20070604062423.E47D81E4005@bag.python.org> Author: neal.norwitz Date: Mon Jun 4 08:24:18 2007 New Revision: 55754 Modified: python/branches/p3yk/Lib/os.py python/branches/p3yk/Lib/test/test_os.py Log: SF #1730441, os._execvpe raises UnboundLocal due to new try/except semantics Modified: python/branches/p3yk/Lib/os.py ============================================================================== --- python/branches/p3yk/Lib/os.py (original) +++ python/branches/p3yk/Lib/os.py Mon Jun 4 08:24:18 2007 @@ -388,13 +388,14 @@ else: envpath = defpath PATH = envpath.split(pathsep) - saved_exc = None + last_exc = saved_exc = None saved_tb = None for dir in PATH: fullname = path.join(dir, file) try: func(fullname, *argrest) except error as e: + last_exc = e tb = sys.exc_info()[2] if (e.errno != ENOENT and e.errno != ENOTDIR and saved_exc is None): @@ -402,7 +403,7 @@ saved_tb = tb if saved_exc: raise error, saved_exc, saved_tb - raise error, e, tb + raise error, last_exc, tb # Change environ to automatically call putenv() if it exists try: Modified: python/branches/p3yk/Lib/test/test_os.py ============================================================================== --- python/branches/p3yk/Lib/test/test_os.py (original) +++ python/branches/p3yk/Lib/test/test_os.py Mon Jun 4 08:24:18 2007 @@ -433,6 +433,10 @@ except NotImplementedError: pass +class ExecTests(unittest.TestCase): + def test_execvpe_with_bad_program(self): + self.assertRaises(OSError, os.execvpe, 'no such app-', [], None) + class Win32ErrorTests(unittest.TestCase): def test_rename(self): self.assertRaises(WindowsError, os.rename, test_support.TESTFN, test_support.TESTFN+".bak") @@ -469,6 +473,7 @@ MakedirTests, DevNullTests, URandomTests, + ExecTests, Win32ErrorTests ) From python-3000-checkins at python.org Mon Jun 4 08:26:01 2007 From: python-3000-checkins at python.org (neal.norwitz) Date: Mon, 4 Jun 2007 08:26:01 +0200 (CEST) Subject: [Python-3000-checkins] r55755 - python/branches/p3yk/Lib/test/test_os.py Message-ID: <20070604062601.26F501E4002@bag.python.org> Author: neal.norwitz Date: Mon Jun 4 08:26:00 2007 New Revision: 55755 Modified: python/branches/p3yk/Lib/test/test_os.py Log: Get rid of extra whitespace Modified: python/branches/p3yk/Lib/test/test_os.py ============================================================================== --- python/branches/p3yk/Lib/test/test_os.py (original) +++ python/branches/p3yk/Lib/test/test_os.py Mon Jun 4 08:26:00 2007 @@ -381,7 +381,7 @@ os.remove(dirname) os.rmdir(test_support.TESTFN) -class MakedirTests (unittest.TestCase): +class MakedirTests(unittest.TestCase): def setUp(self): os.mkdir(test_support.TESTFN) @@ -400,9 +400,6 @@ 'dir5', 'dir6') os.makedirs(path) - - - def tearDown(self): path = os.path.join(test_support.TESTFN, 'dir1', 'dir2', 'dir3', 'dir4', 'dir5', 'dir6') @@ -414,7 +411,7 @@ os.removedirs(path) -class DevNullTests (unittest.TestCase): +class DevNullTests(unittest.TestCase): def test_devnull(self): f = open(os.devnull, 'w') f.write('hello') @@ -423,7 +420,7 @@ self.assertEqual(f.read(), '') f.close() -class URandomTests (unittest.TestCase): +class URandomTests(unittest.TestCase): def test_urandom(self): try: self.assertEqual(len(os.urandom(1)), 1) From python-3000-checkins at python.org Tue Jun 5 15:29:34 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Tue, 5 Jun 2007 15:29:34 +0200 (CEST) Subject: [Python-3000-checkins] r55759 - python/branches/py3k-struni/Objects/exceptions.c Message-ID: <20070605132934.D59A71E400E@bag.python.org> Author: walter.doerwald Date: Tue Jun 5 15:29:29 2007 New Revision: 55759 Modified: python/branches/py3k-struni/Objects/exceptions.c Log: PyUnicode_FromFormat() does support %02x, so use it for formatting the unicode decoding/encoding/translating exception messages. Modified: python/branches/py3k-struni/Objects/exceptions.c ============================================================================== --- python/branches/py3k-struni/Objects/exceptions.c (original) +++ python/branches/py3k-struni/Objects/exceptions.c Tue Jun 5 15:29:29 2007 @@ -1341,17 +1341,17 @@ if (end==start+1) { int badchar = (int)PyUnicode_AS_UNICODE(((PyUnicodeErrorObject *)self)->object)[start]; - char badchar_str[20]; + const char *fmt; if (badchar <= 0xff) - PyOS_snprintf(badchar_str, sizeof(badchar_str), "x%02x", badchar); + fmt = "'%U' codec can't encode character u'\\x%02x' in position %zd: %U"; else if (badchar <= 0xffff) - PyOS_snprintf(badchar_str, sizeof(badchar_str), "u%04x", badchar); + fmt = "'%U' codec can't encode character u'\\u%04x' in position %zd: %U"; else - PyOS_snprintf(badchar_str, sizeof(badchar_str), "U%08x", badchar); + fmt = "'%U' codec can't encode character u'\\U%08x' in position %zd: %U"; return PyUnicode_FromFormat( - "'%U' codec can't encode character u'\\%s' in position %zd: %U", + fmt, ((PyUnicodeErrorObject *)self)->encoding, - badchar_str, + badchar, start, ((PyUnicodeErrorObject *)self)->reason ); @@ -1416,12 +1416,9 @@ return NULL; if (end==start+1) { - /* FromFormat does not support %02x, so format that separately */ - char byte[4]; - PyOS_snprintf(byte, sizeof(byte), "%02x", - ((int)PyBytes_AS_STRING(((PyUnicodeErrorObject *)self)->object)[start])&0xff); + int byte = (int)(PyBytes_AS_STRING(((PyUnicodeErrorObject *)self)->object)[start]&0xff); return PyUnicode_FromFormat( - "'%U' codec can't decode byte 0x%s in position %zd: %U", + "'%U' codec can't decode byte 0x%02x in position %zd: %U", ((PyUnicodeErrorObject *)self)->encoding, byte, start, @@ -1513,16 +1510,16 @@ if (end==start+1) { int badchar = (int)PyUnicode_AS_UNICODE(((PyUnicodeErrorObject *)self)->object)[start]; - char badchar_str[20]; + const char *fmt; if (badchar <= 0xff) - PyOS_snprintf(badchar_str, sizeof(badchar_str), "x%02x", badchar); + fmt = "can't translate character u'\\x%02x' in position %zd: %U"; else if (badchar <= 0xffff) - PyOS_snprintf(badchar_str, sizeof(badchar_str), "u%04x", badchar); + fmt = "can't translate character u'\\u%04x' in position %zd: %U"; else - PyOS_snprintf(badchar_str, sizeof(badchar_str), "U%08x", badchar); + fmt = "can't translate character u'\\U%08x' in position %zd: %U"; return PyUnicode_FromFormat( - "can't translate character u'\\%s' in position %zd: %U", - badchar_str, + fmt, + badchar, start, ((PyUnicodeErrorObject *)self)->reason ); From python-3000-checkins at python.org Tue Jun 5 15:41:54 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Tue, 5 Jun 2007 15:41:54 +0200 (CEST) Subject: [Python-3000-checkins] r55760 - in python/branches/py3k-struni: Lib/test/test_socket.py Modules/socketmodule.c Message-ID: <20070605134154.642BD1E4005@bag.python.org> Author: walter.doerwald Date: Tue Jun 5 15:41:53 2007 New Revision: 55760 Modified: python/branches/py3k-struni/Lib/test/test_socket.py python/branches/py3k-struni/Modules/socketmodule.c Log: Simplify socket_repr() by using PyUnicode_FromFormat() directly. Add a test that calls socket_repr(). Modified: python/branches/py3k-struni/Lib/test/test_socket.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_socket.py (original) +++ python/branches/py3k-struni/Lib/test/test_socket.py Tue Jun 5 15:41:53 2007 @@ -217,6 +217,10 @@ class GeneralModuleTests(unittest.TestCase): + def test_repr(self): + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.assert_(repr(s).startswith("", (long)s->sock_fd, s->sock_family, s->sock_type, s->sock_proto); - return PyUnicode_FromString(buf); } From python-3000-checkins at python.org Tue Jun 5 15:48:14 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Tue, 5 Jun 2007 15:48:14 +0200 (CEST) Subject: [Python-3000-checkins] r55761 - python/branches/py3k-struni/Modules/socketmodule.c Message-ID: <20070605134814.0374E1E4005@bag.python.org> Author: walter.doerwald Date: Tue Jun 5 15:48:11 2007 New Revision: 55761 Modified: python/branches/py3k-struni/Modules/socketmodule.c Log: Remove unused variable. Modified: python/branches/py3k-struni/Modules/socketmodule.c ============================================================================== --- python/branches/py3k-struni/Modules/socketmodule.c (original) +++ python/branches/py3k-struni/Modules/socketmodule.c Tue Jun 5 15:48:11 2007 @@ -2775,7 +2775,6 @@ static PyObject * sock_repr(PySocketSockObject *s) { - char buf[512]; #if SIZEOF_SOCKET_T > SIZEOF_LONG if (s->sock_fd > LONG_MAX) { /* this can occur on Win64, and actually there is a special From python-3000-checkins at python.org Tue Jun 5 15:49:44 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Tue, 5 Jun 2007 15:49:44 +0200 (CEST) Subject: [Python-3000-checkins] r55762 - python/branches/py3k-struni/Modules/socketmodule.c Message-ID: <20070605134944.CF3161E4005@bag.python.org> Author: walter.doerwald Date: Tue Jun 5 15:49:43 2007 New Revision: 55762 Modified: python/branches/py3k-struni/Modules/socketmodule.c Log: Simplify os_init() implementations by using PyErr_Format() directly instead of PyOS_snprintf()+PyErr_SetString(). Modified: python/branches/py3k-struni/Modules/socketmodule.c ============================================================================== --- python/branches/py3k-struni/Modules/socketmodule.c (original) +++ python/branches/py3k-struni/Modules/socketmodule.c Tue Jun 5 15:49:43 2007 @@ -4045,7 +4045,6 @@ { WSADATA WSAData; int ret; - char buf[100]; ret = WSAStartup(0x0101, &WSAData); switch (ret) { case 0: /* No error */ @@ -4062,9 +4061,7 @@ "WSAStartup failed: requested version not supported"); break; default: - PyOS_snprintf(buf, sizeof(buf), - "WSAStartup failed: error code %d", ret); - PyErr_SetString(PyExc_ImportError, buf); + PyErr_Format(PyExc_ImportError, "WSAStartup failed: error code %d", ret); break; } return 0; /* Failure */ @@ -4082,16 +4079,13 @@ os_init(void) { #ifndef PYCC_GCC - char reason[64]; int rc = sock_init(); if (rc == 0) { return 1; /* Success */ } - PyOS_snprintf(reason, sizeof(reason), - "OS/2 TCP/IP Error# %d", sock_errno()); - PyErr_SetString(PyExc_ImportError, reason); + PyErr_Format(PyExc_ImportError, "OS/2 TCP/IP Error# %d", sock_errno()); return 0; /* Failure */ #else From python-3000-checkins at python.org Tue Jun 5 18:04:11 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Tue, 5 Jun 2007 18:04:11 +0200 (CEST) Subject: [Python-3000-checkins] r55763 - python/branches/py3k-struni/Modules/unicodedata.c Message-ID: <20070605160411.C113D1E4005@bag.python.org> Author: walter.doerwald Date: Tue Jun 5 18:04:09 2007 New Revision: 55763 Modified: python/branches/py3k-struni/Modules/unicodedata.c Log: Change category(), bidirectional(), east_asian_width(), decomposition() and name() to return unicode strings. Modified: python/branches/py3k-struni/Modules/unicodedata.c ============================================================================== --- python/branches/py3k-struni/Modules/unicodedata.c (original) +++ python/branches/py3k-struni/Modules/unicodedata.c Tue Jun 5 18:04:09 2007 @@ -258,7 +258,7 @@ if (old->category_changed != 0xFF) index = old->category_changed; } - return PyString_FromString(_PyUnicode_CategoryNames[index]); + return PyUnicode_FromString(_PyUnicode_CategoryNames[index]); } PyDoc_STRVAR(unicodedata_bidirectional__doc__, @@ -290,7 +290,7 @@ else if (old->bidir_changed != 0xFF) index = old->bidir_changed; } - return PyString_FromString(_PyUnicode_BidirectionalNames[index]); + return PyUnicode_FromString(_PyUnicode_BidirectionalNames[index]); } PyDoc_STRVAR(unicodedata_combining__doc__, @@ -379,7 +379,7 @@ if (old->category_changed == 0) index = 0; /* unassigned */ } - return PyString_FromString(_PyUnicode_EastAsianWidthNames[index]); + return PyUnicode_FromString(_PyUnicode_EastAsianWidthNames[index]); } PyDoc_STRVAR(unicodedata_decomposition__doc__, @@ -411,7 +411,7 @@ if (self) { const change_record *old = get_old_record(self, *PyUnicode_AS_UNICODE(v)); if (old->category_changed == 0) - return PyString_FromString(""); /* unassigned */ + return PyUnicode_FromString(""); /* unassigned */ } if (code < 0 || code >= 0x110000) @@ -450,7 +450,7 @@ decomp[i] = '\0'; - return PyString_FromString(decomp); + return PyUnicode_FromString(decomp); } static void @@ -1063,7 +1063,7 @@ } } - return Py_BuildValue("s", name); + return PyUnicode_FromString(name); } PyDoc_STRVAR(unicodedata_lookup__doc__, From python-3000-checkins at python.org Tue Jun 5 18:19:37 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Tue, 5 Jun 2007 18:19:37 +0200 (CEST) Subject: [Python-3000-checkins] r55764 - python/branches/py3k-struni/Modules/zipimport.c Message-ID: <20070605161937.1FCE41E4005@bag.python.org> Author: walter.doerwald Date: Tue Jun 5 18:19:33 2007 New Revision: 55764 Modified: python/branches/py3k-struni/Modules/zipimport.c Log: Use PyUnicode_FromFormat() directly in zipimporter_repr(). Modified: python/branches/py3k-struni/Modules/zipimport.c ============================================================================== --- python/branches/py3k-struni/Modules/zipimport.c (original) +++ python/branches/py3k-struni/Modules/zipimport.c Tue Jun 5 18:19:33 2007 @@ -187,7 +187,6 @@ static PyObject * zipimporter_repr(ZipImporter *self) { - char buf[500]; char *archive = "???"; char *prefix = ""; @@ -196,14 +195,11 @@ if (self->prefix != NULL && PyString_Check(self->prefix)) prefix = PyString_AsString(self->prefix); if (prefix != NULL && *prefix) - PyOS_snprintf(buf, sizeof(buf), - "", - archive, SEP, prefix); + return PyUnicode_FromFormat("", + archive, SEP, prefix); else - PyOS_snprintf(buf, sizeof(buf), - "", - archive); - return PyUnicode_FromString(buf); + return PyUnicode_FromFormat("", + archive); } /* return fullname.split(".")[-1] */ From python-3000-checkins at python.org Tue Jun 5 21:50:57 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Tue, 5 Jun 2007 21:50:57 +0200 (CEST) Subject: [Python-3000-checkins] r55776 - python/branches/py3k-struni/Objects/intobject.c Message-ID: <20070605195057.2AC5D1E4005@bag.python.org> Author: walter.doerwald Date: Tue Jun 5 21:50:53 2007 New Revision: 55776 Modified: python/branches/py3k-struni/Objects/intobject.c Log: Change int_oct() and int_hex() to return unicode objects. Modified: python/branches/py3k-struni/Objects/intobject.c ============================================================================== --- python/branches/py3k-struni/Objects/intobject.c (original) +++ python/branches/py3k-struni/Objects/intobject.c Tue Jun 5 21:50:53 2007 @@ -920,27 +920,23 @@ static PyObject * int_oct(PyIntObject *v) { - char buf[100]; long x = v -> ob_ival; if (x < 0) - PyOS_snprintf(buf, sizeof(buf), "-0%lo", -x); + return PyUnicode_FromFormat("-0%lo", -x); else if (x == 0) - strcpy(buf, "0"); + return PyUnicode_FromString("0"); else - PyOS_snprintf(buf, sizeof(buf), "0%lo", x); - return PyString_FromString(buf); + return PyUnicode_FromFormat("0%lo", x); } static PyObject * int_hex(PyIntObject *v) { - char buf[100]; long x = v -> ob_ival; if (x < 0) - PyOS_snprintf(buf, sizeof(buf), "-0x%lx", -x); + return PyUnicode_FromFormat("-0x%lx", -x); else - PyOS_snprintf(buf, sizeof(buf), "0x%lx", x); - return PyString_FromString(buf); + return PyUnicode_FromFormat("0x%lx", x); } static PyObject * From python-3000-checkins at python.org Tue Jun 5 22:02:28 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Tue, 5 Jun 2007 22:02:28 +0200 (CEST) Subject: [Python-3000-checkins] r55778 - python/branches/py3k-struni/Objects/unicodeobject.c Message-ID: <20070605200228.162DE1E4005@bag.python.org> Author: walter.doerwald Date: Tue Jun 5 22:02:26 2007 New Revision: 55778 Modified: python/branches/py3k-struni/Objects/unicodeobject.c Log: unichr() is named chr() now => fix name in error message. Modified: python/branches/py3k-struni/Objects/unicodeobject.c ============================================================================== --- python/branches/py3k-struni/Objects/unicodeobject.c (original) +++ python/branches/py3k-struni/Objects/unicodeobject.c Tue Jun 5 22:02:26 2007 @@ -891,14 +891,14 @@ #ifdef Py_UNICODE_WIDE if (ordinal < 0 || ordinal > 0x10ffff) { PyErr_SetString(PyExc_ValueError, - "unichr() arg not in range(0x110000) " + "chr() arg not in range(0x110000) " "(wide Python build)"); return NULL; } #else if (ordinal < 0 || ordinal > 0xffff) { PyErr_SetString(PyExc_ValueError, - "unichr() arg not in range(0x10000) " + "chr() arg not in range(0x10000) " "(narrow Python build)"); return NULL; } From python-3000-checkins at python.org Tue Jun 5 22:07:27 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Tue, 5 Jun 2007 22:07:27 +0200 (CEST) Subject: [Python-3000-checkins] r55779 - python/branches/py3k-struni/Python/bltinmodule.c Message-ID: <20070605200727.8ED651E4005@bag.python.org> Author: walter.doerwald Date: Tue Jun 5 22:07:21 2007 New Revision: 55779 Modified: python/branches/py3k-struni/Python/bltinmodule.c Log: Make the name of the C variables match the Python names for chr()/chr8(). Fix function name in PyArg_ParseTuple() call. Modified: python/branches/py3k-struni/Python/bltinmodule.c ============================================================================== --- python/branches/py3k-struni/Python/bltinmodule.c (original) +++ python/branches/py3k-struni/Python/bltinmodule.c Tue Jun 5 22:07:21 2007 @@ -365,7 +365,7 @@ static PyObject * -builtin_chr(PyObject *self, PyObject *args) +builtin_chr8(PyObject *self, PyObject *args) { long x; char s[1]; @@ -381,24 +381,24 @@ return PyString_FromStringAndSize(s, 1); } -PyDoc_STRVAR(chr_doc, +PyDoc_STRVAR(chr8_doc, "chr8(i) -> 8-bit character\n\ \n\ Return a string of one character with ordinal i; 0 <= i < 256."); static PyObject * -builtin_unichr(PyObject *self, PyObject *args) +builtin_chr(PyObject *self, PyObject *args) { long x; - if (!PyArg_ParseTuple(args, "l:unichr", &x)) + if (!PyArg_ParseTuple(args, "l:chr", &x)) return NULL; return PyUnicode_FromOrdinal(x); } -PyDoc_STRVAR(unichr_doc, +PyDoc_STRVAR(chr_doc, "chr(i) -> Unicode character\n\ \n\ Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff."); @@ -1975,8 +1975,8 @@ {"abs", builtin_abs, METH_O, abs_doc}, {"all", builtin_all, METH_O, all_doc}, {"any", builtin_any, METH_O, any_doc}, - {"chr", builtin_unichr, METH_VARARGS, unichr_doc}, - {"chr8", builtin_chr, METH_VARARGS, chr_doc}, + {"chr", builtin_chr, METH_VARARGS, chr_doc}, + {"chr8", builtin_chr8, METH_VARARGS, chr8_doc}, {"cmp", builtin_cmp, METH_VARARGS, cmp_doc}, {"compile", (PyCFunction)builtin_compile, METH_VARARGS | METH_KEYWORDS, compile_doc}, {"delattr", builtin_delattr, METH_VARARGS, delattr_doc}, From python-3000-checkins at python.org Tue Jun 5 22:15:53 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Tue, 5 Jun 2007 22:15:53 +0200 (CEST) Subject: [Python-3000-checkins] r55780 - python/branches/py3k-struni/Python/sysmodule.c Message-ID: <20070605201553.5B6811E4005@bag.python.org> Author: walter.doerwald Date: Tue Jun 5 22:15:52 2007 New Revision: 55780 Modified: python/branches/py3k-struni/Python/sysmodule.c Log: Change getdefaultencoding() and getfilesystemencoding() to return unicode strings. Modified: python/branches/py3k-struni/Python/sysmodule.c ============================================================================== --- python/branches/py3k-struni/Python/sysmodule.c (original) +++ python/branches/py3k-struni/Python/sysmodule.c Tue Jun 5 22:15:52 2007 @@ -214,7 +214,7 @@ static PyObject * sys_getdefaultencoding(PyObject *self) { - return PyString_FromString(PyUnicode_GetDefaultEncoding()); + return PyUnicode_FromString(PyUnicode_GetDefaultEncoding()); } PyDoc_STRVAR(getdefaultencoding_doc, @@ -246,7 +246,7 @@ sys_getfilesystemencoding(PyObject *self) { if (Py_FileSystemDefaultEncoding) - return PyString_FromString(Py_FileSystemDefaultEncoding); + return PyUnicode_FromString(Py_FileSystemDefaultEncoding); Py_INCREF(Py_None); return Py_None; } From python-3000-checkins at python.org Tue Jun 5 22:22:07 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Tue, 5 Jun 2007 22:22:07 +0200 (CEST) Subject: [Python-3000-checkins] r55781 - in python/branches/py3k-struni: Lib/test/test_sys.py Python/sysmodule.c Message-ID: <20070605202207.AB2791E4005@bag.python.org> Author: walter.doerwald Date: Tue Jun 5 22:22:04 2007 New Revision: 55781 Modified: python/branches/py3k-struni/Lib/test/test_sys.py python/branches/py3k-struni/Python/sysmodule.c Log: Change sys.intern() so that unicode strings can be interned too. Add a test for this. Modified: python/branches/py3k-struni/Lib/test/test_sys.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_sys.py (original) +++ python/branches/py3k-struni/Lib/test/test_sys.py Tue Jun 5 22:22:04 2007 @@ -356,7 +356,7 @@ # We don't want them in the interned dict and if they aren't # actually interned, we don't want to create the appearance # that they are by allowing intern() to succeeed. - class S(str): + class S(str8): def __hash__(self): return 123 @@ -368,6 +368,17 @@ setattr(s, s, s) self.assertEqual(getattr(s, s), s) + s = "never interned as unicode before" + self.assert_(sys.intern(s) is s) + s2 = s.swapcase().swapcase() + self.assert_(sys.intern(s2) is s) + + class U(str): + def __hash__(self): + return 123 + + self.assertRaises(TypeError, sys.intern, U("abc")) + def test_main(): test.test_support.run_unittest(SysModuleTest) Modified: python/branches/py3k-struni/Python/sysmodule.c ============================================================================== --- python/branches/py3k-struni/Python/sysmodule.c (original) +++ python/branches/py3k-struni/Python/sysmodule.c Tue Jun 5 22:22:04 2007 @@ -266,14 +266,21 @@ PyObject *s; if (!PyArg_ParseTuple(args, "S:intern", &s)) return NULL; - if (!PyString_CheckExact(s)) { - PyErr_SetString(PyExc_TypeError, - "can't intern subclass of string"); + if (PyString_CheckExact(s)) { + Py_INCREF(s); + PyString_InternInPlace(&s); + return s; + } + else if (PyUnicode_CheckExact(s)) { + Py_INCREF(s); + PyUnicode_InternInPlace(&s); + return s; + } + else { + PyErr_Format(PyExc_TypeError, + "can't intern %.400s", s->ob_type->tp_name); return NULL; } - Py_INCREF(s); - PyString_InternInPlace(&s); - return s; } PyDoc_STRVAR(intern_doc, From python-3000-checkins at python.org Wed Jun 6 17:15:35 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Wed, 6 Jun 2007 17:15:35 +0200 (CEST) Subject: [Python-3000-checkins] r55787 - python/branches/py3k-struni/Objects/codeobject.c Message-ID: <20070606151535.032A21E4005@bag.python.org> Author: walter.doerwald Date: Wed Jun 6 17:15:34 2007 New Revision: 55787 Modified: python/branches/py3k-struni/Objects/codeobject.c Log: Use PyUnicode_FromFormat() directly. Modified: python/branches/py3k-struni/Objects/codeobject.c ============================================================================== --- python/branches/py3k-struni/Objects/codeobject.c (original) +++ python/branches/py3k-struni/Objects/codeobject.c Wed Jun 6 17:15:34 2007 @@ -286,7 +286,6 @@ static PyObject * code_repr(PyCodeObject *co) { - char buf[500]; int lineno = -1; char *filename = "???"; char *name = "???"; @@ -297,10 +296,9 @@ filename = PyString_AS_STRING(co->co_filename); if (co->co_name && PyString_Check(co->co_name)) name = PyString_AS_STRING(co->co_name); - PyOS_snprintf(buf, sizeof(buf), - "", - name, co, filename, lineno); - return PyUnicode_FromString(buf); + return PyUnicode_FromFormat( + "", + name, co, filename, lineno); } static PyObject * From python-3000-checkins at python.org Wed Jun 6 17:17:24 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Wed, 6 Jun 2007 17:17:24 +0200 (CEST) Subject: [Python-3000-checkins] r55788 - python/branches/py3k-struni/Lib/test/test_codeccallbacks.py Message-ID: <20070606151724.B08771E4010@bag.python.org> Author: walter.doerwald Date: Wed Jun 6 17:17:22 2007 New Revision: 55788 Modified: python/branches/py3k-struni/Lib/test/test_codeccallbacks.py Log: Fix test_codeccallbacks.py: bytes has no % operator. Modified: python/branches/py3k-struni/Lib/test/test_codeccallbacks.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_codeccallbacks.py (original) +++ python/branches/py3k-struni/Lib/test/test_codeccallbacks.py Wed Jun 6 17:17:22 2007 @@ -140,17 +140,17 @@ sin += chr(sys.maxunicode) sout = b"a\\xac\\u1234\\u20ac\\u8000" if sys.maxunicode > 0xffff: - sout += b"\\U%08x" % sys.maxunicode + sout += bytes("\\U%08x" % sys.maxunicode) self.assertEqual(sin.encode("ascii", "backslashreplace"), sout) sout = b"a\xac\\u1234\\u20ac\\u8000" if sys.maxunicode > 0xffff: - sout += b"\\U%08x" % sys.maxunicode + sout += bytes("\\U%08x" % sys.maxunicode) self.assertEqual(sin.encode("latin-1", "backslashreplace"), sout) sout = b"a\xac\\u1234\xa4\\u8000" if sys.maxunicode > 0xffff: - sout += b"\\U%08x" % sys.maxunicode + sout += bytes("\\U%08x" % sys.maxunicode) self.assertEqual(sin.encode("iso-8859-15", "backslashreplace"), sout) def test_decoderelaxedutf8(self): From python-3000-checkins at python.org Wed Jun 6 18:31:18 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Wed, 6 Jun 2007 18:31:18 +0200 (CEST) Subject: [Python-3000-checkins] r55789 - in python/branches/py3k-struni: Lib/test/test_fileio.py Modules/_fileio.c Message-ID: <20070606163118.B0C9C1E4005@bag.python.org> Author: walter.doerwald Date: Wed Jun 6 18:31:14 2007 New Revision: 55789 Modified: python/branches/py3k-struni/Lib/test/test_fileio.py python/branches/py3k-struni/Modules/_fileio.c Log: If append mode is specified seek to the end of the file. Add a test to test_fileio.py for this. Modified: python/branches/py3k-struni/Lib/test/test_fileio.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_fileio.py (original) +++ python/branches/py3k-struni/Lib/test/test_fileio.py Wed Jun 6 18:31:14 2007 @@ -205,6 +205,24 @@ finally: os.unlink(TESTFN) + def testAppend(self): + try: + f = open(TESTFN, 'wb') + f.write(b'spam') + f.close() + f = open(TESTFN, 'ab') + f.write(b'eggs') + f.close() + f = open(TESTFN, 'rb') + d = f.read() + f.close() + self.assertEqual(d, b'spameggs') + finally: + try: + os.unlink(TESTFN) + except: + pass + def test_main(): # Historically, these tests have been sloppy about removing TESTFN. # So get rid of it no matter what. Modified: python/branches/py3k-struni/Modules/_fileio.c ============================================================================== --- python/branches/py3k-struni/Modules/_fileio.c (original) +++ python/branches/py3k-struni/Modules/_fileio.c Wed Jun 6 18:31:14 2007 @@ -242,6 +242,18 @@ PyErr_SetFromErrnoWithFilename(PyExc_IOError, name); goto error; } + if (append) { + int result; + Py_BEGIN_ALLOW_THREADS + errno = 0; + result = lseek(self->fd, 0, SEEK_END); + Py_END_ALLOW_THREADS + if (result < 0) { + close(self->fd); + PyErr_SetFromErrnoWithFilename(PyExc_IOError, name); + goto error; + } + } } goto done; From python-3000-checkins at python.org Wed Jun 6 18:44:03 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Wed, 6 Jun 2007 18:44:03 +0200 (CEST) Subject: [Python-3000-checkins] r55790 - in python/branches/py3k-struni/Lib: gzip.py test/test_gzip.py Message-ID: <20070606164403.459011E400E@bag.python.org> Author: walter.doerwald Date: Wed Jun 6 18:43:59 2007 New Revision: 55790 Modified: python/branches/py3k-struni/Lib/gzip.py python/branches/py3k-struni/Lib/test/test_gzip.py Log: Fix gzip.py: Use bytes where 8bit strings have been used formerly. (The filename gets written in utf-8 encoded form which probably isn't correct.) Fix the test. Modified: python/branches/py3k-struni/Lib/gzip.py ============================================================================== --- python/branches/py3k-struni/Lib/gzip.py (original) +++ python/branches/py3k-struni/Lib/gzip.py Wed Jun 6 18:43:59 2007 @@ -104,7 +104,7 @@ self.mode = READ # Set flag indicating start of a new member self._new_member = True - self.extrabuf = "" + self.extrabuf = b"" self.extrasize = 0 self.name = filename # Starts small, scales exponentially @@ -147,20 +147,21 @@ self.bufsize = 0 def _write_gzip_header(self): - self.fileobj.write('\037\213') # magic header - self.fileobj.write('\010') # compression method + self.fileobj.write(b'\037\213') # magic header + self.fileobj.write(b'\010') # compression method fname = self.name if fname.endswith(".gz"): fname = fname[:-3] flags = 0 if fname: flags = FNAME - self.fileobj.write(chr(flags)) + self.fileobj.write(chr(flags).encode('latin-1')) write32u(self.fileobj, int(time.time())) - self.fileobj.write('\002') - self.fileobj.write('\377') + self.fileobj.write(b'\002') + self.fileobj.write(b'\377') if fname: - self.fileobj.write(fname + '\000') + # XXX: Ist utf-8 the correct encoding? + self.fileobj.write(fname.encode('utf-8') + b'\000') def _init_read(self): self.crc = zlib.crc32("") @@ -168,7 +169,7 @@ def _read_gzip_header(self): magic = self.fileobj.read(2) - if magic != '\037\213': + if magic != b'\037\213': raise IOError, 'Not a gzipped file' method = ord( self.fileobj.read(1) ) if method != 8: @@ -188,13 +189,13 @@ # Read and discard a null-terminated string containing the filename while True: s = self.fileobj.read(1) - if not s or s=='\000': + if not s or s==b'\000': break if flag & FCOMMENT: # Read and discard a null-terminated string containing a comment while True: s = self.fileobj.read(1) - if not s or s=='\000': + if not s or s==b'\000': break if flag & FHCRC: self.fileobj.read(2) # Read & discard the 16-bit header CRC @@ -219,7 +220,7 @@ raise IOError(errno.EBADF, "read() on write-only GzipFile object") if self.extrasize <= 0 and self.fileobj is None: - return '' + return b'' readsize = 1024 if size < 0: # get the whole thing @@ -278,7 +279,7 @@ # If the EOF has been reached, flush the decompression object # and mark this object as finished. - if buf == "": + if buf == b"": uncompress = self.decompress.flush() self._read_eof() self._add_read_data( uncompress ) @@ -287,7 +288,7 @@ uncompress = self.decompress.decompress(buf) self._add_read_data( uncompress ) - if self.decompress.unused_data != "": + if self.decompress.unused_data != b"": # Ending case: we've come to the end of a member in the file, # so seek back to the start of the unused data, finish up # this member, and read a new gzip header. @@ -375,7 +376,7 @@ raise IOError("Can't rewind in write mode") self.fileobj.seek(0) self._new_member = True - self.extrabuf = "" + self.extrabuf = b"" self.extrasize = 0 self.offset = 0 @@ -389,9 +390,10 @@ if offset < self.offset: raise IOError('Negative seek in write mode') count = offset - self.offset + chunk = bytes(1024) for i in range(count // 1024): - self.write(1024 * '\0') - self.write((count % 1024) * '\0') + self.write(chunk) + self.write(bytes(count % 1024)) elif self.mode == READ: if offset < self.offset: # for negative seek, rewind and do positive seek @@ -410,7 +412,7 @@ bufs = [] while size != 0: c = self.read(readsize) - i = c.find('\n') + i = c.find(b'\n') # We set i=size to break out of the loop under two # conditions: 1) there's no newline, and the chunk is @@ -419,7 +421,7 @@ if (size <= i) or (i == -1 and len(c) > size): i = size - 1 - if i >= 0 or c == '': + if i >= 0 or c == b'': bufs.append(c[:i + 1]) # Add portion of last chunk self._unread(c[i + 1:]) # Push back rest of chunk break @@ -430,7 +432,7 @@ readsize = min(size, readsize * 2) if readsize > self.min_readsize: self.min_readsize = min(readsize, self.min_readsize * 2, 512) - return ''.join(bufs) # Return resulting line + return b''.join(bufs) # Return resulting line def readlines(self, sizehint=0): # Negative numbers result in reading all the lines @@ -439,7 +441,7 @@ L = [] while sizehint > 0: line = self.readline() - if line == "": + if line == b"": break L.append(line) sizehint = sizehint - len(line) Modified: python/branches/py3k-struni/Lib/test/test_gzip.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_gzip.py (original) +++ python/branches/py3k-struni/Lib/test/test_gzip.py Wed Jun 6 18:43:59 2007 @@ -8,14 +8,14 @@ import gzip -data1 = """ int length=DEFAULTALLOC, err = Z_OK; +data1 = b""" int length=DEFAULTALLOC, err = Z_OK; PyObject *RetVal; int flushmode = Z_FINISH; unsigned long start_total_out; """ -data2 = """/* zlibmodule.c -- gzip-compatible data compression */ +data2 = b"""/* zlibmodule.c -- gzip-compatible data compression */ /* See http://www.gzip.org/zlib/ /* See http://www.winimage.com/zLibDll for Windows */ """ @@ -63,22 +63,22 @@ # many, many members. Create such a file and verify that reading it # works. f = gzip.open(self.filename, 'wb', 9) - f.write('a') + f.write(b'a') f.close() - for i in range(0,200): + for i in range(0, 200): f = gzip.open(self.filename, "ab", 9) # append - f.write('a') + f.write(b'a') f.close() # Try reading the file zgfile = gzip.open(self.filename, "rb") - contents = "" + contents = b"" while 1: ztxt = zgfile.read(8192) contents += ztxt if not ztxt: break zgfile.close() - self.assertEquals(contents, 'a'*201) + self.assertEquals(contents, b'a'*201) def test_readline(self): @@ -89,7 +89,7 @@ line_length = 0 while 1: L = f.readline(line_length) - if L == "" and line_length != 0: break + if not L and line_length != 0: break self.assert_(len(L) <= line_length) line_length = (line_length + 1) % 50 f.close() @@ -144,7 +144,7 @@ f = gzip.GzipFile(self.filename, 'w') for pos in range(0, 256, 16): f.seek(pos) - f.write('GZ\n') + f.write(b'GZ\n') f.close() def test_mode(self): From python-3000-checkins at python.org Wed Jun 6 18:55:40 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Wed, 6 Jun 2007 18:55:40 +0200 (CEST) Subject: [Python-3000-checkins] r55791 - python/branches/py3k-struni/Modules/_fileio.c Message-ID: <20070606165540.EB1B41E4005@bag.python.org> Author: walter.doerwald Date: Wed Jun 6 18:55:38 2007 New Revision: 55791 Modified: python/branches/py3k-struni/Modules/_fileio.c Log: Use O_APPEND flag instead of seeking, when append mode is specified. Modified: python/branches/py3k-struni/Modules/_fileio.c ============================================================================== --- python/branches/py3k-struni/Modules/_fileio.c (original) +++ python/branches/py3k-struni/Modules/_fileio.c Wed Jun 6 18:55:38 2007 @@ -230,6 +230,11 @@ flags |= O_BINARY; #endif +#ifdef O_APPEND + if (append) + flags |= O_APPEND; +#endif + if (fd >= 0) { self->fd = fd; } @@ -242,18 +247,6 @@ PyErr_SetFromErrnoWithFilename(PyExc_IOError, name); goto error; } - if (append) { - int result; - Py_BEGIN_ALLOW_THREADS - errno = 0; - result = lseek(self->fd, 0, SEEK_END); - Py_END_ALLOW_THREADS - if (result < 0) { - close(self->fd); - PyErr_SetFromErrnoWithFilename(PyExc_IOError, name); - goto error; - } - } } goto done; From python-3000-checkins at python.org Thu Jun 7 00:29:26 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 7 Jun 2007 00:29:26 +0200 (CEST) Subject: [Python-3000-checkins] r55794 - python/branches/p3yk/Objects/abstract.c Message-ID: <20070606222926.1F1ED1E4005@bag.python.org> Author: guido.van.rossum Date: Thu Jun 7 00:29:22 2007 New Revision: 55794 Modified: python/branches/p3yk/Objects/abstract.c Log: Make this compile in GCC 2.96, which does not allow interspersing declarations and code. Modified: python/branches/p3yk/Objects/abstract.c ============================================================================== --- python/branches/p3yk/Objects/abstract.c (original) +++ python/branches/p3yk/Objects/abstract.c Thu Jun 7 00:29:22 2007 @@ -2133,8 +2133,9 @@ PyObject_IsInstance(PyObject *inst, PyObject *cls) { PyObject *t, *v, *tb; + PyObject *checker; PyErr_Fetch(&t, &v, &tb); - PyObject *checker = PyObject_GetAttrString(cls, "__instancecheck__"); + checker = PyObject_GetAttrString(cls, "__instancecheck__"); PyErr_Restore(t, v, tb); if (checker != NULL) { PyObject *res; @@ -2203,8 +2204,9 @@ PyObject_IsSubclass(PyObject *derived, PyObject *cls) { PyObject *t, *v, *tb; + PyObject *checker; PyErr_Fetch(&t, &v, &tb); - PyObject *checker = PyObject_GetAttrString(cls, "__subclasscheck__"); + checker = PyObject_GetAttrString(cls, "__subclasscheck__"); PyErr_Restore(t, v, tb); if (checker != NULL) { PyObject *res; From python-3000-checkins at python.org Thu Jun 7 01:53:47 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 7 Jun 2007 01:53:47 +0200 (CEST) Subject: [Python-3000-checkins] r55795 - in python/branches/py3k-struni: Demo/imputil/knee.py Demo/pdist/cvslock.py Doc/Makefile Doc/Makefile.deps Doc/api/utilities.tex Doc/ext/extending.tex Doc/howto/functional.rst Doc/lib/lib.tex Doc/lib/libcodecs.tex Doc/lib/libfuncs.tex Doc/lib/libimp.tex Doc/lib/libitertools.tex Doc/lib/liblogging.tex Doc/lib/libmimewriter.tex Doc/lib/libmimify.tex Doc/lib/libpickle.tex Doc/lib/libposixfile.tex Doc/lib/libshlex.tex Doc/lib/libsubprocess.tex Doc/lib/libsys.tex Doc/lib/libtarfile.tex Doc/lib/libtypes.tex Doc/lib/libundoc.tex Doc/lib/libzipimport.tex Doc/mac/undoc.tex Doc/ref/ref3.tex Doc/tut/tut.tex Doc/whatsnew/whatsnew30.tex Grammar/Grammar Lib/MimeWriter.py Lib/SocketServer.py Lib/bsddb/test/test_thread.py Lib/ctypes/wintypes.py Lib/dis.py Lib/idlelib/StackViewer.py Lib/ihooks.py Lib/imputil.py Lib/logging/__init__.py Lib/logging/handlers.py Lib/mimify.py Lib/optparse.py Lib/os.py Lib/plat-mac/buildtools.py Lib/plat-mac/cfmfile.py Lib/posixfile.py Lib/pydoc.py Lib/sha.py Lib/shlex.py Lib/subprocess.py Lib/tarfile.py Lib/test/dis_module.py Lib/test/infinite_reload.py Lib/test/output/test_pkg Lib/test/regrtest.py Lib/test/test_MimeWriter.py Lib/test/test___all__.py Lib/test/test_builtin.py Lib/test/test_dis.py Lib/test/test_doctest.py Lib/test/test_hmac.py Lib/test/test_import.py Lib/test/test_importhooks.py Lib/test/test_inspect.py Lib/test/test_optparse.py Lib/test/test_os.py Lib/test/test_pkg.py Lib/test/test_subprocess.py Lib/test/test_sundry.py Lib/test/test_syntax.py Lib/test/test_sys.py Lib/test/test_tarfile.py Lib/test/test_tokenize.py Lib/test/test_traceback.py Lib/test/test_urllib.py Lib/test/test_xmlrpc.py Lib/test/testtar.tar Lib/textwrap.py Lib/unittest.py Lib/urllib.py Lib/uuid.py Lib/wsgiref/handlers.py Lib/xmlrpclib.py Misc/BeOS-setup.py Misc/NEWS Misc/build.sh Misc/cheatsheet Modules/Setup.dist Modules/_ctypes/callbacks.c Modules/md5.c Modules/md5.h Modules/md5module.c Modules/shamodule.c Modules/timing.h Modules/timingmodule.c Objects/abstract.c PC/WinMain.c PC/_winreg.c PC/dl_nt.c PC/os2emx/Makefile PC/os2emx/config.c PC/os2emx/python25.def PC/os2vacpp/makefile PC/os2vacpp/makefile.omk PC/pyconfig.h PC/winsound.c PCbuild/pythoncore.vcproj PCbuild8/pythoncore/pythoncore.vcproj Python/ast.c Python/bltinmodule.c Python/ceval.c Python/dynload_win.c Python/graminit.c Python/import.c Python/sysmodule.c README setup.py Message-ID: <20070606235347.43FF81E4005@bag.python.org> Author: guido.van.rossum Date: Thu Jun 7 01:52:48 2007 New Revision: 55795 Added: python/branches/py3k-struni/Doc/whatsnew/whatsnew30.tex - copied unchanged from r55794, python/branches/p3yk/Doc/whatsnew/whatsnew30.tex python/branches/py3k-struni/Lib/test/dis_module.py - copied unchanged from r55794, python/branches/p3yk/Lib/test/dis_module.py Removed: python/branches/py3k-struni/Doc/lib/libmimewriter.tex python/branches/py3k-struni/Doc/lib/libmimify.tex python/branches/py3k-struni/Doc/lib/libposixfile.tex python/branches/py3k-struni/Lib/MimeWriter.py python/branches/py3k-struni/Lib/mimify.py python/branches/py3k-struni/Lib/plat-mac/cfmfile.py python/branches/py3k-struni/Lib/posixfile.py python/branches/py3k-struni/Lib/sha.py python/branches/py3k-struni/Lib/test/infinite_reload.py python/branches/py3k-struni/Lib/test/test_MimeWriter.py python/branches/py3k-struni/Modules/md5.c python/branches/py3k-struni/Modules/md5.h python/branches/py3k-struni/Modules/md5module.c python/branches/py3k-struni/Modules/shamodule.c python/branches/py3k-struni/Modules/timing.h python/branches/py3k-struni/Modules/timingmodule.c Modified: python/branches/py3k-struni/ (props changed) python/branches/py3k-struni/Demo/imputil/knee.py python/branches/py3k-struni/Demo/pdist/cvslock.py python/branches/py3k-struni/Doc/Makefile python/branches/py3k-struni/Doc/Makefile.deps python/branches/py3k-struni/Doc/api/utilities.tex python/branches/py3k-struni/Doc/ext/extending.tex python/branches/py3k-struni/Doc/howto/functional.rst python/branches/py3k-struni/Doc/lib/lib.tex python/branches/py3k-struni/Doc/lib/libcodecs.tex python/branches/py3k-struni/Doc/lib/libfuncs.tex python/branches/py3k-struni/Doc/lib/libimp.tex python/branches/py3k-struni/Doc/lib/libitertools.tex python/branches/py3k-struni/Doc/lib/liblogging.tex python/branches/py3k-struni/Doc/lib/libpickle.tex python/branches/py3k-struni/Doc/lib/libshlex.tex python/branches/py3k-struni/Doc/lib/libsubprocess.tex python/branches/py3k-struni/Doc/lib/libsys.tex python/branches/py3k-struni/Doc/lib/libtarfile.tex python/branches/py3k-struni/Doc/lib/libtypes.tex python/branches/py3k-struni/Doc/lib/libundoc.tex python/branches/py3k-struni/Doc/lib/libzipimport.tex python/branches/py3k-struni/Doc/mac/undoc.tex python/branches/py3k-struni/Doc/ref/ref3.tex python/branches/py3k-struni/Doc/tut/tut.tex python/branches/py3k-struni/Grammar/Grammar python/branches/py3k-struni/Lib/SocketServer.py python/branches/py3k-struni/Lib/bsddb/test/test_thread.py python/branches/py3k-struni/Lib/ctypes/wintypes.py python/branches/py3k-struni/Lib/dis.py python/branches/py3k-struni/Lib/idlelib/StackViewer.py python/branches/py3k-struni/Lib/ihooks.py python/branches/py3k-struni/Lib/imputil.py python/branches/py3k-struni/Lib/logging/__init__.py python/branches/py3k-struni/Lib/logging/handlers.py python/branches/py3k-struni/Lib/optparse.py python/branches/py3k-struni/Lib/os.py python/branches/py3k-struni/Lib/plat-mac/buildtools.py python/branches/py3k-struni/Lib/pydoc.py python/branches/py3k-struni/Lib/shlex.py python/branches/py3k-struni/Lib/subprocess.py python/branches/py3k-struni/Lib/tarfile.py python/branches/py3k-struni/Lib/test/output/test_pkg python/branches/py3k-struni/Lib/test/regrtest.py python/branches/py3k-struni/Lib/test/test___all__.py python/branches/py3k-struni/Lib/test/test_builtin.py python/branches/py3k-struni/Lib/test/test_dis.py python/branches/py3k-struni/Lib/test/test_doctest.py python/branches/py3k-struni/Lib/test/test_hmac.py python/branches/py3k-struni/Lib/test/test_import.py python/branches/py3k-struni/Lib/test/test_importhooks.py python/branches/py3k-struni/Lib/test/test_inspect.py python/branches/py3k-struni/Lib/test/test_optparse.py python/branches/py3k-struni/Lib/test/test_os.py python/branches/py3k-struni/Lib/test/test_pkg.py python/branches/py3k-struni/Lib/test/test_subprocess.py python/branches/py3k-struni/Lib/test/test_sundry.py python/branches/py3k-struni/Lib/test/test_syntax.py python/branches/py3k-struni/Lib/test/test_sys.py python/branches/py3k-struni/Lib/test/test_tarfile.py python/branches/py3k-struni/Lib/test/test_tokenize.py python/branches/py3k-struni/Lib/test/test_traceback.py python/branches/py3k-struni/Lib/test/test_urllib.py python/branches/py3k-struni/Lib/test/test_xmlrpc.py python/branches/py3k-struni/Lib/test/testtar.tar python/branches/py3k-struni/Lib/textwrap.py python/branches/py3k-struni/Lib/unittest.py python/branches/py3k-struni/Lib/urllib.py python/branches/py3k-struni/Lib/uuid.py python/branches/py3k-struni/Lib/wsgiref/handlers.py python/branches/py3k-struni/Lib/xmlrpclib.py python/branches/py3k-struni/Misc/BeOS-setup.py python/branches/py3k-struni/Misc/NEWS python/branches/py3k-struni/Misc/build.sh python/branches/py3k-struni/Misc/cheatsheet python/branches/py3k-struni/Modules/Setup.dist python/branches/py3k-struni/Modules/_ctypes/callbacks.c python/branches/py3k-struni/Objects/abstract.c python/branches/py3k-struni/PC/WinMain.c python/branches/py3k-struni/PC/_winreg.c python/branches/py3k-struni/PC/dl_nt.c python/branches/py3k-struni/PC/os2emx/Makefile python/branches/py3k-struni/PC/os2emx/config.c python/branches/py3k-struni/PC/os2emx/python25.def python/branches/py3k-struni/PC/os2vacpp/makefile python/branches/py3k-struni/PC/os2vacpp/makefile.omk python/branches/py3k-struni/PC/pyconfig.h python/branches/py3k-struni/PC/winsound.c python/branches/py3k-struni/PCbuild/pythoncore.vcproj python/branches/py3k-struni/PCbuild8/pythoncore/pythoncore.vcproj python/branches/py3k-struni/Python/ast.c python/branches/py3k-struni/Python/bltinmodule.c python/branches/py3k-struni/Python/ceval.c python/branches/py3k-struni/Python/dynload_win.c python/branches/py3k-struni/Python/graminit.c python/branches/py3k-struni/Python/import.c python/branches/py3k-struni/Python/sysmodule.c python/branches/py3k-struni/README python/branches/py3k-struni/setup.py Log: Merged revisions 55631-55794 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/p3yk ................ r55636 | neal.norwitz | 2007-05-29 00:06:39 -0700 (Tue, 29 May 2007) | 149 lines Merged revisions 55506-55635 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r55507 | georg.brandl | 2007-05-22 07:28:17 -0700 (Tue, 22 May 2007) | 2 lines Remove the "panel" module doc file which has been ignored since 1994. ........ r55522 | mark.hammond | 2007-05-22 19:04:28 -0700 (Tue, 22 May 2007) | 4 lines Remove definition of PY_UNICODE_TYPE from pyconfig.h, allowing the definition in unicodeobject.h to be used, giving us the desired wchar_t in place of 'unsigned short'. As discussed on python-dev. ........ r55525 | neal.norwitz | 2007-05-22 23:35:32 -0700 (Tue, 22 May 2007) | 6 lines Add -3 option to the interpreter to warn about features that are deprecated and will be changed/removed in Python 3.0. This patch is mostly from Anthony. I tweaked some format and added a little doc. ........ r55527 | neal.norwitz | 2007-05-22 23:57:35 -0700 (Tue, 22 May 2007) | 1 line Whitespace cleanup ........ r55528 | neal.norwitz | 2007-05-22 23:58:36 -0700 (Tue, 22 May 2007) | 1 line Add a bunch more deprecation warnings for builtins that are going away in 3.0 ........ r55549 | georg.brandl | 2007-05-24 09:49:29 -0700 (Thu, 24 May 2007) | 2 lines shlex.split() now has an optional "posix" parameter. ........ r55550 | georg.brandl | 2007-05-24 10:33:33 -0700 (Thu, 24 May 2007) | 2 lines Fix parameter passing. ........ r55555 | facundo.batista | 2007-05-24 10:50:54 -0700 (Thu, 24 May 2007) | 6 lines Added an optional timeout parameter to urllib.ftpwrapper, with tests (for this and a basic one, because there weren't any). Changed also NEWS, but didn't find documentation for this function, assumed it wasn't public... ........ r55563 | facundo.batista | 2007-05-24 13:01:59 -0700 (Thu, 24 May 2007) | 4 lines Removed the .recv() in the test, is not necessary, and was causing problems that didn't have anything to do with was actually being tested... ........ r55564 | facundo.batista | 2007-05-24 13:51:19 -0700 (Thu, 24 May 2007) | 5 lines Let's see if reading exactly what is written allow this live test to pass (now I know why there were so few tests in ftp, http, etc, :( ). ........ r55567 | facundo.batista | 2007-05-24 20:10:28 -0700 (Thu, 24 May 2007) | 4 lines Trying to make the tests work in Windows and Solaris, everywhere else just works ........ r55568 | facundo.batista | 2007-05-24 20:47:19 -0700 (Thu, 24 May 2007) | 4 lines Fixing stupid error, and introducing a sleep, to see if the other thread is awakened and finish sending data. ........ r55569 | facundo.batista | 2007-05-24 21:20:22 -0700 (Thu, 24 May 2007) | 4 lines Commenting out the tests until find out who can test them in one of the problematic enviroments. ........ r55570 | neal.norwitz | 2007-05-24 22:13:40 -0700 (Thu, 24 May 2007) | 2 lines Get test passing again by commenting out the reference to the test class. ........ r55575 | vinay.sajip | 2007-05-25 00:05:59 -0700 (Fri, 25 May 2007) | 1 line Updated docstring for SysLogHandler (#1720726). ........ r55576 | vinay.sajip | 2007-05-25 00:06:55 -0700 (Fri, 25 May 2007) | 1 line Updated documentation for SysLogHandler (#1720726). ........ r55592 | brett.cannon | 2007-05-25 13:17:15 -0700 (Fri, 25 May 2007) | 3 lines Remove direct call's to file's constructor and replace them with calls to open() as ths is considered best practice. ........ r55601 | kristjan.jonsson | 2007-05-26 12:19:50 -0700 (Sat, 26 May 2007) | 1 line Remove the rgbimgmodule from PCBuild8 ........ r55602 | kristjan.jonsson | 2007-05-26 12:31:39 -0700 (Sat, 26 May 2007) | 1 line Include after python.h, so that WINNT is properly set before windows.h is included. Fixes warnings in PC builds. ........ r55603 | walter.doerwald | 2007-05-26 14:04:13 -0700 (Sat, 26 May 2007) | 2 lines Fix typo. ........ r55604 | peter.astrand | 2007-05-26 15:18:20 -0700 (Sat, 26 May 2007) | 1 line Applied patch 1669481, slightly modified: Support close_fds on Win32 ........ r55606 | neal.norwitz | 2007-05-26 21:08:54 -0700 (Sat, 26 May 2007) | 2 lines Add the new function object attribute names from py3k. ........ r55617 | lars.gustaebel | 2007-05-27 12:49:30 -0700 (Sun, 27 May 2007) | 20 lines Added errors argument to TarFile class that allows the user to specify an error handling scheme for character conversion. Additional scheme "utf-8" in read mode. Unicode input filenames are now supported by design. The values of the pax_headers dictionary are now limited to unicode objects. Fixed: The prefix field is no longer used in PAX_FORMAT (in conformance with POSIX). Fixed: In read mode use a possible pax header size field. Fixed: Strip trailing slashes from pax header name values. Fixed: Give values in user-specified pax_headers precedence when writing. Added unicode tests. Added pax/regtype4 member to testtar.tar all possible number fields in a pax header. Added two chapters to the documentation about the different formats tarfile.py supports and how unicode issues are handled. ........ r55618 | raymond.hettinger | 2007-05-27 22:23:22 -0700 (Sun, 27 May 2007) | 1 line Explain when groupby() issues a new group. ........ r55634 | martin.v.loewis | 2007-05-28 21:01:29 -0700 (Mon, 28 May 2007) | 2 lines Test pre-commit hook for a link to a .py file. ........ r55635 | martin.v.loewis | 2007-05-28 21:02:03 -0700 (Mon, 28 May 2007) | 2 lines Revert 55634. ........ ................ r55639 | neal.norwitz | 2007-05-29 00:58:11 -0700 (Tue, 29 May 2007) | 1 line Remove sys.exc_{type,exc_value,exc_traceback} ................ r55641 | neal.norwitz | 2007-05-29 01:03:50 -0700 (Tue, 29 May 2007) | 1 line Missed one sys.exc_type. I wonder why exc_{value,traceback} were already gone ................ r55642 | neal.norwitz | 2007-05-29 01:08:33 -0700 (Tue, 29 May 2007) | 1 line Missed more doc for sys.exc_* attrs. ................ r55643 | neal.norwitz | 2007-05-29 01:18:19 -0700 (Tue, 29 May 2007) | 1 line Remove sys.exc_clear() ................ r55665 | guido.van.rossum | 2007-05-29 19:45:43 -0700 (Tue, 29 May 2007) | 4 lines Make None, True, False keywords. We can now also delete all the other places that explicitly forbid assignment to None, but I'm not going to bother right now. ................ r55666 | guido.van.rossum | 2007-05-29 20:01:51 -0700 (Tue, 29 May 2007) | 3 lines Found another place that needs check for forbidden names. Fixed test_syntax.py accordingly (it helped me find that one). ................ r55668 | guido.van.rossum | 2007-05-29 20:41:48 -0700 (Tue, 29 May 2007) | 2 lines Mark None, True, False as keywords. ................ r55673 | neal.norwitz | 2007-05-29 23:28:25 -0700 (Tue, 29 May 2007) | 3 lines Get the dis module working on modules again after changing dicts to not return lists and also new-style classes. Add a test. ................ r55674 | neal.norwitz | 2007-05-29 23:35:45 -0700 (Tue, 29 May 2007) | 1 line Umm, it helps to add the module that the test uses ................ r55675 | neal.norwitz | 2007-05-29 23:53:05 -0700 (Tue, 29 May 2007) | 4 lines Try to fix up all the other places that were assigning to True/False. There's at least one more problem in test.test_xmlrpc. I have other changes in that file and that should be fixed soon (I hope). ................ r55679 | neal.norwitz | 2007-05-30 00:31:55 -0700 (Wed, 30 May 2007) | 1 line Fix up another place that was assigning to True/False. ................ r55688 | brett.cannon | 2007-05-30 14:19:47 -0700 (Wed, 30 May 2007) | 2 lines Ditch MimeWriter. ................ r55692 | brett.cannon | 2007-05-30 14:52:00 -0700 (Wed, 30 May 2007) | 2 lines Remove the mimify module. ................ r55707 | guido.van.rossum | 2007-05-31 05:08:45 -0700 (Thu, 31 May 2007) | 2 lines Backport the addition of show_code() to dis.py -- it's too handy. ................ r55708 | guido.van.rossum | 2007-05-31 06:22:57 -0700 (Thu, 31 May 2007) | 7 lines Fix a fairly long-standing bug in the check for assignment to None (and other keywords, these days). In 2.5, you could write foo(None=1) without getting a SyntaxError (although foo()'s definition would have to use **kwds to avoid getting a runtime error complaining about an unknown keyword of course). This ought to be backported to 2.5.2 or at least 2.6. ................ r55724 | brett.cannon | 2007-05-31 19:32:41 -0700 (Thu, 31 May 2007) | 2 lines Remove the cfmfile. ................ r55727 | neal.norwitz | 2007-05-31 22:19:44 -0700 (Thu, 31 May 2007) | 1 line Remove reload() builtin. ................ r55729 | neal.norwitz | 2007-05-31 22:51:30 -0700 (Thu, 31 May 2007) | 59 lines Merged revisions 55636-55728 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r55637 | georg.brandl | 2007-05-29 00:16:47 -0700 (Tue, 29 May 2007) | 2 lines Fix rst markup. ........ r55638 | neal.norwitz | 2007-05-29 00:51:39 -0700 (Tue, 29 May 2007) | 1 line Fix typo in doc ........ r55671 | neal.norwitz | 2007-05-29 21:53:41 -0700 (Tue, 29 May 2007) | 1 line Fix indentation (whitespace only). ........ r55676 | thomas.heller | 2007-05-29 23:58:30 -0700 (Tue, 29 May 2007) | 1 line Fix compiler warnings. ........ r55677 | thomas.heller | 2007-05-30 00:01:25 -0700 (Wed, 30 May 2007) | 2 lines Correct the name of a field in the WIN32_FIND_DATAA and WIN32_FIND_DATAW structures. Closes bug #1726026. ........ r55686 | brett.cannon | 2007-05-30 13:46:26 -0700 (Wed, 30 May 2007) | 2 lines Have MimeWriter raise a DeprecationWarning as per PEP 4 and its documentation. ........ r55690 | brett.cannon | 2007-05-30 14:48:58 -0700 (Wed, 30 May 2007) | 3 lines Have mimify raise a DeprecationWarning. The docs and PEP 4 have listed the module as deprecated for a while. ........ r55696 | brett.cannon | 2007-05-30 15:24:28 -0700 (Wed, 30 May 2007) | 2 lines Have md5 raise a DeprecationWarning as per PEP 4. ........ r55705 | neal.norwitz | 2007-05-30 21:14:22 -0700 (Wed, 30 May 2007) | 1 line Add some spaces in the example code. ........ r55716 | brett.cannon | 2007-05-31 12:20:00 -0700 (Thu, 31 May 2007) | 2 lines Have the sha module raise a DeprecationWarning as specified in PEP 4. ........ r55719 | brett.cannon | 2007-05-31 12:40:42 -0700 (Thu, 31 May 2007) | 2 lines Cause buildtools to raise a DeprecationWarning. ........ r55721 | brett.cannon | 2007-05-31 13:01:11 -0700 (Thu, 31 May 2007) | 2 lines Have cfmfile raise a DeprecationWarning as per PEP 4. ........ r55726 | neal.norwitz | 2007-05-31 21:56:47 -0700 (Thu, 31 May 2007) | 1 line Mail if there is an installation failure. ........ ................ r55730 | neal.norwitz | 2007-05-31 23:22:07 -0700 (Thu, 31 May 2007) | 2 lines Remove the code that was missed in rev 55303. ................ r55738 | neal.norwitz | 2007-06-01 19:10:43 -0700 (Fri, 01 Jun 2007) | 1 line Fix doc breakage ................ r55741 | neal.norwitz | 2007-06-02 00:41:58 -0700 (Sat, 02 Jun 2007) | 1 line Remove timing module (plus some remnants of other modules). ................ r55742 | neal.norwitz | 2007-06-02 00:51:44 -0700 (Sat, 02 Jun 2007) | 1 line Remove posixfile module (plus some remnants of other modules). ................ r55744 | neal.norwitz | 2007-06-02 10:18:56 -0700 (Sat, 02 Jun 2007) | 1 line Fix doc breakage. ................ r55745 | neal.norwitz | 2007-06-02 11:32:16 -0700 (Sat, 02 Jun 2007) | 1 line Make a whatsnew 3.0 template. ................ r55754 | neal.norwitz | 2007-06-03 23:24:18 -0700 (Sun, 03 Jun 2007) | 1 line SF #1730441, os._execvpe raises UnboundLocal due to new try/except semantics ................ r55755 | neal.norwitz | 2007-06-03 23:26:00 -0700 (Sun, 03 Jun 2007) | 1 line Get rid of extra whitespace ................ r55794 | guido.van.rossum | 2007-06-06 15:29:22 -0700 (Wed, 06 Jun 2007) | 3 lines Make this compile in GCC 2.96, which does not allow interspersing declarations and code. ................ Modified: python/branches/py3k-struni/Demo/imputil/knee.py ============================================================================== --- python/branches/py3k-struni/Demo/imputil/knee.py (original) +++ python/branches/py3k-struni/Demo/imputil/knee.py Thu Jun 7 01:52:48 2007 @@ -106,8 +106,7 @@ return m -# Replacement for reload() -def reload_hook(module): +def reload(module): name = module.__name__ if '.' not in name: return import_module(name, name, None) @@ -119,8 +118,6 @@ # Save the original hooks original_import = __builtin__.__import__ -original_reload = __builtin__.reload # Now install our hooks __builtin__.__import__ = import_hook -__builtin__.reload = reload_hook Modified: python/branches/py3k-struni/Demo/pdist/cvslock.py ============================================================================== --- python/branches/py3k-struni/Demo/pdist/cvslock.py (original) +++ python/branches/py3k-struni/Demo/pdist/cvslock.py Thu Jun 7 01:52:48 2007 @@ -262,7 +262,6 @@ rl.unlock() finally: print [1] - sys.exc_traceback = None print [2] if rl: rl.unlock() Modified: python/branches/py3k-struni/Doc/Makefile ============================================================================== --- python/branches/py3k-struni/Doc/Makefile (original) +++ python/branches/py3k-struni/Doc/Makefile Thu Jun 7 01:52:48 2007 @@ -122,7 +122,7 @@ # The end of this should reflect the major/minor version numbers of # the release: -WHATSNEW=whatsnew26 +WHATSNEW=whatsnew30 # what's what MANDVIFILES= paper-$(PAPER)/api.dvi paper-$(PAPER)/ext.dvi \ Modified: python/branches/py3k-struni/Doc/Makefile.deps ============================================================================== --- python/branches/py3k-struni/Doc/Makefile.deps (original) +++ python/branches/py3k-struni/Doc/Makefile.deps Thu Jun 7 01:52:48 2007 @@ -171,7 +171,6 @@ lib/libgdbm.tex \ lib/libtermios.tex \ lib/libfcntl.tex \ - lib/libposixfile.tex \ lib/libsyslog.tex \ lib/liblogging.tex \ lib/libpdb.tex \ @@ -192,7 +191,6 @@ lib/libsgmllib.tex \ lib/librfc822.tex \ lib/libmimetools.tex \ - lib/libmimewriter.tex \ lib/libbinascii.tex \ lib/libmm.tex \ lib/libaudioop.tex \ @@ -235,7 +233,6 @@ lib/libzipfile.tex \ lib/libpprint.tex \ lib/libcode.tex \ - lib/libmimify.tex \ lib/libre.tex \ lib/libuserdict.tex \ lib/libdis.tex \ Modified: python/branches/py3k-struni/Doc/api/utilities.tex ============================================================================== --- python/branches/py3k-struni/Doc/api/utilities.tex (original) +++ python/branches/py3k-struni/Doc/api/utilities.tex Thu Jun 7 01:52:48 2007 @@ -140,10 +140,7 @@ \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PyImport_ReloadModule}{PyObject *m} - Reload a module. This is best described by referring to the - built-in Python function \function{reload()}\bifuncindex{reload}, as - the standard \function{reload()} function calls this function - directly. Return a new reference to the reloaded module, or \NULL{} + Reload a module. Return a new reference to the reloaded module, or \NULL{} with an exception set on failure (the module still exists in this case). \end{cfuncdesc} Modified: python/branches/py3k-struni/Doc/ext/extending.tex ============================================================================== --- python/branches/py3k-struni/Doc/ext/extending.tex (original) +++ python/branches/py3k-struni/Doc/ext/extending.tex Thu Jun 7 01:52:48 2007 @@ -399,12 +399,7 @@ following a \cfunction{fork()} without an intervening \cfunction{exec()}) can create problems for some extension modules. Extension module authors should exercise caution when initializing -internal data structures. -Note also that the \function{reload()} function can be used with -extension modules, and will call the module initialization function -(\cfunction{initspam()} in the example), but will not load the module -again if it was loaded from a dynamically loadable object file -(\file{.so} on \UNIX, \file{.dll} on Windows).} +internal data structures.} A more substantial example module is included in the Python source distribution as \file{Modules/xxmodule.c}. This file may be used as a Modified: python/branches/py3k-struni/Doc/howto/functional.rst ============================================================================== --- python/branches/py3k-struni/Doc/howto/functional.rst (original) +++ python/branches/py3k-struni/Doc/howto/functional.rst Thu Jun 7 01:52:48 2007 @@ -980,7 +980,7 @@ that's a slice of the iterator. With a single ``stop`` argument, it will return the first ``stop`` elements. If you supply a starting index, you'll get ``stop-start`` -elements, and if you supply a value for ``step`, elements will be +elements, and if you supply a value for ``step``, elements will be skipped accordingly. Unlike Python's string and list slicing, you can't use negative values for ``start``, ``stop``, or ``step``. Modified: python/branches/py3k-struni/Doc/lib/lib.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/lib.tex (original) +++ python/branches/py3k-struni/Doc/lib/lib.tex Thu Jun 7 01:52:48 2007 @@ -146,8 +146,6 @@ \input{libmhlib} \input{libmimetools} \input{libmimetypes} -\input{libmimewriter} -\input{libmimify} \input{libmultifile} \input{librfc822} @@ -265,7 +263,6 @@ \input{libpty} \input{libfcntl} \input{libpipes} -\input{libposixfile} \input{libresource} \input{libnis} \input{libsyslog} Modified: python/branches/py3k-struni/Doc/lib/libcodecs.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libcodecs.tex (original) +++ python/branches/py3k-struni/Doc/lib/libcodecs.tex Thu Jun 7 01:52:48 2007 @@ -237,7 +237,7 @@ \begin{funcdesc}{iterdecode}{iterable, encoding\optional{, errors}} Uses an incremental decoder to iteratively decode the input provided by \var{iterable}. This function is a generator. \var{errors} (as well as -any other keyword argument) is passed through to the incremental encoder. +any other keyword argument) is passed through to the incremental decoder. \versionadded{2.5} \end{funcdesc} Modified: python/branches/py3k-struni/Doc/lib/libfuncs.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libfuncs.tex (original) +++ python/branches/py3k-struni/Doc/lib/libfuncs.tex Thu Jun 7 01:52:48 2007 @@ -890,82 +890,6 @@ \end{verbatim} \end{funcdesc} -\begin{funcdesc}{reload}{module} - Reload a previously imported \var{module}. The - argument must be a module object, so it must have been successfully - imported before. This is useful if you have edited the module - source file using an external editor and want to try out the new - version without leaving the Python interpreter. The return value is - the module object (the same as the \var{module} argument). - - When \code{reload(module)} is executed: - -\begin{itemize} - - \item Python modules' code is recompiled and the module-level code - reexecuted, defining a new set of objects which are bound to names in - the module's dictionary. The \code{init} function of extension - modules is not called a second time. - - \item As with all other objects in Python the old objects are only - reclaimed after their reference counts drop to zero. - - \item The names in the module namespace are updated to point to - any new or changed objects. - - \item Other references to the old objects (such as names external - to the module) are not rebound to refer to the new objects and - must be updated in each namespace where they occur if that is - desired. - -\end{itemize} - - There are a number of other caveats: - - If a module is syntactically correct but its initialization fails, - the first \keyword{import} statement for it does not bind its name - locally, but does store a (partially initialized) module object in - \code{sys.modules}. To reload the module you must first - \keyword{import} it again (this will bind the name to the partially - initialized module object) before you can \function{reload()} it. - - When a module is reloaded, its dictionary (containing the module's - global variables) is retained. Redefinitions of names will override - the old definitions, so this is generally not a problem. If the new - version of a module does not define a name that was defined by the - old version, the old definition remains. This feature can be used - to the module's advantage if it maintains a global table or cache of - objects --- with a \keyword{try} statement it can test for the - table's presence and skip its initialization if desired: - -\begin{verbatim} -try: - cache -except NameError: - cache = {} -\end{verbatim} - - - It is legal though generally not very useful to reload built-in or - dynamically loaded modules, except for \refmodule{sys}, - \refmodule[main]{__main__} and \refmodule[builtin]{__builtin__}. In - many cases, however, extension modules are not designed to be - initialized more than once, and may fail in arbitrary ways when - reloaded. - - If a module imports objects from another module using \keyword{from} - \ldots{} \keyword{import} \ldots{}, calling \function{reload()} for - the other module does not redefine the objects imported from it --- - one way around this is to re-execute the \keyword{from} statement, - another is to use \keyword{import} and qualified names - (\var{module}.\var{name}) instead. - - If a module instantiates instances of a class, reloading the module - that defines the class does not affect the method definitions of the - instances --- they continue to use the old class definition. The - same is true for derived classes. -\end{funcdesc} - \begin{funcdesc}{repr}{object} Return a string containing a printable representation of an object. This is the same value yielded by conversions (reverse quotes). Modified: python/branches/py3k-struni/Doc/lib/libimp.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libimp.tex (original) +++ python/branches/py3k-struni/Doc/lib/libimp.tex Thu Jun 7 01:52:48 2007 @@ -69,8 +69,7 @@ Load a module that was previously found by \function{find_module()} (or by an otherwise conducted search yielding compatible results). This function does more than importing the module: if the module was -already imported, it is equivalent to a -\function{reload()}\bifuncindex{reload}! The \var{name} argument +already imported, it will reload the module! The \var{name} argument indicates the full module name (including the package name, if this is a submodule of a package). The \var{file} argument is an open file, and \var{filename} is the corresponding file name; these can be @@ -286,7 +285,7 @@ \end{verbatim} A more complete example that implements hierarchical module names and -includes a \function{reload()}\bifuncindex{reload} function can be +includes a \function{reload()} function can be found in the module \module{knee}\refmodindex{knee}. The \module{knee} module can be found in \file{Demo/imputil/} in the Python source distribution. Modified: python/branches/py3k-struni/Doc/lib/libitertools.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libitertools.tex (original) +++ python/branches/py3k-struni/Doc/lib/libitertools.tex Thu Jun 7 01:52:48 2007 @@ -138,6 +138,13 @@ identity function and returns the element unchanged. Generally, the iterable needs to already be sorted on the same key function. + The operation of \function{groupby()} is similar to the \code{uniq} filter + in \UNIX{}. It generates a break or new group every time the value + of the key function changes (which is why it is usually necessary + to have sorted the data using the same key function). That behavior + differs from SQL's GROUP BY which aggregates common elements regardless + of their input order. + The returned group is itself an iterator that shares the underlying iterable with \function{groupby()}. Because the source is shared, when the \function{groupby} object is advanced, the previous group is no @@ -147,6 +154,7 @@ \begin{verbatim} groups = [] uniquekeys = [] + data = sorted(data, key=keyfunc) for k, g in groupby(data, keyfunc): groups.append(list(g)) # Store group iterator as a list uniquekeys.append(k) Modified: python/branches/py3k-struni/Doc/lib/liblogging.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/liblogging.tex (original) +++ python/branches/py3k-struni/Doc/lib/liblogging.tex Thu Jun 7 01:52:48 2007 @@ -1208,8 +1208,11 @@ communicate with a remote \UNIX{} machine whose address is given by \var{address} in the form of a \code{(\var{host}, \var{port})} tuple. If \var{address} is not specified, \code{('localhost', 514)} is -used. The address is used to open a UDP socket. If \var{facility} is -not specified, \constant{LOG_USER} is used. +used. The address is used to open a UDP socket. An alternative to providing +a \code{(\var{host}, \var{port})} tuple is providing an address as a string, +for example "/dev/log". In this case, a Unix domain socket is used to send +the message to the syslog. If \var{facility} is not specified, +\constant{LOG_USER} is used. \end{classdesc} \begin{methoddesc}{close}{} Deleted: /python/branches/py3k-struni/Doc/lib/libmimewriter.tex ============================================================================== --- /python/branches/py3k-struni/Doc/lib/libmimewriter.tex Thu Jun 7 01:52:48 2007 +++ (empty file) @@ -1,80 +0,0 @@ -\section{\module{MimeWriter} --- - Generic MIME file writer} - -\declaremodule{standard}{MimeWriter} - -\modulesynopsis{Generic MIME file writer.} -\sectionauthor{Christopher G. Petrilli}{petrilli at amber.org} - -\deprecated{2.3}{The \refmodule{email} package should be used in - preference to the \module{MimeWriter} module. This - module is present only to maintain backward - compatibility.} - -This module defines the class \class{MimeWriter}. The -\class{MimeWriter} class implements a basic formatter for creating -MIME multi-part files. It doesn't seek around the output file nor -does it use large amounts of buffer space. You must write the parts -out in the order that they should occur in the final -file. \class{MimeWriter} does buffer the headers you add, allowing you -to rearrange their order. - -\begin{classdesc}{MimeWriter}{fp} -Return a new instance of the \class{MimeWriter} class. The only -argument passed, \var{fp}, is a file object to be used for -writing. Note that a \class{StringIO} object could also be used. -\end{classdesc} - - -\subsection{MimeWriter Objects \label{MimeWriter-objects}} - - -\class{MimeWriter} instances have the following methods: - -\begin{methoddesc}[MimeWriter]{addheader}{key, value\optional{, prefix}} -Add a header line to the MIME message. The \var{key} is the name of -the header, where the \var{value} obviously provides the value of the -header. The optional argument \var{prefix} determines where the header -is inserted; \samp{0} means append at the end, \samp{1} is insert at -the start. The default is to append. -\end{methoddesc} - -\begin{methoddesc}[MimeWriter]{flushheaders}{} -Causes all headers accumulated so far to be written out (and -forgotten). This is useful if you don't need a body part at all, -e.g.\ for a subpart of type \mimetype{message/rfc822} that's (mis)used -to store some header-like information. -\end{methoddesc} - -\begin{methoddesc}[MimeWriter]{startbody}{ctype\optional{, plist\optional{, prefix}}} -Returns a file-like object which can be used to write to the -body of the message. The content-type is set to the provided -\var{ctype}, and the optional parameter \var{plist} provides -additional parameters for the content-type declaration. \var{prefix} -functions as in \method{addheader()} except that the default is to -insert at the start. -\end{methoddesc} - -\begin{methoddesc}[MimeWriter]{startmultipartbody}{subtype\optional{, - boundary\optional{, plist\optional{, prefix}}}} -Returns a file-like object which can be used to write to the -body of the message. Additionally, this method initializes the -multi-part code, where \var{subtype} provides the multipart subtype, -\var{boundary} may provide a user-defined boundary specification, and -\var{plist} provides optional parameters for the subtype. -\var{prefix} functions as in \method{startbody()}. Subparts should be -created using \method{nextpart()}. -\end{methoddesc} - -\begin{methoddesc}[MimeWriter]{nextpart}{} -Returns a new instance of \class{MimeWriter} which represents an -individual part in a multipart message. This may be used to write the -part as well as used for creating recursively complex multipart -messages. The message must first be initialized with -\method{startmultipartbody()} before using \method{nextpart()}. -\end{methoddesc} - -\begin{methoddesc}[MimeWriter]{lastpart}{} -This is used to designate the last part of a multipart message, and -should \emph{always} be used when writing multipart messages. -\end{methoddesc} Deleted: /python/branches/py3k-struni/Doc/lib/libmimify.tex ============================================================================== --- /python/branches/py3k-struni/Doc/lib/libmimify.tex Thu Jun 7 01:52:48 2007 +++ (empty file) @@ -1,94 +0,0 @@ -\section{\module{mimify} --- - MIME processing of mail messages} - -\declaremodule{standard}{mimify} -\modulesynopsis{Mimification and unmimification of mail messages.} - -\deprecated{2.3}{The \refmodule{email} package should be used in - preference to the \module{mimify} module. This - module is present only to maintain backward - compatibility.} - -The \module{mimify} module defines two functions to convert mail messages to -and from MIME format. The mail message can be either a simple message -or a so-called multipart message. Each part is treated separately. -Mimifying (a part of) a message entails encoding the message as -quoted-printable if it contains any characters that cannot be -represented using 7-bit \ASCII. Unmimifying (a part of) a message -entails undoing the quoted-printable encoding. Mimify and unmimify -are especially useful when a message has to be edited before being -sent. Typical use would be: - -\begin{verbatim} -unmimify message -edit message -mimify message -send message -\end{verbatim} - -The modules defines the following user-callable functions and -user-settable variables: - -\begin{funcdesc}{mimify}{infile, outfile} -Copy the message in \var{infile} to \var{outfile}, converting parts to -quoted-printable and adding MIME mail headers when necessary. -\var{infile} and \var{outfile} can be file objects (actually, any -object that has a \method{readline()} method (for \var{infile}) or a -\method{write()} method (for \var{outfile})) or strings naming the files. -If \var{infile} and \var{outfile} are both strings, they may have the -same value. -\end{funcdesc} - -\begin{funcdesc}{unmimify}{infile, outfile\optional{, decode_base64}} -Copy the message in \var{infile} to \var{outfile}, decoding all -quoted-printable parts. \var{infile} and \var{outfile} can be file -objects (actually, any object that has a \method{readline()} method (for -\var{infile}) or a \method{write()} method (for \var{outfile})) or strings -naming the files. If \var{infile} and \var{outfile} are both strings, -they may have the same value. -If the \var{decode_base64} argument is provided and tests true, any -parts that are coded in the base64 encoding are decoded as well. -\end{funcdesc} - -\begin{funcdesc}{mime_decode_header}{line} -Return a decoded version of the encoded header line in \var{line}. -This only supports the ISO 8859-1 charset (Latin-1). -\end{funcdesc} - -\begin{funcdesc}{mime_encode_header}{line} -Return a MIME-encoded version of the header line in \var{line}. -\end{funcdesc} - -\begin{datadesc}{MAXLEN} -By default, a part will be encoded as quoted-printable when it -contains any non-\ASCII{} characters (characters with the 8th bit -set), or if there are any lines longer than \constant{MAXLEN} characters -(default value 200). -\end{datadesc} - -\begin{datadesc}{CHARSET} -When not specified in the mail headers, a character set must be filled -in. The string used is stored in \constant{CHARSET}, and the default -value is ISO-8859-1 (also known as Latin1 (latin-one)). -\end{datadesc} - -This module can also be used from the command line. Usage is as -follows: -\begin{verbatim} -mimify.py -e [-l length] [infile [outfile]] -mimify.py -d [-b] [infile [outfile]] -\end{verbatim} -to encode (mimify) and decode (unmimify) respectively. \var{infile} -defaults to standard input, \var{outfile} defaults to standard output. -The same file can be specified for input and output. - -If the \strong{-l} option is given when encoding, if there are any lines -longer than the specified \var{length}, the containing part will be -encoded. - -If the \strong{-b} option is given when decoding, any base64 parts will -be decoded as well. - -\begin{seealso} - \seemodule{quopri}{Encode and decode MIME quoted-printable files.} -\end{seealso} Modified: python/branches/py3k-struni/Doc/lib/libpickle.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libpickle.tex (original) +++ python/branches/py3k-struni/Doc/lib/libpickle.tex Thu Jun 7 01:52:48 2007 @@ -799,7 +799,7 @@ del odict['fh'] # remove filehandle entry return odict - def __setstate__(self,dict): + def __setstate__(self, dict): fh = open(dict['file']) # reopen file count = dict['lineno'] # read from file... while count: # until line count is restored @@ -820,7 +820,7 @@ ... obj.readline() '7: class TextReader:' >>> import pickle ->>> pickle.dump(obj,open('save.p','w')) +>>> pickle.dump(obj,open('save.p', 'wb')) \end{verbatim} If you want to see that \refmodule{pickle} works across Python @@ -829,7 +829,7 @@ \begin{verbatim} >>> import pickle ->>> reader = pickle.load(open('save.p')) +>>> reader = pickle.load(open('save.p', 'rb')) >>> reader.readline() '8: "Print and number lines in a text file."' \end{verbatim} Deleted: /python/branches/py3k-struni/Doc/lib/libposixfile.tex ============================================================================== --- /python/branches/py3k-struni/Doc/lib/libposixfile.tex Thu Jun 7 01:52:48 2007 +++ (empty file) @@ -1,174 +0,0 @@ -% Manual text and implementation by Jaap Vermeulen -\section{\module{posixfile} --- - File-like objects with locking support} - -\declaremodule{builtin}{posixfile} - \platform{Unix} -\modulesynopsis{A file-like object with support for locking.} -\moduleauthor{Jaap Vermeulen}{} -\sectionauthor{Jaap Vermeulen}{} - - -\indexii{\POSIX}{file object} - -\deprecated{1.5}{The locking operation that this module provides is -done better and more portably by the -\function{\refmodule{fcntl}.lockf()} call. -\withsubitem{(in module fcntl)}{\ttindex{lockf()}}} - -This module implements some additional functionality over the built-in -file objects. In particular, it implements file locking, control over -the file flags, and an easy interface to duplicate the file object. -The module defines a new file object, the posixfile object. It -has all the standard file object methods and adds the methods -described below. This module only works for certain flavors of -\UNIX, since it uses \function{fcntl.fcntl()} for file locking.% -\withsubitem{(in module fcntl)}{\ttindex{fcntl()}} - -To instantiate a posixfile object, use the \function{open()} function -in the \module{posixfile} module. The resulting object looks and -feels roughly the same as a standard file object. - -The \module{posixfile} module defines the following constants: - - -\begin{datadesc}{SEEK_SET} -Offset is calculated from the start of the file. -\end{datadesc} - -\begin{datadesc}{SEEK_CUR} -Offset is calculated from the current position in the file. -\end{datadesc} - -\begin{datadesc}{SEEK_END} -Offset is calculated from the end of the file. -\end{datadesc} - -The \module{posixfile} module defines the following functions: - - -\begin{funcdesc}{open}{filename\optional{, mode\optional{, bufsize}}} - Create a new posixfile object with the given filename and mode. The - \var{filename}, \var{mode} and \var{bufsize} arguments are - interpreted the same way as by the built-in \function{open()} - function. -\end{funcdesc} - -\begin{funcdesc}{fileopen}{fileobject} - Create a new posixfile object with the given standard file object. - The resulting object has the same filename and mode as the original - file object. -\end{funcdesc} - -The posixfile object defines the following additional methods: - -\begin{methoddesc}[posixfile]{lock}{fmt, \optional{len\optional{, start\optional{, whence}}}} - Lock the specified section of the file that the file object is - referring to. The format is explained - below in a table. The \var{len} argument specifies the length of the - section that should be locked. The default is \code{0}. \var{start} - specifies the starting offset of the section, where the default is - \code{0}. The \var{whence} argument specifies where the offset is - relative to. It accepts one of the constants \constant{SEEK_SET}, - \constant{SEEK_CUR} or \constant{SEEK_END}. The default is - \constant{SEEK_SET}. For more information about the arguments refer - to the \manpage{fcntl}{2} manual page on your system. -\end{methoddesc} - -\begin{methoddesc}[posixfile]{flags}{\optional{flags}} - Set the specified flags for the file that the file object is referring - to. The new flags are ORed with the old flags, unless specified - otherwise. The format is explained below in a table. Without - the \var{flags} argument - a string indicating the current flags is returned (this is - the same as the \samp{?} modifier). For more information about the - flags refer to the \manpage{fcntl}{2} manual page on your system. -\end{methoddesc} - -\begin{methoddesc}[posixfile]{dup}{} - Duplicate the file object and the underlying file pointer and file - descriptor. The resulting object behaves as if it were newly - opened. -\end{methoddesc} - -\begin{methoddesc}[posixfile]{dup2}{fd} - Duplicate the file object and the underlying file pointer and file - descriptor. The new object will have the given file descriptor. - Otherwise the resulting object behaves as if it were newly opened. -\end{methoddesc} - -\begin{methoddesc}[posixfile]{file}{} - Return the standard file object that the posixfile object is based - on. This is sometimes necessary for functions that insist on a - standard file object. -\end{methoddesc} - -All methods raise \exception{IOError} when the request fails. - -Format characters for the \method{lock()} method have the following -meaning: - -\begin{tableii}{c|l}{samp}{Format}{Meaning} - \lineii{u}{unlock the specified region} - \lineii{r}{request a read lock for the specified section} - \lineii{w}{request a write lock for the specified section} -\end{tableii} - -In addition the following modifiers can be added to the format: - -\begin{tableiii}{c|l|c}{samp}{Modifier}{Meaning}{Notes} - \lineiii{|}{wait until the lock has been granted}{} - \lineiii{?}{return the first lock conflicting with the requested lock, or - \code{None} if there is no conflict.}{(1)} -\end{tableiii} - -\noindent -Note: - -\begin{description} -\item[(1)] The lock returned is in the format \code{(\var{mode}, \var{len}, -\var{start}, \var{whence}, \var{pid})} where \var{mode} is a character -representing the type of lock ('r' or 'w'). This modifier prevents a -request from being granted; it is for query purposes only. -\end{description} - -Format characters for the \method{flags()} method have the following -meanings: - -\begin{tableii}{c|l}{samp}{Format}{Meaning} - \lineii{a}{append only flag} - \lineii{c}{close on exec flag} - \lineii{n}{no delay flag (also called non-blocking flag)} - \lineii{s}{synchronization flag} -\end{tableii} - -In addition the following modifiers can be added to the format: - -\begin{tableiii}{c|l|c}{samp}{Modifier}{Meaning}{Notes} - \lineiii{!}{turn the specified flags 'off', instead of the default 'on'}{(1)} - \lineiii{=}{replace the flags, instead of the default 'OR' operation}{(1)} - \lineiii{?}{return a string in which the characters represent the flags that - are set.}{(2)} -\end{tableiii} - -\noindent -Notes: - -\begin{description} -\item[(1)] The \samp{!} and \samp{=} modifiers are mutually exclusive. - -\item[(2)] This string represents the flags after they may have been altered -by the same call. -\end{description} - -Examples: - -\begin{verbatim} -import posixfile - -file = posixfile.open('/tmp/test', 'w') -file.lock('w|') -... -file.lock('u') -file.close() -\end{verbatim} Modified: python/branches/py3k-struni/Doc/lib/libshlex.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libshlex.tex (original) +++ python/branches/py3k-struni/Doc/lib/libshlex.tex Thu Jun 7 01:52:48 2007 @@ -19,13 +19,15 @@ The \module{shlex} module defines the following functions: -\begin{funcdesc}{split}{s\optional{, comments}} +\begin{funcdesc}{split}{s\optional{, comments\optional{, posix}}} Split the string \var{s} using shell-like syntax. If \var{comments} is \constant{False} (the default), the parsing of comments in the given string will be disabled (setting the \member{commenters} member of the \class{shlex} instance to the empty string). This function operates -in \POSIX{} mode. +in \POSIX{} mode by default, but uses non-\POSIX{} mode if the +\var{posix} argument is false. \versionadded{2.3} +\versionchanged[Added the \var{posix} parameter]{2.6} \end{funcdesc} The \module{shlex} module defines the following class: Modified: python/branches/py3k-struni/Doc/lib/libsubprocess.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libsubprocess.tex (original) +++ python/branches/py3k-struni/Doc/lib/libsubprocess.tex Thu Jun 7 01:52:48 2007 @@ -87,7 +87,10 @@ If \var{close_fds} is true, all file descriptors except \constant{0}, \constant{1} and \constant{2} will be closed before the child process is -executed. (\UNIX{} only) +executed. (\UNIX{} only). Or, on Windows, if \var{close_fds} is true +then no handles will be inherited by the child process. Note that on +Windows, you cannot set \var{close_fds} to true and also redirect the +standard handles by setting \var{stdin}, \var{stdout} or \var{stderr}. If \var{shell} is \constant{True}, the specified command will be executed through the shell. Modified: python/branches/py3k-struni/Doc/lib/libsys.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libsys.tex (original) +++ python/branches/py3k-struni/Doc/lib/libsys.tex Thu Jun 7 01:52:48 2007 @@ -132,11 +132,6 @@ encapsulates the call stack at the point where the exception originally occurred. \obindex{traceback} - If \function{exc_clear()} is called, this function will return three - \code{None} values until either another exception is raised in the - current thread or the execution stack returns to a frame where - another exception is being handled. - \warning{Assigning the \var{traceback} return value to a local variable in a function that is handling an exception will cause a circular reference. This will prevent anything referenced @@ -153,32 +148,6 @@ efficient to avoid creating cycles.} \end{funcdesc} -\begin{funcdesc}{exc_clear}{} - This function clears all information relating to the current or last - exception that occurred in the current thread. After calling this - function, \function{exc_info()} will return three \code{None} values until - another exception is raised in the current thread or the execution stack - returns to a frame where another exception is being handled. - - This function is only needed in only a few obscure situations. These - include logging and error handling systems that report information on the - last or current exception. This function can also be used to try to free - resources and trigger object finalization, though no guarantee is made as - to what objects will be freed, if any. -\versionadded{2.3} -\end{funcdesc} - -\begin{datadesc}{exc_type} -\dataline{exc_value} -\dataline{exc_traceback} -\deprecated {1.5} - {Use \function{exc_info()} instead.} - Since they are global variables, they are not specific to the - current thread, so their use is not safe in a multi-threaded - program. When no exception is being handled, \code{exc_type} is set - to \code{None} and the other two are undefined. -\end{datadesc} - \begin{datadesc}{exec_prefix} A string giving the site-specific directory prefix where the platform-dependent Python files are installed; by default, this is @@ -377,10 +346,7 @@ \begin{datadesc}{modules} This is a dictionary that maps module names to modules which have already been loaded. This can be manipulated to force reloading of - modules and other tricks. Note that removing a module from this - dictionary is \emph{not} the same as calling - \function{reload()}\bifuncindex{reload} on the corresponding module - object. + modules and other tricks. \end{datadesc} \begin{datadesc}{path} Modified: python/branches/py3k-struni/Doc/lib/libtarfile.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libtarfile.tex (original) +++ python/branches/py3k-struni/Doc/lib/libtarfile.tex Thu Jun 7 01:52:48 2007 @@ -133,24 +133,20 @@ \versionadded{2.6} \end{excdesc} +Each of the following constants defines a tar archive format that the +\module{tarfile} module is able to create. See section \ref{tar-formats} for +details. + \begin{datadesc}{USTAR_FORMAT} - \POSIX{}.1-1988 (ustar) format. It supports filenames up to a length of - at best 256 characters and linknames up to 100 characters. The maximum - file size is 8 gigabytes. This is an old and limited but widely - supported format. + \POSIX{}.1-1988 (ustar) format. \end{datadesc} \begin{datadesc}{GNU_FORMAT} - GNU tar format. It supports arbitrarily long filenames and linknames and - files bigger than 8 gigabytes. It is the defacto standard on GNU/Linux - systems. + GNU tar format. \end{datadesc} \begin{datadesc}{PAX_FORMAT} - \POSIX{}.1-2001 (pax) format. It is the most flexible format with - virtually no limits. It supports long filenames and linknames, large files - and stores pathnames in a portable way. However, not all tar - implementations today are able to handle pax archives properly. + \POSIX{}.1-2001 (pax) format. \end{datadesc} \begin{datadesc}{DEFAULT_FORMAT} @@ -175,15 +171,15 @@ The \class{TarFile} object provides an interface to a tar archive. A tar archive is a sequence of blocks. An archive member (a stored file) is made up -of a header block followed by data blocks. It is possible, to store a file in a +of a header block followed by data blocks. It is possible to store a file in a tar archive several times. Each archive member is represented by a \class{TarInfo} object, see \citetitle{TarInfo Objects} (section \ref{tarinfo-objects}) for details. \begin{classdesc}{TarFile}{name=None, mode='r', fileobj=None, format=DEFAULT_FORMAT, tarinfo=TarInfo, dereference=False, - ignore_zeros=False, encoding=None, pax_headers=None, debug=0, - errorlevel=0} + ignore_zeros=False, encoding=None, errors=None, pax_headers=None, + debug=0, errorlevel=0} All following arguments are optional and can be accessed as instance attributes as well. @@ -231,18 +227,14 @@ If \code{2}, all \emph{non-fatal} errors are raised as \exception{TarError} exceptions as well. - The \var{encoding} argument defines the local character encoding. It - defaults to the value from \function{sys.getfilesystemencoding()} or if - that is \code{None} to \code{"ascii"}. \var{encoding} is used only in - connection with the pax format which stores text data in \emph{UTF-8}. If - it is not set correctly, character conversion will fail with a - \exception{UnicodeError}. + The \var{encoding} and \var{errors} arguments control the way strings are + converted to unicode objects and vice versa. The default settings will work + for most users. See section \ref{tar-unicode} for in-depth information. \versionadded{2.6} - The \var{pax_headers} argument must be a dictionary whose elements are - either unicode objects, numbers or strings that can be decoded to unicode - using \var{encoding}. This information will be added to the archive as a - pax global header. + The \var{pax_headers} argument is an optional dictionary of unicode strings + which will be added as a pax global header if \var{format} is + \constant{PAX_FORMAT}. \versionadded{2.6} \end{classdesc} @@ -287,7 +279,7 @@ Extract all members from the archive to the current working directory or directory \var{path}. If optional \var{members} is given, it must be a subset of the list returned by \method{getmembers()}. - Directory informations like owner, modification time and permissions are + Directory information like owner, modification time and permissions are set after all members have been extracted. This is done to work around two problems: A directory's modification time is reset each time a file is created in it. And, if a directory's permissions do not allow writing, @@ -365,6 +357,11 @@ \deprecated{2.6}{Use the \member{format} attribute instead.} \end{memberdesc} +\begin{memberdesc}{pax_headers} + A dictionary containing key-value pairs of pax global headers. + \versionadded{2.6} +\end{memberdesc} + %----------------- % TarInfo Objects %----------------- @@ -384,8 +381,8 @@ Create a \class{TarInfo} object. \end{classdesc} -\begin{methoddesc}{frombuf}{} - Create and return a \class{TarInfo} object from a string buffer. +\begin{methoddesc}{frombuf}{buf} + Create and return a \class{TarInfo} object from string buffer \var{buf}. \versionadded[Raises \exception{HeaderError} if the buffer is invalid.]{2.6} \end{methoddesc} @@ -396,10 +393,11 @@ \versionadded{2.6} \end{methoddesc} -\begin{methoddesc}{tobuf}{\optional{format}} - Create a string buffer from a \class{TarInfo} object. See - \class{TarFile}'s \member{format} argument for information. - \versionchanged[The \var{format} parameter]{2.6} +\begin{methoddesc}{tobuf}{\optional{format\optional{, encoding + \optional{, errors}}}} + Create a string buffer from a \class{TarInfo} object. For information + on the arguments see the constructor of the \class{TarFile} class. + \versionchanged[The arguments were added]{2.6} \end{methoddesc} A \code{TarInfo} object has the following public data attributes: @@ -452,6 +450,12 @@ Group name. \end{memberdesc} +\begin{memberdesc}{pax_headers} + A dictionary containing key-value pairs of an associated pax + extended header. + \versionadded{2.6} +\end{memberdesc} + A \class{TarInfo} object also provides some convenient query methods: \begin{methoddesc}{isfile}{} @@ -554,3 +558,103 @@ tar.extract(tarinfo) tar.close() \end{verbatim} + +%------------ +% Tar format +%------------ + +\subsection{Supported tar formats \label{tar-formats}} + +There are three tar formats that can be created with the \module{tarfile} +module: + +\begin{itemize} + +\item +The \POSIX{}.1-1988 ustar format (\constant{USTAR_FORMAT}). It supports +filenames up to a length of at best 256 characters and linknames up to 100 +characters. The maximum file size is 8 gigabytes. This is an old and limited +but widely supported format. + +\item +The GNU tar format (\constant{GNU_FORMAT}). It supports long filenames and +linknames, files bigger than 8 gigabytes and sparse files. It is the de facto +standard on GNU/Linux systems. \module{tarfile} fully supports the GNU tar +extensions for long names, sparse file support is read-only. + +\item +The \POSIX{}.1-2001 pax format (\constant{PAX_FORMAT}). It is the most +flexible format with virtually no limits. It supports long filenames and +linknames, large files and stores pathnames in a portable way. However, not +all tar implementations today are able to handle pax archives properly. + +The \emph{pax} format is an extension to the existing \emph{ustar} format. It +uses extra headers for information that cannot be stored otherwise. There are +two flavours of pax headers: Extended headers only affect the subsequent file +header, global headers are valid for the complete archive and affect all +following files. All the data in a pax header is encoded in \emph{UTF-8} for +portability reasons. + +\end{itemize} + +There are some more variants of the tar format which can be read, but not +created: + +\begin{itemize} + +\item +The ancient V7 format. This is the first tar format from \UNIX{} Seventh +Edition, storing only regular files and directories. Names must not be longer +than 100 characters, there is no user/group name information. Some archives +have miscalculated header checksums in case of fields with non-\ASCII{} +characters. + +\item +The SunOS tar extended format. This format is a variant of the \POSIX{}.1-2001 +pax format, but is not compatible. + +\end{itemize} + +%---------------- +% Unicode issues +%---------------- + +\subsection{Unicode issues \label{tar-unicode}} + +The tar format was originally conceived to make backups on tape drives with the +main focus on preserving file system information. Nowadays tar archives are +commonly used for file distribution and exchanging archives over networks. One +problem of the original format (that all other formats are merely variants of) +is that there is no concept of supporting different character encodings. +For example, an ordinary tar archive created on a \emph{UTF-8} system cannot be +read correctly on a \emph{Latin-1} system if it contains non-\ASCII{} +characters. Names (i.e. filenames, linknames, user/group names) containing +these characters will appear damaged. Unfortunately, there is no way to +autodetect the encoding of an archive. + +The pax format was designed to solve this problem. It stores non-\ASCII{} names +using the universal character encoding \emph{UTF-8}. When a pax archive is +read, these \emph{UTF-8} names are converted to the encoding of the local +file system. + +The details of unicode conversion are controlled by the \var{encoding} and +\var{errors} keyword arguments of the \class{TarFile} class. + +The default value for \var{encoding} is the local character encoding. It is +deduced from \function{sys.getfilesystemencoding()} and +\function{sys.getdefaultencoding()}. In read mode, \var{encoding} is used +exclusively to convert unicode names from a pax archive to strings in the local +character encoding. In write mode, the use of \var{encoding} depends on the +chosen archive format. In case of \constant{PAX_FORMAT}, input names that +contain non-\ASCII{} characters need to be decoded before being stored as +\emph{UTF-8} strings. The other formats do not make use of \var{encoding} +unless unicode objects are used as input names. These are converted to +8-bit character strings before they are added to the archive. + +The \var{errors} argument defines how characters are treated that cannot be +converted to or from \var{encoding}. Possible values are listed in section +\ref{codec-base-classes}. In read mode, there is an additional scheme +\code{'utf-8'} which means that bad characters are replaced by their +\emph{UTF-8} representation. This is the default scheme. In write mode the +default value for \var{errors} is \code{'strict'} to ensure that name +information is not altered unnoticed. Modified: python/branches/py3k-struni/Doc/lib/libtypes.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libtypes.tex (original) +++ python/branches/py3k-struni/Doc/lib/libtypes.tex Thu Jun 7 01:52:48 2007 @@ -163,7 +163,7 @@ \begin{datadesc}{TracebackType} The type of traceback objects such as found in -\code{sys.exc_traceback}. +\code{sys.exc_info()[2]}. \end{datadesc} \begin{datadesc}{FrameType} Modified: python/branches/py3k-struni/Doc/lib/libundoc.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libundoc.tex (original) +++ python/branches/py3k-struni/Doc/lib/libundoc.tex Thu Jun 7 01:52:48 2007 @@ -88,7 +88,6 @@ % XXX need Windows instructions! \begin{description} -\item[\module{timing}] ---- Measure time intervals to high resolution (use \function{time.clock()} - instead). +\item +--- This section should be empty for Python 3.0. \end{description} Modified: python/branches/py3k-struni/Doc/lib/libzipimport.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libzipimport.tex (original) +++ python/branches/py3k-struni/Doc/lib/libzipimport.tex Thu Jun 7 01:52:48 2007 @@ -29,11 +29,6 @@ if a ZIP archive doesn't contain \file{.pyc} files, importing may be rather slow. -Using the built-in \function{reload()} function will -fail if called on a module loaded from a ZIP archive; it is unlikely that -\function{reload()} would be needed, since this would imply that the ZIP -has been altered during runtime. - The available attributes of this module are: \begin{excdesc}{ZipImportError} Modified: python/branches/py3k-struni/Doc/mac/undoc.tex ============================================================================== --- python/branches/py3k-struni/Doc/mac/undoc.tex (original) +++ python/branches/py3k-struni/Doc/mac/undoc.tex Thu Jun 7 01:52:48 2007 @@ -23,18 +23,6 @@ \deprecated{2.4}{} -\section{\module{cfmfile} --- Code Fragment Resource module} -\declaremodule{standard}{cfmfile} - \platform{Mac} -\modulesynopsis{Code Fragment Resource module.} - -\module{cfmfile} is a module that understands Code Fragments and the -accompanying ``cfrg'' resources. It can parse them and merge them, and is -used by BuildApplication to combine all plugin modules to a single -executable. - -\deprecated{2.4}{} - \section{\module{icopen} --- Internet Config replacement for \method{open()}} \declaremodule{standard}{icopen} \platform{Mac} Modified: python/branches/py3k-struni/Doc/ref/ref3.tex ============================================================================== --- python/branches/py3k-struni/Doc/ref/ref3.tex (original) +++ python/branches/py3k-struni/Doc/ref/ref3.tex Thu Jun 7 01:52:48 2007 @@ -977,10 +977,8 @@ traceback. When an exception handler is entered, the stack trace is made available to the program. (See section~\ref{try}, ``The \code{try} statement.'') -It is accessible as \code{sys.exc_traceback}, and also as the third -item of the tuple returned by \code{sys.exc_info()}. The latter is -the preferred interface, since it works correctly when the program is -using multiple threads. +It is accessible as the third +item of the tuple returned by \code{sys.exc_info()}. When the program contains no suitable handler, the stack trace is written (nicely formatted) to the standard error stream; if the interpreter is interactive, it is also made available to the user as @@ -994,7 +992,6 @@ \ttindex{exc_traceback} \ttindex{last_traceback}} \ttindex{sys.exc_info} -\ttindex{sys.exc_traceback} \ttindex{sys.last_traceback} Special read-only attributes: \member{tb_next} is the next level in the @@ -1198,13 +1195,13 @@ references between objects (e.g., a doubly-linked list or a tree data structure with parent and child pointers); a reference to the object on the stack frame of a function that caught an exception (the -traceback stored in \code{sys.exc_traceback} keeps the stack frame +traceback stored in \code{sys.exc_info()[2]} keeps the stack frame alive); or a reference to the object on the stack frame that raised an unhandled exception in interactive mode (the traceback stored in \code{sys.last_traceback} keeps the stack frame alive). The first situation can only be remedied by explicitly breaking the cycles; the latter two situations can be resolved by storing \code{None} in -\code{sys.exc_traceback} or \code{sys.last_traceback}. Circular +\code{sys.last_traceback}. Circular references which are garbage are detected when the option cycle detector is enabled (it's on by default), but can only be cleaned up if there are no Python-level \method{__del__()} methods involved. Modified: python/branches/py3k-struni/Doc/tut/tut.tex ============================================================================== --- python/branches/py3k-struni/Doc/tut/tut.tex (original) +++ python/branches/py3k-struni/Doc/tut/tut.tex Thu Jun 7 01:52:48 2007 @@ -2653,7 +2653,7 @@ ['__displayhook__', '__doc__', '__excepthook__', '__name__', '__stderr__', '__stdin__', '__stdout__', '_getframe', 'api_version', 'argv', 'builtin_module_names', 'byteorder', 'callstats', 'copyright', - 'displayhook', 'exc_clear', 'exc_info', 'exc_type', 'excepthook', + 'displayhook', 'exc_info', 'excepthook', 'exec_prefix', 'executable', 'exit', 'getdefaultencoding', 'getdlopenflags', 'getrecursionlimit', 'getrefcount', 'hexversion', 'maxint', 'maxunicode', 'meta_path', 'modules', 'path', 'path_hooks', 'path_importer_cache', @@ -2703,7 +2703,7 @@ 'id', 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'min', 'object', 'oct', 'open', 'ord', 'pow', 'property', 'quit', 'range', - 'reload', 'repr', 'reversed', 'round', 'set', + 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'unichr', 'unicode', 'vars', 'zip'] \end{verbatim} Modified: python/branches/py3k-struni/Grammar/Grammar ============================================================================== --- python/branches/py3k-struni/Grammar/Grammar (original) +++ python/branches/py3k-struni/Grammar/Grammar Thu Jun 7 01:52:48 2007 @@ -100,7 +100,7 @@ atom: ('(' [yield_expr|testlist_comp] ')' | '[' [testlist_comp] ']' | '{' [dictorsetmaker] '}' | - NAME | NUMBER | STRING+ | '...') + NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False') testlist_comp: test ( comp_for | (',' test)* [','] ) trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME subscriptlist: subscript (',' subscript)* [','] Deleted: /python/branches/py3k-struni/Lib/MimeWriter.py ============================================================================== --- /python/branches/py3k-struni/Lib/MimeWriter.py Thu Jun 7 01:52:48 2007 +++ (empty file) @@ -1,181 +0,0 @@ -"""Generic MIME writer. - -This module defines the class MimeWriter. The MimeWriter class implements -a basic formatter for creating MIME multi-part files. It doesn't seek around -the output file nor does it use large amounts of buffer space. You must write -the parts out in the order that they should occur in the final file. -MimeWriter does buffer the headers you add, allowing you to rearrange their -order. - -""" - - -import mimetools - -__all__ = ["MimeWriter"] - -class MimeWriter: - - """Generic MIME writer. - - Methods: - - __init__() - addheader() - flushheaders() - startbody() - startmultipartbody() - nextpart() - lastpart() - - A MIME writer is much more primitive than a MIME parser. It - doesn't seek around on the output file, and it doesn't use large - amounts of buffer space, so you have to write the parts in the - order they should occur on the output file. It does buffer the - headers you add, allowing you to rearrange their order. - - General usage is: - - f = - w = MimeWriter(f) - ...call w.addheader(key, value) 0 or more times... - - followed by either: - - f = w.startbody(content_type) - ...call f.write(data) for body data... - - or: - - w.startmultipartbody(subtype) - for each part: - subwriter = w.nextpart() - ...use the subwriter's methods to create the subpart... - w.lastpart() - - The subwriter is another MimeWriter instance, and should be - treated in the same way as the toplevel MimeWriter. This way, - writing recursive body parts is easy. - - Warning: don't forget to call lastpart()! - - XXX There should be more state so calls made in the wrong order - are detected. - - Some special cases: - - - startbody() just returns the file passed to the constructor; - but don't use this knowledge, as it may be changed. - - - startmultipartbody() actually returns a file as well; - this can be used to write the initial 'if you can read this your - mailer is not MIME-aware' message. - - - If you call flushheaders(), the headers accumulated so far are - written out (and forgotten); this is useful if you don't need a - body part at all, e.g. for a subpart of type message/rfc822 - that's (mis)used to store some header-like information. - - - Passing a keyword argument 'prefix=' to addheader(), - start*body() affects where the header is inserted; 0 means - append at the end, 1 means insert at the start; default is - append for addheader(), but insert for start*body(), which use - it to determine where the Content-Type header goes. - - """ - - def __init__(self, fp): - self._fp = fp - self._headers = [] - - def addheader(self, key, value, prefix=0): - """Add a header line to the MIME message. - - The key is the name of the header, where the value obviously provides - the value of the header. The optional argument prefix determines - where the header is inserted; 0 means append at the end, 1 means - insert at the start. The default is to append. - - """ - lines = value.split("\n") - while lines and not lines[-1]: del lines[-1] - while lines and not lines[0]: del lines[0] - for i in range(1, len(lines)): - lines[i] = " " + lines[i].strip() - value = "\n".join(lines) + "\n" - line = key + ": " + value - if prefix: - self._headers.insert(0, line) - else: - self._headers.append(line) - - def flushheaders(self): - """Writes out and forgets all headers accumulated so far. - - This is useful if you don't need a body part at all; for example, - for a subpart of type message/rfc822 that's (mis)used to store some - header-like information. - - """ - self._fp.writelines(self._headers) - self._headers = [] - - def startbody(self, ctype, plist=[], prefix=1): - """Returns a file-like object for writing the body of the message. - - The content-type is set to the provided ctype, and the optional - parameter, plist, provides additional parameters for the - content-type declaration. The optional argument prefix determines - where the header is inserted; 0 means append at the end, 1 means - insert at the start. The default is to insert at the start. - - """ - for name, value in plist: - ctype = ctype + ';\n %s=\"%s\"' % (name, value) - self.addheader("Content-Type", ctype, prefix=prefix) - self.flushheaders() - self._fp.write("\n") - return self._fp - - def startmultipartbody(self, subtype, boundary=None, plist=[], prefix=1): - """Returns a file-like object for writing the body of the message. - - Additionally, this method initializes the multi-part code, where the - subtype parameter provides the multipart subtype, the boundary - parameter may provide a user-defined boundary specification, and the - plist parameter provides optional parameters for the subtype. The - optional argument, prefix, determines where the header is inserted; - 0 means append at the end, 1 means insert at the start. The default - is to insert at the start. Subparts should be created using the - nextpart() method. - - """ - self._boundary = boundary or mimetools.choose_boundary() - return self.startbody("multipart/" + subtype, - [("boundary", self._boundary)] + plist, - prefix=prefix) - - def nextpart(self): - """Returns a new instance of MimeWriter which represents an - individual part in a multipart message. - - This may be used to write the part as well as used for creating - recursively complex multipart messages. The message must first be - initialized with the startmultipartbody() method before using the - nextpart() method. - - """ - self._fp.write("\n--" + self._boundary + "\n") - return self.__class__(self._fp) - - def lastpart(self): - """This is used to designate the last part of a multipart message. - - It should always be used when writing multipart messages. - - """ - self._fp.write("\n--" + self._boundary + "--\n") - - -if __name__ == '__main__': - import test.test_MimeWriter Modified: python/branches/py3k-struni/Lib/SocketServer.py ============================================================================== --- python/branches/py3k-struni/Lib/SocketServer.py (original) +++ python/branches/py3k-struni/Lib/SocketServer.py Thu Jun 7 01:52:48 2007 @@ -518,12 +518,9 @@ self.request = request self.client_address = client_address self.server = server - try: - self.setup() - self.handle() - self.finish() - finally: - sys.exc_traceback = None # Help garbage collection + self.setup() + self.handle() + self.finish() def setup(self): pass Modified: python/branches/py3k-struni/Lib/bsddb/test/test_thread.py ============================================================================== --- python/branches/py3k-struni/Lib/bsddb/test/test_thread.py (original) +++ python/branches/py3k-struni/Lib/bsddb/test/test_thread.py Thu Jun 7 01:52:48 2007 @@ -10,12 +10,6 @@ from pprint import pprint from random import random -try: - True, False -except NameError: - True = 1 - False = 0 - DASH = '-' try: Modified: python/branches/py3k-struni/Lib/ctypes/wintypes.py ============================================================================== --- python/branches/py3k-struni/Lib/ctypes/wintypes.py (original) +++ python/branches/py3k-struni/Lib/ctypes/wintypes.py Thu Jun 7 01:52:48 2007 @@ -147,7 +147,7 @@ ("dwReserved0", DWORD), ("dwReserved1", DWORD), ("cFileName", c_char * MAX_PATH), - ("cAlternameFileName", c_char * 14)] + ("cAlternateFileName", c_char * 14)] class WIN32_FIND_DATAW(Structure): _fields_ = [("dwFileAttributes", DWORD), @@ -159,7 +159,7 @@ ("dwReserved0", DWORD), ("dwReserved1", DWORD), ("cFileName", c_wchar * MAX_PATH), - ("cAlternameFileName", c_wchar * 14)] + ("cAlternateFileName", c_wchar * 14)] __all__ = ['ATOM', 'BOOL', 'BOOLEAN', 'BYTE', 'COLORREF', 'DOUBLE', 'DWORD', 'FILETIME', 'HACCEL', 'HANDLE', 'HBITMAP', 'HBRUSH', Modified: python/branches/py3k-struni/Lib/dis.py ============================================================================== --- python/branches/py3k-struni/Lib/dis.py (original) +++ python/branches/py3k-struni/Lib/dis.py Thu Jun 7 01:52:48 2007 @@ -23,13 +23,10 @@ if hasattr(x, '__code__'): x = x.__code__ if hasattr(x, '__dict__'): - items = x.__dict__.items() - items.sort() + items = sorted(x.__dict__.items()) for name, x1 in items: - if type(x1) in (types.MethodType, - types.FunctionType, - types.CodeType, - types.ClassType): + if isinstance(x1, (types.MethodType, types.FunctionType, + types.CodeType, types.ClassType, type)): print("Disassembly of %s:" % name) try: dis(x1) @@ -41,9 +38,8 @@ elif isinstance(x, str): disassemble_string(x) else: - raise TypeError, \ - "don't know how to disassemble %s objects" % \ - type(x).__name__ + raise TypeError("don't know how to disassemble %s objects" % + type(x).__name__) def distb(tb=None): """Disassemble a traceback (default: last traceback).""" Modified: python/branches/py3k-struni/Lib/idlelib/StackViewer.py ============================================================================== --- python/branches/py3k-struni/Lib/idlelib/StackViewer.py (original) +++ python/branches/py3k-struni/Lib/idlelib/StackViewer.py Thu Jun 7 01:52:48 2007 @@ -120,18 +120,3 @@ item = make_objecttreeitem(key + " =", value, setfunction) sublist.append(item) return sublist - - -def _test(): - try: - import testcode - reload(testcode) - except: - sys.last_type, sys.last_value, sys.last_traceback = sys.exc_info() - from Tkinter import Tk - root = Tk() - StackBrowser(None, top=root) - root.mainloop() - -if __name__ == "__main__": - _test() Modified: python/branches/py3k-struni/Lib/ihooks.py ============================================================================== --- python/branches/py3k-struni/Lib/ihooks.py (original) +++ python/branches/py3k-struni/Lib/ihooks.py Thu Jun 7 01:52:48 2007 @@ -45,9 +45,7 @@ If a module importer class supports dotted names, its import_module() must return a different value depending on whether it is called on behalf of a "from ... import ..." statement or not. (This is caused -by the way the __import__ hook is used by the Python interpreter.) It -would also do wise to install a different version of reload(). - +by the way the __import__ hook is used by the Python interpreter.) """ @@ -379,17 +377,14 @@ def install(self): self.save_import_module = __builtin__.__import__ - self.save_reload = __builtin__.reload if not hasattr(__builtin__, 'unload'): __builtin__.unload = None self.save_unload = __builtin__.unload __builtin__.__import__ = self.import_module - __builtin__.reload = self.reload __builtin__.unload = self.unload def uninstall(self): __builtin__.__import__ = self.save_import_module - __builtin__.reload = self.save_reload __builtin__.unload = self.save_unload if not __builtin__.unload: del __builtin__.unload Modified: python/branches/py3k-struni/Lib/imputil.py ============================================================================== --- python/branches/py3k-struni/Lib/imputil.py (original) +++ python/branches/py3k-struni/Lib/imputil.py Thu Jun 7 01:52:48 2007 @@ -40,9 +40,6 @@ self.namespace = namespace namespace['__import__'] = self._import_hook - ### fix this - #namespace['reload'] = self._reload_hook - def uninstall(self): "Restore the previous import mechanism." self.namespace['__import__'] = self.previous_importer @@ -194,22 +191,6 @@ return module return None - def _reload_hook(self, module): - "Python calls this hook to reload a module." - - # reloading of a module may or may not be possible (depending on the - # importer), but at least we can validate that it's ours to reload - importer = module.__dict__.get('__importer__') - if not importer: - ### oops. now what... - pass - - # okay. it is using the imputil system, and we must delegate it, but - # we don't know what to do (yet) - ### we should blast the module dict and do another get_code(). need to - ### flesh this out and add proper docco... - raise SystemError, "reload not yet implemented" - class Importer: "Base class for replacing standard import functions." @@ -682,7 +663,6 @@ # flag to force absolute imports? (speeds _determine_import_context and # checking for a relative module) # insert names of archives into sys.path (see quote below) -# note: reload does NOT blast module dict # shift import mechanisms and policies around; provide for hooks, overrides # (see quote below) # add get_source stuff Modified: python/branches/py3k-struni/Lib/logging/__init__.py ============================================================================== --- python/branches/py3k-struni/Lib/logging/__init__.py (original) +++ python/branches/py3k-struni/Lib/logging/__init__.py Thu Jun 7 01:52:48 2007 @@ -66,7 +66,7 @@ try: raise Exception except: - return sys.exc_traceback.tb_frame.f_back + return sys.exc_info()[2].tb_frame.f_back if hasattr(sys, '_getframe'): currentframe = lambda: sys._getframe(3) # done filching Modified: python/branches/py3k-struni/Lib/logging/handlers.py ============================================================================== --- python/branches/py3k-struni/Lib/logging/handlers.py (original) +++ python/branches/py3k-struni/Lib/logging/handlers.py Thu Jun 7 01:52:48 2007 @@ -629,7 +629,8 @@ """ Initialize a handler. - If address is specified as a string, UNIX socket is used. + If address is specified as a string, a UNIX socket is used. To log to a + local syslogd, "SysLogHandler(address="/dev/log")" can be used. If facility is not specified, LOG_USER is used. """ logging.Handler.__init__(self) Deleted: /python/branches/py3k-struni/Lib/mimify.py ============================================================================== --- /python/branches/py3k-struni/Lib/mimify.py Thu Jun 7 01:52:48 2007 +++ (empty file) @@ -1,464 +0,0 @@ -#! /usr/bin/env python - -"""Mimification and unmimification of mail messages. - -Decode quoted-printable parts of a mail message or encode using -quoted-printable. - -Usage: - mimify(input, output) - unmimify(input, output, decode_base64 = 0) -to encode and decode respectively. Input and output may be the name -of a file or an open file object. Only a readline() method is used -on the input file, only a write() method is used on the output file. -When using file names, the input and output file names may be the -same. - -Interactive usage: - mimify.py -e [infile [outfile]] - mimify.py -d [infile [outfile]] -to encode and decode respectively. Infile defaults to standard -input and outfile to standard output. -""" - -# Configure -MAXLEN = 200 # if lines longer than this, encode as quoted-printable -CHARSET = 'ISO-8859-1' # default charset for non-US-ASCII mail -QUOTE = '> ' # string replies are quoted with -# End configure - -import re - -__all__ = ["mimify","unmimify","mime_encode_header","mime_decode_header"] - -qp = re.compile('^content-transfer-encoding:\\s*quoted-printable', re.I) -base64_re = re.compile('^content-transfer-encoding:\\s*base64', re.I) -mp = re.compile('^content-type:.*multipart/.*boundary="?([^;"\n]*)', re.I|re.S) -chrset = re.compile('^(content-type:.*charset=")(us-ascii|iso-8859-[0-9]+)(".*)', re.I|re.S) -he = re.compile('^-*\n') -mime_code = re.compile('=([0-9a-f][0-9a-f])', re.I) -mime_head = re.compile('=\\?iso-8859-1\\?q\\?([^? \t\n]+)\\?=', re.I) -repl = re.compile('^subject:\\s+re: ', re.I) - -class File: - """A simple fake file object that knows about limited read-ahead and - boundaries. The only supported method is readline().""" - - def __init__(self, file, boundary): - self.file = file - self.boundary = boundary - self.peek = None - - def readline(self): - if self.peek is not None: - return '' - line = self.file.readline() - if not line: - return line - if self.boundary: - if line == self.boundary + '\n': - self.peek = line - return '' - if line == self.boundary + '--\n': - self.peek = line - return '' - return line - -class HeaderFile: - def __init__(self, file): - self.file = file - self.peek = None - - def readline(self): - if self.peek is not None: - line = self.peek - self.peek = None - else: - line = self.file.readline() - if not line: - return line - if he.match(line): - return line - while 1: - self.peek = self.file.readline() - if len(self.peek) == 0 or \ - (self.peek[0] != ' ' and self.peek[0] != '\t'): - return line - line = line + self.peek - self.peek = None - -def mime_decode(line): - """Decode a single line of quoted-printable text to 8bit.""" - newline = '' - pos = 0 - while 1: - res = mime_code.search(line, pos) - if res is None: - break - newline = newline + line[pos:res.start(0)] + \ - chr(int(res.group(1), 16)) - pos = res.end(0) - return newline + line[pos:] - -def mime_decode_header(line): - """Decode a header line to 8bit.""" - newline = '' - pos = 0 - while 1: - res = mime_head.search(line, pos) - if res is None: - break - match = res.group(1) - # convert underscores to spaces (before =XX conversion!) - match = ' '.join(match.split('_')) - newline = newline + line[pos:res.start(0)] + mime_decode(match) - pos = res.end(0) - return newline + line[pos:] - -def unmimify_part(ifile, ofile, decode_base64 = 0): - """Convert a quoted-printable part of a MIME mail message to 8bit.""" - multipart = None - quoted_printable = 0 - is_base64 = 0 - is_repl = 0 - if ifile.boundary and ifile.boundary[:2] == QUOTE: - prefix = QUOTE - else: - prefix = '' - - # read header - hfile = HeaderFile(ifile) - while 1: - line = hfile.readline() - if not line: - return - if prefix and line[:len(prefix)] == prefix: - line = line[len(prefix):] - pref = prefix - else: - pref = '' - line = mime_decode_header(line) - if qp.match(line): - quoted_printable = 1 - continue # skip this header - if decode_base64 and base64_re.match(line): - is_base64 = 1 - continue - ofile.write(pref + line) - if not prefix and repl.match(line): - # we're dealing with a reply message - is_repl = 1 - mp_res = mp.match(line) - if mp_res: - multipart = '--' + mp_res.group(1) - if he.match(line): - break - if is_repl and (quoted_printable or multipart): - is_repl = 0 - - # read body - while 1: - line = ifile.readline() - if not line: - return - line = re.sub(mime_head, '\\1', line) - if prefix and line[:len(prefix)] == prefix: - line = line[len(prefix):] - pref = prefix - else: - pref = '' -## if is_repl and len(line) >= 4 and line[:4] == QUOTE+'--' and line[-3:] != '--\n': -## multipart = line[:-1] - while multipart: - if line == multipart + '--\n': - ofile.write(pref + line) - multipart = None - line = None - break - if line == multipart + '\n': - ofile.write(pref + line) - nifile = File(ifile, multipart) - unmimify_part(nifile, ofile, decode_base64) - line = nifile.peek - if not line: - # premature end of file - break - continue - # not a boundary between parts - break - if line and quoted_printable: - while line[-2:] == '=\n': - line = line[:-2] - newline = ifile.readline() - if newline[:len(QUOTE)] == QUOTE: - newline = newline[len(QUOTE):] - line = line + newline - line = mime_decode(line) - if line and is_base64 and not pref: - import base64 - line = base64.decodestring(line) - if line: - ofile.write(pref + line) - -def unmimify(infile, outfile, decode_base64 = 0): - """Convert quoted-printable parts of a MIME mail message to 8bit.""" - if type(infile) == type(''): - ifile = open(infile) - if type(outfile) == type('') and infile == outfile: - import os - d, f = os.path.split(infile) - os.rename(infile, os.path.join(d, ',' + f)) - else: - ifile = infile - if type(outfile) == type(''): - ofile = open(outfile, 'w') - else: - ofile = outfile - nifile = File(ifile, None) - unmimify_part(nifile, ofile, decode_base64) - ofile.flush() - -mime_char = re.compile('[=\177-\377]') # quote these chars in body -mime_header_char = re.compile('[=?\177-\377]') # quote these in header - -def mime_encode(line, header): - """Code a single line as quoted-printable. - If header is set, quote some extra characters.""" - if header: - reg = mime_header_char - else: - reg = mime_char - newline = '' - pos = 0 - if len(line) >= 5 and line[:5] == 'From ': - # quote 'From ' at the start of a line for stupid mailers - newline = ('=%02x' % ord('F')).upper() - pos = 1 - while 1: - res = reg.search(line, pos) - if res is None: - break - newline = newline + line[pos:res.start(0)] + \ - ('=%02x' % ord(res.group(0))).upper() - pos = res.end(0) - line = newline + line[pos:] - - newline = '' - while len(line) >= 75: - i = 73 - while line[i] == '=' or line[i-1] == '=': - i = i - 1 - i = i + 1 - newline = newline + line[:i] + '=\n' - line = line[i:] - return newline + line - -mime_header = re.compile('([ \t(]|^)([-a-zA-Z0-9_+]*[\177-\377][-a-zA-Z0-9_+\177-\377]*)(?=[ \t)]|\n)') - -def mime_encode_header(line): - """Code a single header line as quoted-printable.""" - newline = '' - pos = 0 - while 1: - res = mime_header.search(line, pos) - if res is None: - break - newline = '%s%s%s=?%s?Q?%s?=' % \ - (newline, line[pos:res.start(0)], res.group(1), - CHARSET, mime_encode(res.group(2), 1)) - pos = res.end(0) - return newline + line[pos:] - -mv = re.compile('^mime-version:', re.I) -cte = re.compile('^content-transfer-encoding:', re.I) -iso_char = re.compile('[\177-\377]') - -def mimify_part(ifile, ofile, is_mime): - """Convert an 8bit part of a MIME mail message to quoted-printable.""" - has_cte = is_qp = is_base64 = 0 - multipart = None - must_quote_body = must_quote_header = has_iso_chars = 0 - - header = [] - header_end = '' - message = [] - message_end = '' - # read header - hfile = HeaderFile(ifile) - while 1: - line = hfile.readline() - if not line: - break - if not must_quote_header and iso_char.search(line): - must_quote_header = 1 - if mv.match(line): - is_mime = 1 - if cte.match(line): - has_cte = 1 - if qp.match(line): - is_qp = 1 - elif base64_re.match(line): - is_base64 = 1 - mp_res = mp.match(line) - if mp_res: - multipart = '--' + mp_res.group(1) - if he.match(line): - header_end = line - break - header.append(line) - - # read body - while 1: - line = ifile.readline() - if not line: - break - if multipart: - if line == multipart + '--\n': - message_end = line - break - if line == multipart + '\n': - message_end = line - break - if is_base64: - message.append(line) - continue - if is_qp: - while line[-2:] == '=\n': - line = line[:-2] - newline = ifile.readline() - if newline[:len(QUOTE)] == QUOTE: - newline = newline[len(QUOTE):] - line = line + newline - line = mime_decode(line) - message.append(line) - if not has_iso_chars: - if iso_char.search(line): - has_iso_chars = must_quote_body = 1 - if not must_quote_body: - if len(line) > MAXLEN: - must_quote_body = 1 - - # convert and output header and body - for line in header: - if must_quote_header: - line = mime_encode_header(line) - chrset_res = chrset.match(line) - if chrset_res: - if has_iso_chars: - # change us-ascii into iso-8859-1 - if chrset_res.group(2).lower() == 'us-ascii': - line = '%s%s%s' % (chrset_res.group(1), - CHARSET, - chrset_res.group(3)) - else: - # change iso-8859-* into us-ascii - line = '%sus-ascii%s' % chrset_res.group(1, 3) - if has_cte and cte.match(line): - line = 'Content-Transfer-Encoding: ' - if is_base64: - line = line + 'base64\n' - elif must_quote_body: - line = line + 'quoted-printable\n' - else: - line = line + '7bit\n' - ofile.write(line) - if (must_quote_header or must_quote_body) and not is_mime: - ofile.write('Mime-Version: 1.0\n') - ofile.write('Content-Type: text/plain; ') - if has_iso_chars: - ofile.write('charset="%s"\n' % CHARSET) - else: - ofile.write('charset="us-ascii"\n') - if must_quote_body and not has_cte: - ofile.write('Content-Transfer-Encoding: quoted-printable\n') - ofile.write(header_end) - - for line in message: - if must_quote_body: - line = mime_encode(line, 0) - ofile.write(line) - ofile.write(message_end) - - line = message_end - while multipart: - if line == multipart + '--\n': - # read bit after the end of the last part - while 1: - line = ifile.readline() - if not line: - return - if must_quote_body: - line = mime_encode(line, 0) - ofile.write(line) - if line == multipart + '\n': - nifile = File(ifile, multipart) - mimify_part(nifile, ofile, 1) - line = nifile.peek - if not line: - # premature end of file - break - ofile.write(line) - continue - # unexpectedly no multipart separator--copy rest of file - while 1: - line = ifile.readline() - if not line: - return - if must_quote_body: - line = mime_encode(line, 0) - ofile.write(line) - -def mimify(infile, outfile): - """Convert 8bit parts of a MIME mail message to quoted-printable.""" - if type(infile) == type(''): - ifile = open(infile) - if type(outfile) == type('') and infile == outfile: - import os - d, f = os.path.split(infile) - os.rename(infile, os.path.join(d, ',' + f)) - else: - ifile = infile - if type(outfile) == type(''): - ofile = open(outfile, 'w') - else: - ofile = outfile - nifile = File(ifile, None) - mimify_part(nifile, ofile, 0) - ofile.flush() - -import sys -if __name__ == '__main__' or (len(sys.argv) > 0 and sys.argv[0] == 'mimify'): - import getopt - usage = 'Usage: mimify [-l len] -[ed] [infile [outfile]]' - - decode_base64 = 0 - opts, args = getopt.getopt(sys.argv[1:], 'l:edb') - if len(args) not in (0, 1, 2): - print(usage) - sys.exit(1) - if (('-e', '') in opts) == (('-d', '') in opts) or \ - ((('-b', '') in opts) and (('-d', '') not in opts)): - print(usage) - sys.exit(1) - for o, a in opts: - if o == '-e': - encode = mimify - elif o == '-d': - encode = unmimify - elif o == '-l': - try: - MAXLEN = int(a) - except (ValueError, OverflowError): - print(usage) - sys.exit(1) - elif o == '-b': - decode_base64 = 1 - if len(args) == 0: - encode_args = (sys.stdin, sys.stdout) - elif len(args) == 1: - encode_args = (args[0], sys.stdout) - else: - encode_args = (args[0], args[1]) - if decode_base64: - encode_args = encode_args + (decode_base64,) - encode(*encode_args) Modified: python/branches/py3k-struni/Lib/optparse.py ============================================================================== --- python/branches/py3k-struni/Lib/optparse.py (original) +++ python/branches/py3k-struni/Lib/optparse.py Thu Jun 7 01:52:48 2007 @@ -816,12 +816,6 @@ SUPPRESS_HELP = "SUPPRESS"+"HELP" SUPPRESS_USAGE = "SUPPRESS"+"USAGE" -# For compatibility with Python 2.2 -try: - True, False -except NameError: - (True, False) = (1, 0) - def isbasestring(x): return isinstance(x, basestring) Modified: python/branches/py3k-struni/Lib/os.py ============================================================================== --- python/branches/py3k-struni/Lib/os.py (original) +++ python/branches/py3k-struni/Lib/os.py Thu Jun 7 01:52:48 2007 @@ -388,13 +388,14 @@ else: envpath = defpath PATH = envpath.split(pathsep) - saved_exc = None + last_exc = saved_exc = None saved_tb = None for dir in PATH: fullname = path.join(dir, file) try: func(fullname, *argrest) except error as e: + last_exc = e tb = sys.exc_info()[2] if (e.errno != ENOENT and e.errno != ENOTDIR and saved_exc is None): @@ -402,7 +403,7 @@ saved_tb = tb if saved_exc: raise error, saved_exc, saved_tb - raise error, e, tb + raise error, last_exc, tb # Change environ to automatically call putenv() if it exists try: Modified: python/branches/py3k-struni/Lib/plat-mac/buildtools.py ============================================================================== --- python/branches/py3k-struni/Lib/plat-mac/buildtools.py (original) +++ python/branches/py3k-struni/Lib/plat-mac/buildtools.py Thu Jun 7 01:52:48 2007 @@ -13,6 +13,9 @@ import EasyDialogs import shutil +import warnings +warnings.warn("the buildtools module is deprecated", DeprecationWarning, 2) + BuildError = "BuildError" Deleted: /python/branches/py3k-struni/Lib/plat-mac/cfmfile.py ============================================================================== --- /python/branches/py3k-struni/Lib/plat-mac/cfmfile.py Thu Jun 7 01:52:48 2007 +++ (empty file) @@ -1,183 +0,0 @@ -"""codefragments.py -- wrapper to modify code fragments.""" - -# (c) 1998, Just van Rossum, Letterror - -__version__ = "0.8b3" -__author__ = "jvr" - -import Carbon.File -import struct -from Carbon import Res -import os -import sys - -DEBUG = 0 - -error = "cfm.error" - -BUFSIZE = 0x80000 - -def mergecfmfiles(srclist, dst, architecture = 'fat'): - """Merge all files in srclist into a new file dst. - - If architecture is given, only code fragments of that type will be used: - "pwpc" for PPC, "m68k" for cfm68k. This does not work for "classic" - 68k code, since it does not use code fragments to begin with. - If architecture is None, all fragments will be used, enabling FAT binaries. - """ - - srclist = list(srclist) - for i in range(len(srclist)): - srclist[i] = Carbon.File.pathname(srclist[i]) - dst = Carbon.File.pathname(dst) - - dstfile = open(dst, "wb") - rf = Res.FSpOpenResFile(dst, 3) - try: - dstcfrg = CfrgResource() - for src in srclist: - srccfrg = CfrgResource(src) - for frag in srccfrg.fragments: - if frag.architecture == 'pwpc' and architecture == 'm68k': - continue - if frag.architecture == 'm68k' and architecture == 'pwpc': - continue - dstcfrg.append(frag) - - frag.copydata(dstfile) - - cfrgres = Res.Resource(dstcfrg.build()) - Res.UseResFile(rf) - cfrgres.AddResource('cfrg', 0, "") - finally: - dstfile.close() - rf = Res.CloseResFile(rf) - - -class CfrgResource: - - def __init__(self, path = None): - self.version = 1 - self.fragments = [] - self.path = path - if path is not None and os.path.exists(path): - currentresref = Res.CurResFile() - resref = Res.FSpOpenResFile(path, 1) - Res.UseResFile(resref) - try: - try: - data = Res.Get1Resource('cfrg', 0).data - except Res.Error: - raise Res.Error, "no 'cfrg' resource found", sys.exc_traceback - finally: - Res.CloseResFile(resref) - Res.UseResFile(currentresref) - self.parse(data) - if self.version != 1: - raise error, "unknown 'cfrg' resource format" - - def parse(self, data): - (res1, res2, self.version, - res3, res4, res5, res6, - self.memberCount) = struct.unpack("8l", data[:32]) - data = data[32:] - while data: - frag = FragmentDescriptor(self.path, data) - data = data[frag.memberSize:] - self.fragments.append(frag) - - def build(self): - self.memberCount = len(self.fragments) - data = struct.pack("8l", 0, 0, self.version, 0, 0, 0, 0, self.memberCount) - for frag in self.fragments: - data = data + frag.build() - return data - - def append(self, frag): - self.fragments.append(frag) - - -class FragmentDescriptor: - - def __init__(self, path, data = None): - self.path = path - if data is not None: - self.parse(data) - - def parse(self, data): - self.architecture = data[:4] - ( self.updatelevel, - self.currentVersion, - self.oldDefVersion, - self.stacksize, - self.applibdir, - self.fragtype, - self.where, - self.offset, - self.length, - self.res1, self.res2, - self.memberSize,) = struct.unpack("4lhBB4lh", data[4:42]) - pname = data[42:self.memberSize] - self.name = pname[1:1+ord(pname[0])] - - def build(self): - data = self.architecture - data = data + struct.pack("4lhBB4l", - self.updatelevel, - self.currentVersion, - self.oldDefVersion, - self.stacksize, - self.applibdir, - self.fragtype, - self.where, - self.offset, - self.length, - self.res1, self.res2) - self.memberSize = len(data) + 2 + 1 + len(self.name) - # pad to 4 byte boundaries - if self.memberSize % 4: - self.memberSize = self.memberSize + 4 - (self.memberSize % 4) - data = data + struct.pack("hb", self.memberSize, len(self.name)) - data = data + self.name - data = data + '\000' * (self.memberSize - len(data)) - return data - - def getfragment(self): - if self.where != 1: - raise error, "can't read fragment, unsupported location" - f = open(self.path, "rb") - f.seek(self.offset) - if self.length: - frag = f.read(self.length) - else: - frag = f.read() - f.close() - return frag - - def copydata(self, outfile): - if self.where != 1: - raise error, "can't read fragment, unsupported location" - infile = open(self.path, "rb") - if self.length == 0: - infile.seek(0, 2) - self.length = infile.tell() - - # Position input file and record new offset from output file - infile.seek(self.offset) - - # pad to 16 byte boundaries - offset = outfile.tell() - if offset % 16: - offset = offset + 16 - (offset % 16) - outfile.seek(offset) - self.offset = offset - - l = self.length - while l: - if l > BUFSIZE: - outfile.write(infile.read(BUFSIZE)) - l = l - BUFSIZE - else: - outfile.write(infile.read(l)) - l = 0 - infile.close() Deleted: /python/branches/py3k-struni/Lib/posixfile.py ============================================================================== --- /python/branches/py3k-struni/Lib/posixfile.py Thu Jun 7 01:52:48 2007 +++ (empty file) @@ -1,237 +0,0 @@ -"""Extended file operations available in POSIX. - -f = posixfile.open(filename, [mode, [bufsize]]) - will create a new posixfile object - -f = posixfile.fileopen(fileobject) - will create a posixfile object from a builtin file object - -f.file() - will return the original builtin file object - -f.dup() - will return a new file object based on a new filedescriptor - -f.dup2(fd) - will return a new file object based on the given filedescriptor - -f.flags(mode) - will turn on the associated flag (merge) - mode can contain the following characters: - - (character representing a flag) - a append only flag - c close on exec flag - n no delay flag - s synchronization flag - (modifiers) - ! turn flags 'off' instead of default 'on' - = copy flags 'as is' instead of default 'merge' - ? return a string in which the characters represent the flags - that are set - - note: - the '!' and '=' modifiers are mutually exclusive. - - the '?' modifier will return the status of the flags after they - have been changed by other characters in the mode string - -f.lock(mode [, len [, start [, whence]]]) - will (un)lock a region - mode can contain the following characters: - - (character representing type of lock) - u unlock - r read lock - w write lock - (modifiers) - | wait until the lock can be granted - ? return the first lock conflicting with the requested lock - or 'None' if there is no conflict. The lock returned is in the - format (mode, len, start, whence, pid) where mode is a - character representing the type of lock ('r' or 'w') - - note: - the '?' modifier prevents a region from being locked; it is - query only -""" -import warnings -warnings.warn("The posixfile module is deprecated; " - "fcntl.lockf() provides better locking", DeprecationWarning, 2) - -class _posixfile_: - """File wrapper class that provides extra POSIX file routines.""" - - states = ['open', 'closed'] - - # - # Internal routines - # - def __repr__(self): - file = self._file_ - return "<%s posixfile '%s', mode '%s' at %s>" % \ - (self.states[file.closed], file.name, file.mode, \ - hex(id(self))[2:]) - - # - # Initialization routines - # - def open(self, name, mode='r', bufsize=-1): - import __builtin__ - return self.fileopen(__builtin__.open(name, mode, bufsize)) - - def fileopen(self, file): - import types - if repr(type(file)) != "": - raise TypeError, 'posixfile.fileopen() arg must be file object' - self._file_ = file - # Copy basic file methods - for maybemethod in dir(file): - if not maybemethod.startswith('_'): - attr = getattr(file, maybemethod) - if isinstance(attr, types.BuiltinMethodType): - setattr(self, maybemethod, attr) - return self - - # - # New methods - # - def file(self): - return self._file_ - - def dup(self): - import posix - - if not hasattr(posix, 'fdopen'): - raise AttributeError, 'dup() method unavailable' - - return posix.fdopen(posix.dup(self._file_.fileno()), self._file_.mode) - - def dup2(self, fd): - import posix - - if not hasattr(posix, 'fdopen'): - raise AttributeError, 'dup() method unavailable' - - posix.dup2(self._file_.fileno(), fd) - return posix.fdopen(fd, self._file_.mode) - - def flags(self, *which): - import fcntl, os - - if which: - if len(which) > 1: - raise TypeError, 'Too many arguments' - which = which[0] - else: which = '?' - - l_flags = 0 - if 'n' in which: l_flags = l_flags | os.O_NDELAY - if 'a' in which: l_flags = l_flags | os.O_APPEND - if 's' in which: l_flags = l_flags | os.O_SYNC - - file = self._file_ - - if '=' not in which: - cur_fl = fcntl.fcntl(file.fileno(), fcntl.F_GETFL, 0) - if '!' in which: l_flags = cur_fl & ~ l_flags - else: l_flags = cur_fl | l_flags - - l_flags = fcntl.fcntl(file.fileno(), fcntl.F_SETFL, l_flags) - - if 'c' in which: - arg = ('!' not in which) # 0 is don't, 1 is do close on exec - l_flags = fcntl.fcntl(file.fileno(), fcntl.F_SETFD, arg) - - if '?' in which: - which = '' # Return current flags - l_flags = fcntl.fcntl(file.fileno(), fcntl.F_GETFL, 0) - if os.O_APPEND & l_flags: which = which + 'a' - if fcntl.fcntl(file.fileno(), fcntl.F_GETFD, 0) & 1: - which = which + 'c' - if os.O_NDELAY & l_flags: which = which + 'n' - if os.O_SYNC & l_flags: which = which + 's' - return which - - def lock(self, how, *args): - import struct, fcntl - - if 'w' in how: l_type = fcntl.F_WRLCK - elif 'r' in how: l_type = fcntl.F_RDLCK - elif 'u' in how: l_type = fcntl.F_UNLCK - else: raise TypeError, 'no type of lock specified' - - if '|' in how: cmd = fcntl.F_SETLKW - elif '?' in how: cmd = fcntl.F_GETLK - else: cmd = fcntl.F_SETLK - - l_whence = 0 - l_start = 0 - l_len = 0 - - if len(args) == 1: - l_len = args[0] - elif len(args) == 2: - l_len, l_start = args - elif len(args) == 3: - l_len, l_start, l_whence = args - elif len(args) > 3: - raise TypeError, 'too many arguments' - - # Hack by davem at magnet.com to get locking to go on freebsd; - # additions for AIX by Vladimir.Marangozov at imag.fr - import sys, os - if sys.platform in ('netbsd1', - 'openbsd2', - 'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5', - 'freebsd6', 'freebsd7', - 'bsdos2', 'bsdos3', 'bsdos4'): - flock = struct.pack('lxxxxlxxxxlhh', \ - l_start, l_len, os.getpid(), l_type, l_whence) - elif sys.platform in ('aix3', 'aix4'): - flock = struct.pack('hhlllii', \ - l_type, l_whence, l_start, l_len, 0, 0, 0) - else: - flock = struct.pack('hhllhh', \ - l_type, l_whence, l_start, l_len, 0, 0) - - flock = fcntl.fcntl(self._file_.fileno(), cmd, flock) - - if '?' in how: - if sys.platform in ('netbsd1', - 'openbsd2', - 'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5', - 'bsdos2', 'bsdos3', 'bsdos4'): - l_start, l_len, l_pid, l_type, l_whence = \ - struct.unpack('lxxxxlxxxxlhh', flock) - elif sys.platform in ('aix3', 'aix4'): - l_type, l_whence, l_start, l_len, l_sysid, l_pid, l_vfs = \ - struct.unpack('hhlllii', flock) - elif sys.platform == "linux2": - l_type, l_whence, l_start, l_len, l_pid, l_sysid = \ - struct.unpack('hhllhh', flock) - else: - l_type, l_whence, l_start, l_len, l_sysid, l_pid = \ - struct.unpack('hhllhh', flock) - - if l_type != fcntl.F_UNLCK: - if l_type == fcntl.F_RDLCK: - return 'r', l_len, l_start, l_whence, l_pid - else: - return 'w', l_len, l_start, l_whence, l_pid - -def open(name, mode='r', bufsize=-1): - """Public routine to open a file as a posixfile object.""" - return _posixfile_().open(name, mode, bufsize) - -def fileopen(file): - """Public routine to get a posixfile object from a Python file object.""" - return _posixfile_().fileopen(file) - -# -# Constants -# -SEEK_SET = 0 -SEEK_CUR = 1 -SEEK_END = 2 - -# -# End of posixfile.py -# Modified: python/branches/py3k-struni/Lib/pydoc.py ============================================================================== --- python/branches/py3k-struni/Lib/pydoc.py (original) +++ python/branches/py3k-struni/Lib/pydoc.py Thu Jun 7 01:52:48 2007 @@ -271,12 +271,11 @@ # that inherits from another module that has changed). if forceload and path in sys.modules: if path not in sys.builtin_module_names: - # Avoid simply calling reload() because it leaves names in - # the currently loaded module lying around if they're not - # defined in the new source file. Instead, remove the - # module from sys.modules and re-import. Also remove any - # submodules because they won't appear in the newly loaded - # module's namespace if they're already in sys.modules. + # Remove the module from sys.modules and re-import to try + # and avoid problems with partially loaded modules. + # Also remove any submodules because they won't appear + # in the newly loaded module's namespace if they're already + # in sys.modules. subs = [m for m in sys.modules if m.startswith(path + '.')] for key in [path] + subs: # Prevent garbage collection. Deleted: /python/branches/py3k-struni/Lib/sha.py ============================================================================== --- /python/branches/py3k-struni/Lib/sha.py Thu Jun 7 01:52:48 2007 +++ (empty file) @@ -1,11 +0,0 @@ -# $Id$ -# -# Copyright (C) 2005 Gregory P. Smith (greg at electricrain.com) -# Licensed to PSF under a Contributor Agreement. - -from hashlib import sha1 as sha -new = sha - -blocksize = 1 # legacy value (wrong in any useful sense) -digest_size = 20 -digestsize = 20 Modified: python/branches/py3k-struni/Lib/shlex.py ============================================================================== --- python/branches/py3k-struni/Lib/shlex.py (original) +++ python/branches/py3k-struni/Lib/shlex.py Thu Jun 7 01:52:48 2007 @@ -268,8 +268,8 @@ raise StopIteration return token -def split(s, comments=False): - lex = shlex(s, posix=True) +def split(s, comments=False, posix=True): + lex = shlex(s, posix=posix) lex.whitespace_split = True if not comments: lex.commenters = '' Modified: python/branches/py3k-struni/Lib/subprocess.py ============================================================================== --- python/branches/py3k-struni/Lib/subprocess.py (original) +++ python/branches/py3k-struni/Lib/subprocess.py Thu Jun 7 01:52:48 2007 @@ -340,13 +340,6 @@ except: MAXFD = 256 -# True/False does not exist on 2.2.0 -try: - False -except NameError: - False = 0 - True = 1 - _active = [] def _cleanup(): @@ -479,9 +472,10 @@ if preexec_fn is not None: raise ValueError("preexec_fn is not supported on Windows " "platforms") - if close_fds: + if close_fds and (stdin is not None or stdout is not None or + stderr is not None): raise ValueError("close_fds is not supported on Windows " - "platforms") + "platforms if you redirect stdin/stdout/stderr") else: # POSIX if startupinfo is not None: @@ -740,9 +734,7 @@ hp, ht, pid, tid = CreateProcess(executable, args, # no special security None, None, - # must inherit handles to pass std - # handles - 1, + int(not close_fds), creationflags, env, cwd, Modified: python/branches/py3k-struni/Lib/tarfile.py ============================================================================== --- python/branches/py3k-struni/Lib/tarfile.py (original) +++ python/branches/py3k-struni/Lib/tarfile.py Thu Jun 7 01:52:48 2007 @@ -127,6 +127,17 @@ PAX_FIELDS = ("path", "linkpath", "size", "mtime", "uid", "gid", "uname", "gname") +# Fields in a pax header that are numbers, all other fields +# are treated as strings. +PAX_NUMBER_FIELDS = { + "atime": float, + "ctime": float, + "mtime": float, + "uid": int, + "gid": int, + "size": int +} + #--------------------------------------------------------- # Bits used in the mode field, values in octal. #--------------------------------------------------------- @@ -156,7 +167,7 @@ #--------------------------------------------------------- ENCODING = sys.getfilesystemencoding() if ENCODING is None: - ENCODING = "ascii" + ENCODING = sys.getdefaultencoding() #--------------------------------------------------------- # Some useful functions @@ -220,6 +231,26 @@ s = chr(0200) + s return s +def uts(s, encoding, errors): + """Convert a unicode object to a string. + """ + if errors == "utf-8": + # An extra error handler similar to the -o invalid=UTF-8 option + # in POSIX.1-2001. Replace untranslatable characters with their + # UTF-8 representation. + try: + return s.encode(encoding, "strict") + except UnicodeEncodeError: + x = [] + for c in s: + try: + x.append(c.encode(encoding, "strict")) + except UnicodeEncodeError: + x.append(c.encode("utf8")) + return "".join(x) + else: + return s.encode(encoding, errors) + def calc_chksums(buf): """Calculate the checksum for a member's header by summing up all characters except for the chksum field which is treated as if @@ -924,7 +955,7 @@ def __repr__(self): return "<%s %r at %#x>" % (self.__class__.__name__,self.name,id(self)) - def get_info(self): + def get_info(self, encoding, errors): """Return the TarInfo's attributes as a dictionary. """ info = { @@ -946,24 +977,29 @@ if info["type"] == DIRTYPE and not info["name"].endswith("/"): info["name"] += "/" + for key in ("name", "linkname", "uname", "gname"): + if type(info[key]) is unicode: + info[key] = info[key].encode(encoding, errors) + return info - def tobuf(self, format=DEFAULT_FORMAT, encoding=ENCODING): + def tobuf(self, format=DEFAULT_FORMAT, encoding=ENCODING, errors="strict"): """Return a tar header as a string of 512 byte blocks. """ + info = self.get_info(encoding, errors) + if format == USTAR_FORMAT: - return self.create_ustar_header() + return self.create_ustar_header(info) elif format == GNU_FORMAT: - return self.create_gnu_header() + return self.create_gnu_header(info) elif format == PAX_FORMAT: - return self.create_pax_header(encoding) + return self.create_pax_header(info, encoding, errors) else: raise ValueError("invalid format") - def create_ustar_header(self): + def create_ustar_header(self, info): """Return the object as a ustar header block. """ - info = self.get_info() info["magic"] = POSIX_MAGIC if len(info["linkname"]) > LENGTH_LINK: @@ -974,10 +1010,9 @@ return self._create_header(info, USTAR_FORMAT) - def create_gnu_header(self): + def create_gnu_header(self, info): """Return the object as a GNU header block sequence. """ - info = self.get_info() info["magic"] = GNU_MAGIC buf = "" @@ -989,12 +1024,11 @@ return buf + self._create_header(info, GNU_FORMAT) - def create_pax_header(self, encoding): + def create_pax_header(self, info, encoding, errors): """Return the object as a ustar header block. If it cannot be represented this way, prepend a pax extended header sequence with supplement information. """ - info = self.get_info() info["magic"] = POSIX_MAGIC pax_headers = self.pax_headers.copy() @@ -1004,7 +1038,11 @@ ("name", "path", LENGTH_NAME), ("linkname", "linkpath", LENGTH_LINK), ("uname", "uname", 32), ("gname", "gname", 32)): - val = info[name].decode(encoding) + if hname in pax_headers: + # The pax header has priority. + continue + + val = info[name].decode(encoding, errors) # Try to encode the string as ASCII. try: @@ -1013,27 +1051,23 @@ pax_headers[hname] = val continue - if len(val) > length: - if name == "name": - # Try to squeeze a longname in the prefix and name fields as in - # ustar format. - try: - info["prefix"], info["name"] = self._posix_split_name(info["name"]) - except ValueError: - pax_headers[hname] = val - else: - continue - else: - pax_headers[hname] = val + if len(info[name]) > length: + pax_headers[hname] = val # Test number fields for values that exceed the field limit or values # that like to be stored as float. for name, digits in (("uid", 8), ("gid", 8), ("size", 12), ("mtime", 12)): + if name in pax_headers: + # The pax header has priority. Avoid overflow. + info[name] = 0 + continue + val = info[name] if not 0 <= val < 8 ** (digits - 1) or isinstance(val, float): pax_headers[name] = str(val) info[name] = 0 + # Create a pax extended header if necessary. if pax_headers: buf = self._create_pax_generic_header(pax_headers) else: @@ -1042,26 +1076,10 @@ return buf + self._create_header(info, USTAR_FORMAT) @classmethod - def create_pax_global_header(cls, pax_headers, encoding): + def create_pax_global_header(cls, pax_headers): """Return the object as a pax global header block sequence. """ - new_headers = {} - for key, val in pax_headers.items(): - key = cls._to_unicode(key, encoding) - val = cls._to_unicode(val, encoding) - new_headers[key] = val - return cls._create_pax_generic_header(new_headers, type=XGLTYPE) - - @staticmethod - def _to_unicode(value, encoding): - if isinstance(value, str): - return value - elif isinstance(value, (int, float)): - return str(value) - elif isinstance(value, str): - return str(value, encoding) - else: - raise ValueError("unable to convert to unicode: %r" % value) + return cls._create_pax_generic_header(pax_headers, type=XGLTYPE) def _posix_split_name(self, name): """Split a name longer than 100 chars into a prefix @@ -1093,9 +1111,9 @@ " ", # checksum field info.get("type", REGTYPE), stn(info.get("linkname", ""), 100), - stn(info.get("magic", ""), 8), - stn(info.get("uname", ""), 32), - stn(info.get("gname", ""), 32), + stn(info.get("magic", POSIX_MAGIC), 8), + stn(info.get("uname", "root"), 32), + stn(info.get("gname", "root"), 32), itn(info.get("devmajor", 0), 8, format), itn(info.get("devminor", 0), 8, format), stn(info.get("prefix", ""), 155) @@ -1256,12 +1274,9 @@ offset += self._block(self.size) tarfile.offset = offset - # Patch the TarInfo object with saved extended + # Patch the TarInfo object with saved global # header information. - for keyword, value in tarfile.pax_headers.items(): - if keyword in PAX_FIELDS: - setattr(self, keyword, value) - self.pax_headers[keyword] = value + self._apply_pax_info(tarfile.pax_headers, tarfile.encoding, tarfile.errors) return self @@ -1272,18 +1287,17 @@ buf = tarfile.fileobj.read(self._block(self.size)) # Fetch the next header and process it. - b = tarfile.fileobj.read(BLOCKSIZE) - t = self.frombuf(b) - t.offset = self.offset - next = t._proc_member(tarfile) + next = self.fromtarfile(tarfile) + if next is None: + raise HeaderError("missing subsequent header") # Patch the TarInfo object from the next header with # the longname information. next.offset = self.offset if self.type == GNUTYPE_LONGNAME: - next.name = buf.rstrip(NUL) + next.name = nts(buf) elif self.type == GNUTYPE_LONGLINK: - next.linkname = buf.rstrip(NUL) + next.linkname = nts(buf) return next @@ -1358,21 +1372,10 @@ else: pax_headers = tarfile.pax_headers.copy() - # Fields in POSIX.1-2001 that are numbers, all other fields - # are treated as UTF-8 strings. - type_mapping = { - "atime": float, - "ctime": float, - "mtime": float, - "uid": int, - "gid": int, - "size": int - } - # Parse pax header information. A record looks like that: # "%d %s=%s\n" % (length, keyword, value). length is the size # of the complete record including the length field itself and - # the newline. + # the newline. keyword and value are both UTF-8 encoded strings. regex = re.compile(r"(\d+) ([^=]+)=", re.U) pos = 0 while True: @@ -1385,35 +1388,55 @@ value = buf[match.end(2) + 1:match.start(1) + length - 1] keyword = keyword.decode("utf8") - keyword = keyword.encode(tarfile.encoding) - value = value.decode("utf8") - if keyword in type_mapping: + + pax_headers[keyword] = value + pos += length + + # Fetch the next header. + next = self.fromtarfile(tarfile) + + if self.type in (XHDTYPE, SOLARIS_XHDTYPE): + if next is None: + raise HeaderError("missing subsequent header") + + # Patch the TarInfo object with the extended header info. + next._apply_pax_info(pax_headers, tarfile.encoding, tarfile.errors) + next.offset = self.offset + + if "size" in pax_headers: + # If the extended header replaces the size field, + # we need to recalculate the offset where the next + # header starts. + offset = next.offset_data + if next.isreg() or next.type not in SUPPORTED_TYPES: + offset += next._block(next.size) + tarfile.offset = offset + + return next + + def _apply_pax_info(self, pax_headers, encoding, errors): + """Replace fields with supplemental information from a previous + pax extended or global header. + """ + for keyword, value in pax_headers.items(): + if keyword not in PAX_FIELDS: + continue + + if keyword == "path": + value = value.rstrip("/") + + if keyword in PAX_NUMBER_FIELDS: try: - value = type_mapping[keyword](value) + value = PAX_NUMBER_FIELDS[keyword](value) except ValueError: value = 0 else: - value = value.encode(tarfile.encoding) - - pax_headers[keyword] = value - pos += length + value = uts(value, encoding, errors) - # Fetch the next header that will be patched with the - # supplement information from the pax header (extended - # only). - t = self.fromtarfile(tarfile) - - if self.type != XGLTYPE and t is not None: - # Patch the TarInfo object from the next header with - # the pax header's information. - for keyword, value in pax_headers.items(): - if keyword in PAX_FIELDS: - setattr(t, keyword, value) - pax_headers[keyword] = value - t.pax_headers = pax_headers.copy() + setattr(self, keyword, value) - return t + self.pax_headers = pax_headers.copy() def _block(self, count): """Round up a byte count by BLOCKSIZE and return it, @@ -1464,8 +1487,9 @@ format = DEFAULT_FORMAT # The format to use when creating an archive. - encoding = ENCODING # Transfer UTF-8 strings from POSIX.1-2001 - # headers to this encoding. + encoding = ENCODING # Encoding for 8-bit character strings. + + errors = None # Error handler for unicode conversion. tarinfo = TarInfo # The default TarInfo class to use. @@ -1473,7 +1497,7 @@ def __init__(self, name=None, mode="r", fileobj=None, format=None, tarinfo=None, dereference=None, ignore_zeros=None, encoding=None, - pax_headers=None, debug=None, errorlevel=None): + errors=None, pax_headers=None, debug=None, errorlevel=None): """Open an (uncompressed) tar archive `name'. `mode' is either 'r' to read from an existing archive, 'a' to append data to an existing file or 'w' to create a new file overwriting an existing one. `mode' @@ -1492,7 +1516,7 @@ # Create nonexistent files in append mode. self.mode = "w" self._mode = "wb" - fileobj = _open(name, self._mode) + fileobj = bltn_open(name, self._mode) self._extfileobj = False else: if name is None and hasattr(fileobj, "name"): @@ -1514,6 +1538,19 @@ self.ignore_zeros = ignore_zeros if encoding is not None: self.encoding = encoding + + if errors is not None: + self.errors = errors + elif mode == "r": + self.errors = "utf-8" + else: + self.errors = "strict" + + if pax_headers is not None and self.format == PAX_FORMAT: + self.pax_headers = pax_headers + else: + self.pax_headers = {} + if debug is not None: self.debug = debug if errorlevel is not None: @@ -1526,7 +1563,6 @@ self.offset = 0 # current position in the archive file self.inodes = {} # dictionary caching the inodes of # archive members already added - self.pax_headers = {} # save contents of global pax headers if self.mode == "r": self.firstmember = None @@ -1545,9 +1581,8 @@ if self.mode in "aw": self._loaded = True - if pax_headers: - buf = self.tarinfo.create_pax_global_header( - pax_headers.copy(), self.encoding) + if self.pax_headers: + buf = self.tarinfo.create_pax_global_header(self.pax_headers.copy()) self.fileobj.write(buf) self.offset += len(buf) @@ -1669,7 +1704,7 @@ raise CompressionError("gzip module is not available") if fileobj is None: - fileobj = _open(name, mode + "b") + fileobj = bltn_open(name, mode + "b") try: t = cls.taropen(name, mode, @@ -1819,8 +1854,6 @@ self.inodes[inode] = arcname elif stat.S_ISDIR(stmd): type = DIRTYPE - if arcname[-1:] != "/": - arcname += "/" elif stat.S_ISFIFO(stmd): type = FIFOTYPE elif stat.S_ISLNK(stmd): @@ -1930,7 +1963,7 @@ # Append the tar header and data to the archive. if tarinfo.isreg(): - f = _open(name, "rb") + f = bltn_open(name, "rb") self.addfile(tarinfo, f) f.close() @@ -1954,7 +1987,7 @@ tarinfo = copy.copy(tarinfo) - buf = tarinfo.tobuf(self.format, self.encoding) + buf = tarinfo.tobuf(self.format, self.encoding, self.errors) self.fileobj.write(buf) self.offset += len(buf) @@ -2141,7 +2174,7 @@ """Make a file called targetpath. """ source = self.extractfile(tarinfo) - target = _open(targetpath, "wb") + target = bltn_open(targetpath, "wb") copyfileobj(source, target) source.close() target.close() @@ -2483,4 +2516,5 @@ except TarError: return False +bltn_open = open open = TarFile.open Deleted: /python/branches/py3k-struni/Lib/test/infinite_reload.py ============================================================================== --- /python/branches/py3k-struni/Lib/test/infinite_reload.py Thu Jun 7 01:52:48 2007 +++ (empty file) @@ -1,7 +0,0 @@ -# For testing http://python.org/sf/742342, which reports that Python -# segfaults (infinite recursion in C) in the presence of infinite -# reload()ing. This module is imported by test_import.py:test_infinite_reload -# to make sure this doesn't happen any more. - -import infinite_reload -reload(infinite_reload) Modified: python/branches/py3k-struni/Lib/test/output/test_pkg ============================================================================== --- python/branches/py3k-struni/Lib/test/output/test_pkg (original) +++ python/branches/py3k-struni/Lib/test/output/test_pkg Thu Jun 7 01:52:48 2007 @@ -15,8 +15,6 @@ t3 loading t3.sub.subsub loading t3 t3.sub t3.sub.subsub -t3 loading -t3.sub.subsub loading running test t4 t4 loading t4.sub.subsub loading Modified: python/branches/py3k-struni/Lib/test/regrtest.py ============================================================================== --- python/branches/py3k-struni/Lib/test/regrtest.py (original) +++ python/branches/py3k-struni/Lib/test/regrtest.py Thu Jun 7 01:52:48 2007 @@ -669,7 +669,8 @@ indirect_test() else: def run_the_test(): - reload(the_module) + del sys.modules[the_module.__name__] + exec('import ' + the_module.__name__) deltas = [] nwarmup, ntracked, fname = huntrleaks @@ -841,7 +842,6 @@ test_signal test_sunaudiodev test_threadsignals - test_timing test_wait3 test_wait4 """, @@ -894,7 +894,6 @@ test_sunaudiodev test_sundry test_tarfile - test_timing """, 'unixware7': """ @@ -992,7 +991,6 @@ test_threaded_import test_threadedtempfile test_threading - test_timing """, 'darwin': """ Deleted: /python/branches/py3k-struni/Lib/test/test_MimeWriter.py ============================================================================== --- /python/branches/py3k-struni/Lib/test/test_MimeWriter.py Thu Jun 7 01:52:48 2007 +++ (empty file) @@ -1,291 +0,0 @@ -"""Test program for MimeWriter module. - -The test program was too big to comfortably fit in the MimeWriter -class, so it's here in its own file. - -This should generate Barry's example, modulo some quotes and newlines. - -""" - -import unittest, sys, StringIO -from test.test_support import run_unittest - -from MimeWriter import MimeWriter - -SELLER = '''\ -INTERFACE Seller-1; - -TYPE Seller = OBJECT - DOCUMENTATION "A simple Seller interface to test ILU" - METHODS - price():INTEGER, - END; -''' - -BUYER = '''\ -class Buyer: - def __setup__(self, maxprice): - self._maxprice = maxprice - - def __main__(self, kos): - """Entry point upon arrival at a new KOS.""" - broker = kos.broker() - # B4 == Barry's Big Bass Business :-) - seller = broker.lookup('Seller_1.Seller', 'B4') - if seller: - price = seller.price() - print 'Seller wants $', price, '... ' - if price > self._maxprice: - print 'too much!' - else: - print "I'll take it!" - else: - print 'no seller found here' -''' # Don't ask why this comment is here - -STATE = '''\ -# instantiate a buyer instance and put it in a magic place for the KOS -# to find. -__kp__ = Buyer() -__kp__.__setup__(500) -''' - -SIMPLE_METADATA = [ - ("Interpreter", "python"), - ("Interpreter-Version", "1.3"), - ("Owner-Name", "Barry Warsaw"), - ("Owner-Rendezvous", "bwarsaw at cnri.reston.va.us"), - ("Home-KSS", "kss.cnri.reston.va.us"), - ("Identifier", "hdl://cnri.kss/my_first_knowbot"), - ("Launch-Date", "Mon Feb 12 16:39:03 EST 1996"), - ] - -COMPLEX_METADATA = [ - ("Metadata-Type", "complex"), - ("Metadata-Key", "connection"), - ("Access", "read-only"), - ("Connection-Description", "Barry's Big Bass Business"), - ("Connection-Id", "B4"), - ("Connection-Direction", "client"), - ] - -EXTERNAL_METADATA = [ - ("Metadata-Type", "complex"), - ("Metadata-Key", "generic-interface"), - ("Access", "read-only"), - ("Connection-Description", "Generic Interface for All Knowbots"), - ("Connection-Id", "generic-kp"), - ("Connection-Direction", "client"), - ] - - -OUTPUT = '''\ -From: bwarsaw at cnri.reston.va.us -Date: Mon Feb 12 17:21:48 EST 1996 -To: kss-submit at cnri.reston.va.us -MIME-Version: 1.0 -Content-Type: multipart/knowbot; - boundary="801spam999"; - version="0.1" - -This is a multi-part message in MIME format. - ---801spam999 -Content-Type: multipart/knowbot-metadata; - boundary="802spam999" - - ---802spam999 -Content-Type: message/rfc822 -KP-Metadata-Type: simple -KP-Access: read-only - -KPMD-Interpreter: python -KPMD-Interpreter-Version: 1.3 -KPMD-Owner-Name: Barry Warsaw -KPMD-Owner-Rendezvous: bwarsaw at cnri.reston.va.us -KPMD-Home-KSS: kss.cnri.reston.va.us -KPMD-Identifier: hdl://cnri.kss/my_first_knowbot -KPMD-Launch-Date: Mon Feb 12 16:39:03 EST 1996 - ---802spam999 -Content-Type: text/isl -KP-Metadata-Type: complex -KP-Metadata-Key: connection -KP-Access: read-only -KP-Connection-Description: Barry's Big Bass Business -KP-Connection-Id: B4 -KP-Connection-Direction: client - -INTERFACE Seller-1; - -TYPE Seller = OBJECT - DOCUMENTATION "A simple Seller interface to test ILU" - METHODS - price():INTEGER, - END; - ---802spam999 -Content-Type: message/external-body; - access-type="URL"; - URL="hdl://cnri.kss/generic-knowbot" - -Content-Type: text/isl -KP-Metadata-Type: complex -KP-Metadata-Key: generic-interface -KP-Access: read-only -KP-Connection-Description: Generic Interface for All Knowbots -KP-Connection-Id: generic-kp -KP-Connection-Direction: client - - ---802spam999-- - ---801spam999 -Content-Type: multipart/knowbot-code; - boundary="803spam999" - - ---803spam999 -Content-Type: text/plain -KP-Module-Name: BuyerKP - -class Buyer: - def __setup__(self, maxprice): - self._maxprice = maxprice - - def __main__(self, kos): - """Entry point upon arrival at a new KOS.""" - broker = kos.broker() - # B4 == Barry's Big Bass Business :-) - seller = broker.lookup('Seller_1.Seller', 'B4') - if seller: - price = seller.price() - print 'Seller wants $', price, '... ' - if price > self._maxprice: - print 'too much!' - else: - print "I'll take it!" - else: - print 'no seller found here' - ---803spam999-- - ---801spam999 -Content-Type: multipart/knowbot-state; - boundary="804spam999" -KP-Main-Module: main - - ---804spam999 -Content-Type: text/plain -KP-Module-Name: main - -# instantiate a buyer instance and put it in a magic place for the KOS -# to find. -__kp__ = Buyer() -__kp__.__setup__(500) - ---804spam999-- - ---801spam999-- -''' - -class MimewriterTest(unittest.TestCase): - - def test(self): - buf = StringIO.StringIO() - - # Toplevel headers - - toplevel = MimeWriter(buf) - toplevel.addheader("From", "bwarsaw at cnri.reston.va.us") - toplevel.addheader("Date", "Mon Feb 12 17:21:48 EST 1996") - toplevel.addheader("To", "kss-submit at cnri.reston.va.us") - toplevel.addheader("MIME-Version", "1.0") - - # Toplevel body parts - - f = toplevel.startmultipartbody("knowbot", "801spam999", - [("version", "0.1")], prefix=0) - f.write("This is a multi-part message in MIME format.\n") - - # First toplevel body part: metadata - - md = toplevel.nextpart() - md.startmultipartbody("knowbot-metadata", "802spam999") - - # Metadata part 1 - - md1 = md.nextpart() - md1.addheader("KP-Metadata-Type", "simple") - md1.addheader("KP-Access", "read-only") - m = MimeWriter(md1.startbody("message/rfc822")) - for key, value in SIMPLE_METADATA: - m.addheader("KPMD-" + key, value) - m.flushheaders() - del md1 - - # Metadata part 2 - - md2 = md.nextpart() - for key, value in COMPLEX_METADATA: - md2.addheader("KP-" + key, value) - f = md2.startbody("text/isl") - f.write(SELLER) - del md2 - - # Metadata part 3 - - md3 = md.nextpart() - f = md3.startbody("message/external-body", - [("access-type", "URL"), - ("URL", "hdl://cnri.kss/generic-knowbot")]) - m = MimeWriter(f) - for key, value in EXTERNAL_METADATA: - md3.addheader("KP-" + key, value) - md3.startbody("text/isl") - # Phantom body doesn't need to be written - - md.lastpart() - - # Second toplevel body part: code - - code = toplevel.nextpart() - code.startmultipartbody("knowbot-code", "803spam999") - - # Code: buyer program source - - buyer = code.nextpart() - buyer.addheader("KP-Module-Name", "BuyerKP") - f = buyer.startbody("text/plain") - f.write(BUYER) - - code.lastpart() - - # Third toplevel body part: state - - state = toplevel.nextpart() - state.addheader("KP-Main-Module", "main") - state.startmultipartbody("knowbot-state", "804spam999") - - # State: a bunch of assignments - - st = state.nextpart() - st.addheader("KP-Module-Name", "main") - f = st.startbody("text/plain") - f.write(STATE) - - state.lastpart() - - # End toplevel body parts - - toplevel.lastpart() - - self.assertEqual(buf.getvalue(), OUTPUT) - -def test_main(): - run_unittest(MimewriterTest) - -if __name__ == '__main__': - test_main() Modified: python/branches/py3k-struni/Lib/test/test___all__.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test___all__.py (original) +++ python/branches/py3k-struni/Lib/test/test___all__.py Thu Jun 7 01:52:48 2007 @@ -1,7 +1,6 @@ import unittest from test.test_support import verbose, run_unittest import sys -import warnings class AllTest(unittest.TestCase): @@ -34,7 +33,6 @@ self.check_all("CGIHTTPServer") self.check_all("ConfigParser") self.check_all("Cookie") - self.check_all("MimeWriter") self.check_all("Queue") self.check_all("SimpleHTTPServer") self.check_all("SocketServer") @@ -92,7 +90,6 @@ self.check_all("mhlib") self.check_all("mimetools") self.check_all("mimetypes") - self.check_all("mimify") self.check_all("multifile") self.check_all("netrc") self.check_all("nntplib") Modified: python/branches/py3k-struni/Lib/test/test_builtin.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_builtin.py (original) +++ python/branches/py3k-struni/Lib/test/test_builtin.py Thu Jun 7 01:52:48 2007 @@ -1485,14 +1485,6 @@ fp.close() unlink(TESTFN) - def test_reload(self): - import marshal - reload(marshal) - import string - reload(string) - ## import sys - ## self.assertRaises(ImportError, reload, sys) - def test_repr(self): self.assertEqual(repr(''), '\'\'') self.assertEqual(repr(0), '0') Modified: python/branches/py3k-struni/Lib/test/test_dis.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_dis.py (original) +++ python/branches/py3k-struni/Lib/test/test_dis.py Thu Jun 7 01:52:48 2007 @@ -89,6 +89,18 @@ 7 RETURN_VALUE """ +dis_module_expected_results = """\ +Disassembly of f: + 4 0 LOAD_CONST 0 (None) + 3 RETURN_VALUE + +Disassembly of g: + 5 0 LOAD_CONST 0 (None) + 3 RETURN_VALUE + +""" + + class DisTests(unittest.TestCase): def do_disassembly_test(self, func, expected): s = StringIO.StringIO() @@ -127,6 +139,7 @@ self.do_disassembly_test(bug708901, dis_bug708901) def test_bug_1333982(self): + # XXX: re-enable this test! # This one is checking bytecodes generated for an `assert` statement, # so fails if the tests are run with -O. Skip this test then. pass # Test has been disabled due to change in the way @@ -153,9 +166,12 @@ expected = _BIG_LINENO_FORMAT % (i + 2) self.do_disassembly_test(func(i), expected) + def test_big_linenos(self): + from test import dis_module + self.do_disassembly_test(dis_module, dis_module_expected_results) + def test_main(): run_unittest(DisTests) - if __name__ == "__main__": test_main() Modified: python/branches/py3k-struni/Lib/test/test_doctest.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_doctest.py (original) +++ python/branches/py3k-struni/Lib/test/test_doctest.py Thu Jun 7 01:52:48 2007 @@ -2409,7 +2409,7 @@ def test_coverage(coverdir): tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,], trace=0, count=1) - tracer.run('reload(doctest); test_main()') + tracer.run('test_main()') r = tracer.results() print('Writing coverage results...') r.write_results(show_missing=True, summary=True, Modified: python/branches/py3k-struni/Lib/test/test_hmac.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_hmac.py (original) +++ python/branches/py3k-struni/Lib/test/test_hmac.py Thu Jun 7 01:52:48 2007 @@ -1,5 +1,5 @@ import hmac -import sha +from hashlib import sha1 import unittest from test import test_support @@ -43,7 +43,7 @@ def test_sha_vectors(self): def shatest(key, data, digest): - h = hmac.HMAC(key, data, digestmod=sha) + h = hmac.HMAC(key, data, digestmod=sha1) self.assertEqual(h.hexdigest().upper(), digest.upper()) shatest(chr(0x0b) * 20, @@ -95,11 +95,11 @@ def test_withmodule(self): # Constructor call with text and digest module. - import sha + from hashlib import sha1 try: - h = hmac.HMAC("key", "", sha) + h = hmac.HMAC("key", "", sha1) except: - self.fail("Constructor call with sha module raised exception.") + self.fail("Constructor call with hashlib.sha1 raised exception.") class SanityTestCase(unittest.TestCase): Modified: python/branches/py3k-struni/Lib/test/test_import.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_import.py (original) +++ python/branches/py3k-struni/Lib/test/test_import.py Thu Jun 7 01:52:48 2007 @@ -6,6 +6,7 @@ import sys import py_compile import warnings +from test.test_support import unlink def remove_files(name): @@ -63,22 +64,9 @@ self.assertEquals(mod.b, b, "module loaded (%s) but contents invalid" % mod) finally: - os.unlink(source) - - try: - try: - reload(mod) - except ImportError as err: - self.fail("import from .pyc/.pyo failed: %s" % err) - finally: - try: - os.unlink(pyc) - except OSError: - pass - try: - os.unlink(pyo) - except OSError: - pass + unlink(source) + unlink(pyc) + unlink(pyo) del sys.modules[TESTFN] sys.path.insert(0, os.curdir) @@ -136,6 +124,8 @@ # New in 2.4, we shouldn't be able to import that no matter how often # we try. sys.path.insert(0, os.curdir) + if TESTFN in sys.modules: + del sys.modules[TESTFN] try: for i in 1, 2, 3: try: @@ -149,60 +139,6 @@ sys.path.pop(0) remove_files(TESTFN) - def test_failing_reload(self): - # A failing reload should leave the module object in sys.modules. - source = TESTFN + os.extsep + "py" - f = open(source, "w") - print("a = 1", file=f) - print("b = 2", file=f) - f.close() - - sys.path.insert(0, os.curdir) - try: - mod = __import__(TESTFN) - self.assert_(TESTFN in sys.modules, "expected module in sys.modules") - self.assertEquals(mod.a, 1, "module has wrong attribute values") - self.assertEquals(mod.b, 2, "module has wrong attribute values") - - # On WinXP, just replacing the .py file wasn't enough to - # convince reload() to reparse it. Maybe the timestamp didn't - # move enough. We force it to get reparsed by removing the - # compiled file too. - remove_files(TESTFN) - - # Now damage the module. - f = open(source, "w") - print("a = 10", file=f) - print("b = 20//0", file=f) - f.close() - - self.assertRaises(ZeroDivisionError, reload, mod) - - # But we still expect the module to be in sys.modules. - mod = sys.modules.get(TESTFN) - self.failIf(mod is None, "expected module to still be in sys.modules") - - # We should have replaced a w/ 10, but the old b value should - # stick. - self.assertEquals(mod.a, 10, "module has wrong attribute values") - self.assertEquals(mod.b, 2, "module has wrong attribute values") - - finally: - sys.path.pop(0) - remove_files(TESTFN) - if TESTFN in sys.modules: - del sys.modules[TESTFN] - - def test_infinite_reload(self): - # Bug #742342 reports that Python segfaults (infinite recursion in C) - # when faced with self-recursive reload()ing. - - sys.path.insert(0, os.path.dirname(__file__)) - try: - import infinite_reload - finally: - sys.path.pop(0) - def test_import_name_binding(self): # import x.y.z binds x in the current namespace import test as x Modified: python/branches/py3k-struni/Lib/test/test_importhooks.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_importhooks.py (original) +++ python/branches/py3k-struni/Lib/test/test_importhooks.py Thu Jun 7 01:52:48 2007 @@ -190,10 +190,6 @@ import reloadmodule self.failIf(hasattr(reloadmodule,'reloaded')) - TestImporter.modules['reloadmodule'] = (False, reload_co) - reload(reloadmodule) - self.failUnless(hasattr(reloadmodule,'reloaded')) - import hooktestpackage.newrel self.assertEqual(hooktestpackage.newrel.get_name(), "hooktestpackage.newrel") Modified: python/branches/py3k-struni/Lib/test/test_inspect.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_inspect.py (original) +++ python/branches/py3k-struni/Lib/test/test_inspect.py Thu Jun 7 01:52:48 2007 @@ -26,7 +26,7 @@ try: 1/0 except: - tb = sys.exc_traceback + tb = sys.exc_info()[2] git = mod.StupidGit() Modified: python/branches/py3k-struni/Lib/test/test_optparse.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_optparse.py (original) +++ python/branches/py3k-struni/Lib/test/test_optparse.py Thu Jun 7 01:52:48 2007 @@ -27,12 +27,6 @@ from optparse import _match_abbrev from optparse import _parse_num -# Do the right thing with boolean values for all known Python versions. -try: - True, False -except NameError: - (True, False) = (1, 0) - retype = type(re.compile('')) class InterceptedError(Exception): Modified: python/branches/py3k-struni/Lib/test/test_os.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_os.py (original) +++ python/branches/py3k-struni/Lib/test/test_os.py Thu Jun 7 01:52:48 2007 @@ -381,7 +381,7 @@ os.remove(dirname) os.rmdir(test_support.TESTFN) -class MakedirTests (unittest.TestCase): +class MakedirTests(unittest.TestCase): def setUp(self): os.mkdir(test_support.TESTFN) @@ -400,9 +400,6 @@ 'dir5', 'dir6') os.makedirs(path) - - - def tearDown(self): path = os.path.join(test_support.TESTFN, 'dir1', 'dir2', 'dir3', 'dir4', 'dir5', 'dir6') @@ -414,7 +411,7 @@ os.removedirs(path) -class DevNullTests (unittest.TestCase): +class DevNullTests(unittest.TestCase): def test_devnull(self): f = open(os.devnull, 'w') f.write('hello') @@ -423,7 +420,7 @@ self.assertEqual(f.read(), '') f.close() -class URandomTests (unittest.TestCase): +class URandomTests(unittest.TestCase): def test_urandom(self): try: self.assertEqual(len(os.urandom(1)), 1) @@ -433,6 +430,10 @@ except NotImplementedError: pass +class ExecTests(unittest.TestCase): + def test_execvpe_with_bad_program(self): + self.assertRaises(OSError, os.execvpe, 'no such app-', [], None) + class Win32ErrorTests(unittest.TestCase): def test_rename(self): self.assertRaises(WindowsError, os.rename, test_support.TESTFN, test_support.TESTFN+".bak") @@ -469,6 +470,7 @@ MakedirTests, DevNullTests, URandomTests, + ExecTests, Win32ErrorTests ) Modified: python/branches/py3k-struni/Lib/test/test_pkg.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_pkg.py (original) +++ python/branches/py3k-struni/Lib/test/test_pkg.py Thu Jun 7 01:52:48 2007 @@ -120,9 +120,6 @@ """ import t3.sub.subsub print(t3.__name__, t3.sub.__name__, t3.sub.subsub.__name__) -reload(t3) -reload(t3.sub) -reload(t3.sub.subsub) """), ("t4", [ Modified: python/branches/py3k-struni/Lib/test/test_subprocess.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_subprocess.py (original) +++ python/branches/py3k-struni/Lib/test/test_subprocess.py Thu Jun 7 01:52:48 2007 @@ -604,8 +604,16 @@ self.assertRaises(ValueError, subprocess.call, [sys.executable, "-c", "import sys; sys.exit(47)"], + stdout=subprocess.PIPE, close_fds=True) + def test_close_fds(self): + # close file descriptors + rc = subprocess.call([sys.executable, "-c", + "import sys; sys.exit(47)"], + close_fds=True) + self.assertEqual(rc, 47) + def test_shell_sequence(self): # Run command through the shell (sequence) newenv = os.environ.copy() Modified: python/branches/py3k-struni/Lib/test/test_sundry.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_sundry.py (original) +++ python/branches/py3k-struni/Lib/test/test_sundry.py Thu Jun 7 01:52:48 2007 @@ -4,9 +4,6 @@ import warnings with guard_warnings_filter(): - warnings.filterwarnings('ignore', r".*posixfile", - DeprecationWarning) - from test.test_support import verbose import BaseHTTPServer @@ -33,7 +30,6 @@ import linecache import macurl2path import mailcap - import mimify import mutex import nntplib import nturl2path @@ -42,7 +38,6 @@ import pdb import pipes #import poplib - import posixfile import pstats import py_compile import pydoc Modified: python/branches/py3k-struni/Lib/test/test_syntax.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_syntax.py (original) +++ python/branches/py3k-struni/Lib/test/test_syntax.py Thu Jun 7 01:52:48 2007 @@ -27,15 +27,13 @@ Errors from set_context(): -TODO(jhylton): "assignment to None" is inconsistent with other messages - >>> obj.None = 1 Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: invalid syntax >>> None = 1 Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: assignment to keyword (, line 1) It's a syntax error to assign to the empty tuple. Why isn't it an error to assign to the empty list? It will always raise some error at @@ -95,7 +93,7 @@ >>> def f(None=1): ... pass Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: invalid syntax From ast_for_arguments(): @@ -108,17 +106,17 @@ >>> def f(x, None): ... pass Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: invalid syntax >>> def f(*None): ... pass Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: invalid syntax >>> def f(**None): ... pass Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: invalid syntax From ast_for_funcdef(): @@ -126,7 +124,7 @@ >>> def None(x): ... pass Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: invalid syntax From ast_for_call(): @@ -231,7 +229,7 @@ SyntaxError: augmented assignment to generator expression not possible (, line 1) >>> None += 1 Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: assignment to keyword (, line 1) >>> f() += 1 Traceback (most recent call last): SyntaxError: illegal expression for augmented assignment (, line 1) Modified: python/branches/py3k-struni/Lib/test/test_sys.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_sys.py (original) +++ python/branches/py3k-struni/Lib/test/test_sys.py Thu Jun 7 01:52:48 2007 @@ -63,47 +63,6 @@ # FIXME: testing the code for a lost or replaced excepthook in # Python/pythonrun.c::PyErr_PrintEx() is tricky. - def test_exc_clear(self): - self.assertRaises(TypeError, sys.exc_clear, 42) - - # Verify that exc_info is present and matches exc, then clear it, and - # check that it worked. - def clear_check(exc): - typ, value, traceback = sys.exc_info() - self.assert_(typ is not None) - self.assert_(value is exc) - self.assert_(traceback is not None) - - sys.exc_clear() - - typ, value, traceback = sys.exc_info() - self.assert_(typ is None) - self.assert_(value is None) - self.assert_(traceback is None) - - def clear(): - try: - raise ValueError, 42 - except ValueError as exc: - clear_check(exc) - - # Raise an exception and check that it can be cleared - clear() - - # Verify that a frame currently handling an exception is - # unaffected by calling exc_clear in a nested frame. - try: - raise ValueError, 13 - except ValueError as exc: - typ1, value1, traceback1 = sys.exc_info() - clear() - typ2, value2, traceback2 = sys.exc_info() - - self.assert_(typ1 is typ2) - self.assert_(value1 is exc) - self.assert_(value1 is value2) - self.assert_(traceback1 is traceback2) - def test_exit(self): self.assertRaises(TypeError, sys.exit, 42, 42) Modified: python/branches/py3k-struni/Lib/test/test_tarfile.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_tarfile.py (original) +++ python/branches/py3k-struni/Lib/test/test_tarfile.py Thu Jun 7 01:52:48 2007 @@ -1,4 +1,4 @@ -# encoding: iso8859-1 +# -*- coding: iso-8859-15 -*- import sys import os @@ -372,9 +372,9 @@ def test_read_longname(self): # Test reading of longname (bug #1471427). - name = self.subdir + "/" + "123/" * 125 + "longname" + longname = self.subdir + "/" + "123/" * 125 + "longname" try: - tarinfo = self.tar.getmember(name) + tarinfo = self.tar.getmember(longname) except KeyError: self.fail("longname not found") self.assert_(tarinfo.type != tarfile.DIRTYPE, "read longname as dirtype") @@ -393,13 +393,24 @@ tarinfo = self.tar.getmember(longname) offset = tarinfo.offset self.tar.fileobj.seek(offset) - fobj = StringIO.StringIO(self.tar.fileobj.read(1536)) + fobj = StringIO.StringIO(self.tar.fileobj.read(3 * 512)) self.assertRaises(tarfile.ReadError, tarfile.open, name="foo.tar", fileobj=fobj) + def test_header_offset(self): + # Test if the start offset of the TarInfo object includes + # the preceding extended header. + longname = self.subdir + "/" + "123/" * 125 + "longname" + offset = self.tar.getmember(longname).offset + fobj = open(tarname) + fobj.seek(offset) + tarinfo = tarfile.TarInfo.frombuf(fobj.read(512)) + self.assertEqual(tarinfo.type, self.longnametype) + class GNUReadTest(LongnameTest): subdir = "gnu" + longnametype = tarfile.GNUTYPE_LONGNAME def test_sparse_file(self): tarinfo1 = self.tar.getmember("ustar/sparse") @@ -410,26 +421,40 @@ "sparse file extraction failed") -class PaxReadTest(ReadTest): +class PaxReadTest(LongnameTest): subdir = "pax" + longnametype = tarfile.XHDTYPE - def test_pax_globheaders(self): + def test_pax_global_headers(self): tar = tarfile.open(tarname, encoding="iso8859-1") + tarinfo = tar.getmember("pax/regtype1") self.assertEqual(tarinfo.uname, "foo") self.assertEqual(tarinfo.gname, "bar") - self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), "???????") + self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), u"???????") tarinfo = tar.getmember("pax/regtype2") self.assertEqual(tarinfo.uname, "") self.assertEqual(tarinfo.gname, "bar") - self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), "???????") + self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), u"???????") tarinfo = tar.getmember("pax/regtype3") self.assertEqual(tarinfo.uname, "tarfile") self.assertEqual(tarinfo.gname, "tarfile") - self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), "???????") + self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), u"???????") + + def test_pax_number_fields(self): + # All following number fields are read from the pax header. + tar = tarfile.open(tarname, encoding="iso8859-1") + tarinfo = tar.getmember("pax/regtype4") + self.assertEqual(tarinfo.size, 7011) + self.assertEqual(tarinfo.uid, 123) + self.assertEqual(tarinfo.gid, 123) + self.assertEqual(tarinfo.mtime, 1041808783.0) + self.assertEqual(type(tarinfo.mtime), float) + self.assertEqual(float(tarinfo.pax_headers["atime"]), 1041808783.0) + self.assertEqual(float(tarinfo.pax_headers["ctime"]), 1041808783.0) class WriteTest(unittest.TestCase): @@ -700,68 +725,160 @@ n = tar.getmembers()[0].name self.assert_(name == n, "PAX longname creation failed") - def test_iso8859_15_filename(self): - self._test_unicode_filename("iso8859-15") + def test_pax_global_header(self): + pax_headers = { + u"foo": u"bar", + u"uid": u"0", + u"mtime": u"1.23", + u"test": u"???", + u"???": u"test"} + + tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT, \ + pax_headers=pax_headers) + tar.addfile(tarfile.TarInfo("test")) + tar.close() + + # Test if the global header was written correctly. + tar = tarfile.open(tmpname, encoding="iso8859-1") + self.assertEqual(tar.pax_headers, pax_headers) + self.assertEqual(tar.getmembers()[0].pax_headers, pax_headers) + + # Test if all the fields are unicode. + for key, val in tar.pax_headers.items(): + self.assert_(type(key) is unicode) + self.assert_(type(val) is unicode) + if key in tarfile.PAX_NUMBER_FIELDS: + try: + tarfile.PAX_NUMBER_FIELDS[key](val) + except (TypeError, ValueError): + self.fail("unable to convert pax header field") + + def test_pax_extended_header(self): + # The fields from the pax header have priority over the + # TarInfo. + pax_headers = {u"path": u"foo", u"uid": u"123"} + + tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT, encoding="iso8859-1") + t = tarfile.TarInfo() + t.name = u"???" # non-ASCII + t.uid = 8**8 # too large + t.pax_headers = pax_headers + tar.addfile(t) + tar.close() + + tar = tarfile.open(tmpname, encoding="iso8859-1") + t = tar.getmembers()[0] + self.assertEqual(t.pax_headers, pax_headers) + self.assertEqual(t.name, "foo") + self.assertEqual(t.uid, 123) + + +class UstarUnicodeTest(unittest.TestCase): + # All *UnicodeTests FIXME + + format = tarfile.USTAR_FORMAT + + def test_iso8859_1_filename(self): + self._test_unicode_filename("iso8859-1") + + def test_utf7_filename(self): + self._test_unicode_filename("utf7") def test_utf8_filename(self): self._test_unicode_filename("utf8") - def test_utf16_filename(self): - self._test_unicode_filename("utf16") - def _test_unicode_filename(self, encoding): - tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT) - name = "\u20ac".encode(encoding) # Euro sign - tar.encoding = encoding + tar = tarfile.open(tmpname, "w", format=self.format, encoding=encoding, errors="strict") + name = "???" tar.addfile(tarfile.TarInfo(name)) tar.close() tar = tarfile.open(tmpname, encoding=encoding) - self.assertEqual(tar.getmembers()[0].name, name) + self.assert_(type(tar.getnames()[0]) is not unicode) + self.assertEqual(tar.getmembers()[0].name, name.encode(encoding)) tar.close() def test_unicode_filename_error(self): - # The euro sign filename cannot be translated to iso8859-1 encoding. - tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT, encoding="utf8") - name = "\u20ac".encode("utf8") # Euro sign - tar.addfile(tarfile.TarInfo(name)) + tar = tarfile.open(tmpname, "w", format=self.format, encoding="ascii", errors="strict") + tarinfo = tarfile.TarInfo() + + tarinfo.name = "???" + if self.format == tarfile.PAX_FORMAT: + self.assertRaises(UnicodeError, tar.addfile, tarinfo) + else: + tar.addfile(tarinfo) + + tarinfo.name = u"???" + self.assertRaises(UnicodeError, tar.addfile, tarinfo) + + tarinfo.name = "foo" + tarinfo.uname = u"???" + self.assertRaises(UnicodeError, tar.addfile, tarinfo) + + def test_unicode_argument(self): + tar = tarfile.open(tarname, "r", encoding="iso8859-1", errors="strict") + for t in tar: + self.assert_(type(t.name) is str) + self.assert_(type(t.linkname) is str) + self.assert_(type(t.uname) is str) + self.assert_(type(t.gname) is str) tar.close() - self.assertRaises(UnicodeError, tarfile.open, tmpname, encoding="iso8859-1") + def test_uname_unicode(self): + for name in (u"???", "???"): + t = tarfile.TarInfo("foo") + t.uname = name + t.gname = name - def test_pax_headers(self): - self._test_pax_headers({"foo": "bar", "uid": 0, "mtime": 1.23}) + fobj = StringIO.StringIO() + tar = tarfile.open("foo.tar", mode="w", fileobj=fobj, format=self.format, encoding="iso8859-1") + tar.addfile(t) + tar.close() + fobj.seek(0) - self._test_pax_headers({"euro": "\u20ac".encode("utf8")}) + tar = tarfile.open("foo.tar", fileobj=fobj, encoding="iso8859-1") + t = tar.getmember("foo") + self.assertEqual(t.uname, "???") + self.assertEqual(t.gname, "???") - self._test_pax_headers({"euro": "\u20ac"}, - {"euro": "\u20ac".encode("utf8")}) +class GNUUnicodeTest(UstarUnicodeTest): - self._test_pax_headers({"\u20ac": "euro"}, - {"\u20ac".encode("utf8"): "euro"}) + format = tarfile.GNU_FORMAT - def _test_pax_headers(self, pax_headers, cmp_headers=None): - if cmp_headers is None: - cmp_headers = pax_headers - tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT, \ - pax_headers=pax_headers, encoding="utf8") - tar.addfile(tarfile.TarInfo("test")) - tar.close() +class PaxUnicodeTest(UstarUnicodeTest): - tar = tarfile.open(tmpname, encoding="utf8") - self.assertEqual(tar.pax_headers, cmp_headers) + format = tarfile.PAX_FORMAT - def test_truncated_header(self): - tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT) - tarinfo = tarfile.TarInfo("123/" * 126 + "longname") - tar.addfile(tarinfo) + def _create_unicode_name(self, name): + tar = tarfile.open(tmpname, "w", format=self.format) + t = tarfile.TarInfo() + t.pax_headers["path"] = name + tar.addfile(t) tar.close() - # Simulate a premature EOF. - open(tmpname, "rb+").truncate(1536) - tar = tarfile.open(tmpname) - self.assertEqual(tar.getmembers(), []) + def test_error_handlers(self): + # Test if the unicode error handlers work correctly for characters + # that cannot be expressed in a given encoding. + self._create_unicode_name(u"???") + + for handler, name in (("utf-8", u"???".encode("utf8")), + ("replace", "???"), ("ignore", "")): + tar = tarfile.open(tmpname, format=self.format, encoding="ascii", + errors=handler) + self.assertEqual(tar.getnames()[0], name) + + self.assertRaises(UnicodeError, tarfile.open, tmpname, + encoding="ascii", errors="strict") + + def test_error_handler_utf8(self): + # Create a pathname that has one component representable using + # iso8859-1 and the other only in iso8859-15. + self._create_unicode_name(u"???/?") + + tar = tarfile.open(tmpname, format=self.format, encoding="iso8859-1", + errors="utf-8") + self.assertEqual(tar.getnames()[0], "???/" + u"?".encode("utf8")) class AppendTest(unittest.TestCase): @@ -836,63 +953,58 @@ def test_ustar_limits(self): # 100 char name tarinfo = tarfile.TarInfo("0123456789" * 10) - tarinfo.create_ustar_header() + tarinfo.tobuf(tarfile.USTAR_FORMAT) # 101 char name that cannot be stored tarinfo = tarfile.TarInfo("0123456789" * 10 + "0") - self.assertRaises(ValueError, tarinfo.create_ustar_header) + self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT) # 256 char name with a slash at pos 156 tarinfo = tarfile.TarInfo("123/" * 62 + "longname") - tarinfo.create_ustar_header() + tarinfo.tobuf(tarfile.USTAR_FORMAT) # 256 char name that cannot be stored tarinfo = tarfile.TarInfo("1234567/" * 31 + "longname") - self.assertRaises(ValueError, tarinfo.create_ustar_header) + self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT) # 512 char name tarinfo = tarfile.TarInfo("123/" * 126 + "longname") - self.assertRaises(ValueError, tarinfo.create_ustar_header) + self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT) # 512 char linkname tarinfo = tarfile.TarInfo("longlink") tarinfo.linkname = "123/" * 126 + "longname" - self.assertRaises(ValueError, tarinfo.create_ustar_header) + self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT) # uid > 8 digits tarinfo = tarfile.TarInfo("name") tarinfo.uid = 010000000 - self.assertRaises(ValueError, tarinfo.create_ustar_header) + self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT) def test_gnu_limits(self): tarinfo = tarfile.TarInfo("123/" * 126 + "longname") - tarinfo.create_gnu_header() + tarinfo.tobuf(tarfile.GNU_FORMAT) tarinfo = tarfile.TarInfo("longlink") tarinfo.linkname = "123/" * 126 + "longname" - tarinfo.create_gnu_header() + tarinfo.tobuf(tarfile.GNU_FORMAT) # uid >= 256 ** 7 tarinfo = tarfile.TarInfo("name") tarinfo.uid = 04000000000000000000 - self.assertRaises(ValueError, tarinfo.create_gnu_header) + self.assertRaises(ValueError, tarinfo.tobuf, tarfile.GNU_FORMAT) def test_pax_limits(self): - # A 256 char name that can be stored without an extended header. - tarinfo = tarfile.TarInfo("123/" * 62 + "longname") - self.assert_(len(tarinfo.create_pax_header("utf8")) == 512, - "create_pax_header attached superfluous extended header") - tarinfo = tarfile.TarInfo("123/" * 126 + "longname") - tarinfo.create_pax_header("utf8") + tarinfo.tobuf(tarfile.PAX_FORMAT) tarinfo = tarfile.TarInfo("longlink") tarinfo.linkname = "123/" * 126 + "longname" - tarinfo.create_pax_header("utf8") + tarinfo.tobuf(tarfile.PAX_FORMAT) tarinfo = tarfile.TarInfo("name") tarinfo.uid = 04000000000000000000 - tarinfo.create_pax_header("utf8") + tarinfo.tobuf(tarfile.PAX_FORMAT) class GzipMiscReadTest(MiscReadTest): @@ -940,6 +1052,9 @@ StreamWriteTest, GNUWriteTest, PaxWriteTest, + UstarUnicodeTest, + GNUUnicodeTest, + PaxUnicodeTest, AppendTest, LimitsTest, ] Modified: python/branches/py3k-struni/Lib/test/test_tokenize.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_tokenize.py (original) +++ python/branches/py3k-struni/Lib/test/test_tokenize.py Thu Jun 7 01:52:48 2007 @@ -19,7 +19,7 @@ >>> dump_tokens("if False:\\n" ... " # NL\\n" -... " True = False # NEWLINE\\n") +... " a = False # NEWLINE\\n") NAME 'if' (1, 0) (1, 2) NAME 'False' (1, 3) (1, 8) OP ':' (1, 8) (1, 9) @@ -27,7 +27,7 @@ COMMENT '# NL' (2, 4) (2, 8) NL '\\n' (2, 8) (2, 9) INDENT ' ' (3, 0) (3, 4) -NAME 'True' (3, 4) (3, 8) +NAME 'a' (3, 4) (3, 5) OP '=' (3, 9) (3, 10) NAME 'False' (3, 11) (3, 16) COMMENT '# NEWLINE' (3, 17) (3, 26) Modified: python/branches/py3k-struni/Lib/test/test_traceback.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_traceback.py (original) +++ python/branches/py3k-struni/Lib/test/test_traceback.py Thu Jun 7 01:52:48 2007 @@ -52,58 +52,13 @@ self.assert_("^" in err[2]) self.assert_(err[1].find(")") == err[2].find("^")) - def test_bug737473(self): - import sys, os, tempfile, time - - savedpath = sys.path[:] - testdir = tempfile.mkdtemp() - try: - sys.path.insert(0, testdir) - testfile = os.path.join(testdir, 'test_bug737473.py') - print(""" -def test(): - raise ValueError""", file=open(testfile, 'w')) - - if 'test_bug737473' in sys.modules: - del sys.modules['test_bug737473'] - import test_bug737473 - - try: - test_bug737473.test() - except ValueError: - # this loads source code to linecache - traceback.extract_tb(sys.exc_traceback) - - # If this test runs too quickly, test_bug737473.py's mtime - # attribute will remain unchanged even if the file is rewritten. - # Consequently, the file would not reload. So, added a sleep() - # delay to assure that a new, distinct timestamp is written. - # Since WinME with FAT32 has multisecond resolution, more than - # three seconds are needed for this test to pass reliably :-( - time.sleep(4) - - print(""" -def test(): - raise NotImplementedError""", file=open(testfile, 'w')) - reload(test_bug737473) - try: - test_bug737473.test() - except NotImplementedError: - src = traceback.extract_tb(sys.exc_traceback)[-1][-1] - self.failUnlessEqual(src, 'raise NotImplementedError') - finally: - sys.path[:] = savedpath - for f in os.listdir(testdir): - os.unlink(os.path.join(testdir, f)) - os.rmdir(testdir) - def test_members(self): # Covers Python/structmember.c::listmembers() try: 1/0 except: import sys - sys.exc_traceback.__members__ + sys.exc_info()[2].__members__ def test_base_exception(self): # Test that exceptions derived from BaseException are formatted right Modified: python/branches/py3k-struni/Lib/test/test_urllib.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_urllib.py (original) +++ python/branches/py3k-struni/Lib/test/test_urllib.py Thu Jun 7 01:52:48 2007 @@ -8,6 +8,10 @@ import mimetools import tempfile import StringIO +import ftplib +import threading +import socket +import time def hexescape(char): """Escape char as RFC 2396 specifies""" @@ -541,6 +545,76 @@ "url2pathname() failed; %s != %s" % (expect, result)) +# Just commented them out. +# Can't really tell why keep failing in windows and sparc. +# Everywhere else they work ok, but on those machines, someteimes +# fail in one of the tests, sometimes in other. I have a linux, and +# the tests go ok. +# If anybody has one of the problematic enviroments, please help! +# . Facundo +# +# def server(evt): +# serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +# serv.settimeout(3) +# serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) +# serv.bind(("", 9093)) +# serv.listen(5) +# try: +# conn, addr = serv.accept() +# conn.send("1 Hola mundo\n") +# cantdata = 0 +# while cantdata < 13: +# data = conn.recv(13-cantdata) +# cantdata += len(data) +# time.sleep(.3) +# conn.send("2 No more lines\n") +# conn.close() +# except socket.timeout: +# pass +# finally: +# serv.close() +# evt.set() +# +# class FTPWrapperTests(unittest.TestCase): +# +# def setUp(self): +# ftplib.FTP.port = 9093 +# self.evt = threading.Event() +# threading.Thread(target=server, args=(self.evt,)).start() +# time.sleep(.1) +# +# def tearDown(self): +# self.evt.wait() +# +# def testBasic(self): +# # connects +# ftp = urllib.ftpwrapper("myuser", "mypass", "localhost", 9093, []) +# ftp.ftp.sock.close() +# +# def testTimeoutDefault(self): +# # default +# ftp = urllib.ftpwrapper("myuser", "mypass", "localhost", 9093, []) +# self.assertTrue(ftp.ftp.sock.gettimeout() is None) +# ftp.ftp.sock.close() +# +# def testTimeoutValue(self): +# # a value +# ftp = urllib.ftpwrapper("myuser", "mypass", "localhost", 9093, [], timeout=30) +# self.assertEqual(ftp.ftp.sock.gettimeout(), 30) +# ftp.ftp.sock.close() +# +# def testTimeoutNone(self): +# # None, having other default +# previous = socket.getdefaulttimeout() +# socket.setdefaulttimeout(30) +# try: +# ftp = urllib.ftpwrapper("myuser", "mypass", "localhost", 9093, []) +# finally: +# socket.setdefaulttimeout(previous) +# self.assertEqual(ftp.ftp.sock.gettimeout(), 30) +# ftp.ftp.close() +# + def test_main(): @@ -551,7 +625,8 @@ QuotingTests, UnquotingTests, urlencode_Tests, - Pathname_Tests + Pathname_Tests, + #FTPWrapperTests, ) Modified: python/branches/py3k-struni/Lib/test/test_xmlrpc.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_xmlrpc.py (original) +++ python/branches/py3k-struni/Lib/test/test_xmlrpc.py Thu Jun 7 01:52:48 2007 @@ -17,7 +17,7 @@ 'ashortlong': 2, 'anotherlist': ['.zyx.41'], 'abase64': xmlrpclib.Binary("my dog has fleas"), - 'boolean': xmlrpclib.False, + 'boolean': False, 'unicode': '\u4000\u6000\u8000', 'ukey\u4000': 'regular value', 'datetime1': xmlrpclib.DateTime('20050210T11:41:23'), @@ -133,10 +133,11 @@ """ # sys.setdefaultencoding() normally doesn't exist after site.py is - # loaded. reload(sys) is the way to get it back. + # loaded. Re-initializing sys again is the way to get it back. :-( old_encoding = sys.getdefaultencoding() setdefaultencoding_existed = hasattr(sys, "setdefaultencoding") - reload(sys) # ugh! + import imp + imp.init_builtin('sys') sys.setdefaultencoding("iso-8859-1") try: (s, d), m = xmlrpclib.loads(utf8) Modified: python/branches/py3k-struni/Lib/test/testtar.tar ============================================================================== Binary files. No diff available. Modified: python/branches/py3k-struni/Lib/textwrap.py ============================================================================== --- python/branches/py3k-struni/Lib/textwrap.py (original) +++ python/branches/py3k-struni/Lib/textwrap.py Thu Jun 7 01:52:48 2007 @@ -9,14 +9,6 @@ import string, re -# Do the right thing with boolean values for all known Python versions -# (so this module can be copied to projects that don't depend on Python -# 2.3, e.g. Optik and Docutils). -try: - True, False -except NameError: - (True, False) = (1, 0) - __all__ = ['TextWrapper', 'wrap', 'fill'] # Hardcode the recognized whitespace characters to the US-ASCII Modified: python/branches/py3k-struni/Lib/unittest.py ============================================================================== --- python/branches/py3k-struni/Lib/unittest.py (original) +++ python/branches/py3k-struni/Lib/unittest.py Thu Jun 7 01:52:48 2007 @@ -65,22 +65,6 @@ ############################################################################## -# Backward compatibility -############################################################################## -if sys.version_info[:2] < (2, 2): - False, True = 0, 1 - def isinstance(obj, clsinfo): - import __builtin__ - if type(clsinfo) in (tuple, list): - for cls in clsinfo: - if cls is type: cls = types.ClassType - if __builtin__.isinstance(obj, cls): - return 1 - return 0 - else: return __builtin__.isinstance(obj, clsinfo) - - -############################################################################## # Test framework core ############################################################################## Modified: python/branches/py3k-struni/Lib/urllib.py ============================================================================== --- python/branches/py3k-struni/Lib/urllib.py (original) +++ python/branches/py3k-struni/Lib/urllib.py Thu Jun 7 01:52:48 2007 @@ -805,19 +805,20 @@ class ftpwrapper: """Class used by open_ftp() for cache of open FTP connections.""" - def __init__(self, user, passwd, host, port, dirs): + def __init__(self, user, passwd, host, port, dirs, timeout=None): self.user = user self.passwd = passwd self.host = host self.port = port self.dirs = dirs + self.timeout = timeout self.init() def init(self): import ftplib self.busy = 0 self.ftp = ftplib.FTP() - self.ftp.connect(self.host, self.port) + self.ftp.connect(self.host, self.port, self.timeout) self.ftp.login(self.user, self.passwd) for dir in self.dirs: self.ftp.cwd(dir) Modified: python/branches/py3k-struni/Lib/uuid.py ============================================================================== --- python/branches/py3k-struni/Lib/uuid.py (original) +++ python/branches/py3k-struni/Lib/uuid.py Thu Jun 7 01:52:48 2007 @@ -535,8 +535,8 @@ def uuid3(namespace, name): """Generate a UUID from the MD5 hash of a namespace UUID and a name.""" - import hashlib - hash = hashlib.md5(namespace.bytes + name).digest() + from hashlib import md5 + hash = md5(namespace.bytes + name).digest() return UUID(bytes=hash[:16], version=3) def uuid4(): @@ -558,8 +558,8 @@ def uuid5(namespace, name): """Generate a UUID from the SHA-1 hash of a namespace UUID and a name.""" - import sha - hash = sha.sha(namespace.bytes + name).digest() + from hashlib import sha1 + hash = sha1(namespace.bytes + name).digest() return UUID(bytes=hash[:16], version=5) # The following standard UUIDs are for use with uuid3() or uuid5(). Modified: python/branches/py3k-struni/Lib/wsgiref/handlers.py ============================================================================== --- python/branches/py3k-struni/Lib/wsgiref/handlers.py (original) +++ python/branches/py3k-struni/Lib/wsgiref/handlers.py Thu Jun 7 01:52:48 2007 @@ -8,23 +8,6 @@ __all__ = ['BaseHandler', 'SimpleHandler', 'BaseCGIHandler', 'CGIHandler'] -try: - dict -except NameError: - def dict(items): - d = {} - for k,v in items: - d[k] = v - return d - -try: - True - False -except NameError: - True = not None - False = not True - - # Weekday and month names for HTTP date/time formatting; always English! _weekdayname = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] _monthname = [None, # Dummy so we can use 1-based month numbers Modified: python/branches/py3k-struni/Lib/xmlrpclib.py ============================================================================== --- python/branches/py3k-struni/Lib/xmlrpclib.py (original) +++ python/branches/py3k-struni/Lib/xmlrpclib.py Thu Jun 7 01:52:48 2007 @@ -274,8 +274,6 @@ # all other values are interpreted as False. boolean = Boolean = bool -# to avoid breaking code which references xmlrpclib.{True,False} -True, False = True, False ## # Wrapper for XML-RPC DateTime values. This converts a time value to Modified: python/branches/py3k-struni/Misc/BeOS-setup.py ============================================================================== --- python/branches/py3k-struni/Misc/BeOS-setup.py (original) +++ python/branches/py3k-struni/Misc/BeOS-setup.py Thu Jun 7 01:52:48 2007 @@ -168,8 +168,6 @@ if platform in ['Darwin1.2', 'beos']: math_libs = [] - # XXX Omitted modules: gl, pure, dl, SGI-specific modules - # # The following modules are all pretty straightforward, and compile # on pretty much any POSIXish platform. @@ -242,9 +240,6 @@ # Lance Ellinghaus's syslog daemon interface exts.append( Extension('syslog', ['syslogmodule.c']) ) - # George Neville-Neil's timing module: - exts.append( Extension('timing', ['timingmodule.c']) ) - # # Here ends the simple stuff. From here on, modules need certain # libraries, are platform-specific, or present other surprises. @@ -340,15 +335,8 @@ if self.compiler.find_library_file(lib_dirs, 'db'): dblib = ['db'] - db185_incs = find_file('db_185.h', inc_dirs, - ['/usr/include/db3', '/usr/include/db2']) db_inc = find_file('db.h', inc_dirs, ['/usr/include/db1']) - if db185_incs is not None: - exts.append( Extension('bsddb', ['bsddbmodule.c'], - include_dirs = db185_incs, - define_macros=[('HAVE_DB_185_H',1)], - libraries = dblib ) ) - elif db_inc is not None: + db_inc is not None: exts.append( Extension('bsddb', ['bsddbmodule.c'], include_dirs = db_inc, libraries = dblib) ) Modified: python/branches/py3k-struni/Misc/NEWS ============================================================================== --- python/branches/py3k-struni/Misc/NEWS (original) +++ python/branches/py3k-struni/Misc/NEWS Thu Jun 7 01:52:48 2007 @@ -26,6 +26,8 @@ Core and Builtins ----------------- +- None, True, False are now keywords. + - PEP 3119: isinstance() and issubclass() can be overridden. - Remove BaseException.message. @@ -137,7 +139,7 @@ backticks (ie, `x`), <> - Removed these Python builtins: - apply(), callable(), coerce(), file(), reduce() + apply(), callable(), coerce(), file(), reduce(), reload() - Removed these Python methods: {}.has_key @@ -163,6 +165,7 @@ - Removed these attributes from Python modules: * operator module: div, idiv, __div__, __idiv__, isCallable, sequenceIncludes + * sys module: exc_clear(), exc_type, exc_value, exc_traceback Library @@ -172,8 +175,8 @@ AST -> bytecode mechanism. - Removed these modules: - * Bastion, bsddb185, exceptions, md5, popen2, rexec, - sets, sha, stringold, strop, xmllib + * Bastion, bsddb185, exceptions, md5, MimeWriter, mimify, popen2, rexec, + sets, sha, stringold, strop, timing, xmllib. - Remove obsolete IRIX modules: al/AL, cd/CD, cddb, cdplayer, cl/CL, DEVICE, ERRNO, FILE, fl/FL, flp, fm, GET, gl/GL, GLWS, IN, imgfile, IOCTL, jpeg, @@ -223,6 +226,9 @@ Mac --- +- The cfmfile was removed. + + New platforms ------------- Modified: python/branches/py3k-struni/Misc/build.sh ============================================================================== --- python/branches/py3k-struni/Misc/build.sh (original) +++ python/branches/py3k-struni/Misc/build.sh Thu Jun 7 01:52:48 2007 @@ -170,6 +170,7 @@ start=`current_time` make install >& build/$F update_status "Installing" "$F" $start + mail_on_failure "install" build/$F if [ ! -x $PYTHON ]; then ln -s ${PYTHON}3.* $PYTHON Modified: python/branches/py3k-struni/Misc/cheatsheet ============================================================================== --- python/branches/py3k-struni/Misc/cheatsheet (original) +++ python/branches/py3k-struni/Misc/cheatsheet Thu Jun 7 01:52:48 2007 @@ -41,6 +41,7 @@ -h print this help message and exit -i Inspect interactively after running script (also PYTHONINSPECT=x) and force prompts, even if stdin appears not to be a terminal +-m mod run library module as a script (terminates option list -O optimize generated bytecode (a tad; also PYTHONOPTIMIZE=x) -OO remove doc-strings in addition to the -O optimizations -Q arg division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew @@ -926,7 +927,6 @@ abs(x) Return the absolute value of number x. bool(x) Returns True when the argument x is true and False otherwise. buffer(obj) Creates a buffer reference to an object. -callable(x) Returns True if x callable, else False. chr(i) Returns one-character string whose ASCII code isinteger i classmethod(f) Converts a function f, into a method with the class as the first argument. Useful for creating alternative constructors. @@ -934,14 +934,14 @@ compile(string, from which the code was read, or eg. ''if not read filename, kind) from file.kind can be 'eval' if string is a single stmt, or 'single' which prints the output of expression statements - thatevaluate to something else than None, or be 'exec'. + that evaluate to something else than None, or be 'exec'. complex(real[, Builds a complex object (can also be done using J or j image]) suffix,e.g. 1+3J) delattr(obj, name) deletes attribute named name of object obj <=> del obj.name If no args, returns the list of names in current dict([items]) Create a new dictionary from the specified item list. -dir([object]) localsymbol table. With a module, class or class - instanceobject as arg, returns list of names in its attr. +dir([object]) local symbol table. With a module, class or class + instance object as arg, returns list of names in its attr. dict. divmod(a,b) Returns tuple of (a/b, a%b) enumerate(seq) Return a iterator giving: (0, seq[0]), (1, seq[1]), ... @@ -956,7 +956,7 @@ float(x) Converts a number or a string to floating point. getattr(object, [ arg added in 1.5.2]Gets attribute called name name[, default])) from object,e.g. getattr(x, 'f') <=> x.f). If not found, - raisesAttributeError or returns default if specified. + raises AttributeError or returns default if specified. globals() Returns a dictionary containing current global variables. hasattr(object, Returns true if object has attr called name. name) @@ -966,9 +966,7 @@ id(object) Returns a unique 'identity' integer for an object. int(x[, base]) base paramenter specifies base from which to convert string values. -intern(aString) Enters aString in the table of "interned strings" - andreturns the string. Interned strings are 'immortals'. -isinstance(obj, returns true if obj is an instance of class. Ifissubclass +isinstance(obj, Returns true if obj is an instance of class. Ifissubclass class) (A,B) then isinstance(x,A) => isinstance(x,B) issubclass(class1, returns true if class1 is derived from class2 class2) @@ -1001,26 +999,24 @@ [, buffering]]) pow(x, y [, z]) Returns x to power y [modulo z]. See also ** operator. property() Created a property with access controlled by functions. -range(start [,end Returns list of ints from >= start and < end.With 1 arg, -[, step]]) list from 0..arg-1With 2 args, list from start..end-1With 3 - args, list from start up to end by step -reload(module) after fixing it. If module was syntacticallycorrect but had - an error in initialization, mustimport it one more time - before calling reload(). - Returns a string containing a printable and if possible -repr(object) evaluable representation of an object. +range(start [,end Returns list of ints from >= start and < end. With 1 arg, +[, step]]) list from 0..arg-1. With 2 args, list from start..end-1. + With 3 args, list from start up to end by step + after fixing it. +repr(object) Returns a string containing a printable and if possible + evaluable representation of an object. Class redefinable (__repr__). See also str(). round(x, n=0) Returns the floating point value x rounded to n digitsafter the decimal point. -setattr(object, This is the counterpart of getattr().setattr(o, 'foobar', -name, value) 3) <=> o.foobar = 3Creates attribute if it doesn't exist! +setattr(object, This is the counterpart of getattr(). setattr(o, 'foobar', +name, value) 3) <=> o.foobar = 3. Creates attribute if it doesn't exist! slice([start,] stop Returns a slice object representing a range, with R/ -[, step]) Oattributes: start, stop, step. - Returns a string containing a nicely +[, step]) O attributes: start, stop, step. staticmethod() Convert a function to method with no self or class argument. Useful for methods associated with a class that do not need access to an object's internal state. -str(object) printablerepresentation of an object. Class overridable +str(object) Returns a string containing a nicely + printable representation of an object. Class overridable (__str__).See also repr(). super(type) Create an unbound super object. Used to call cooperative superclass methods. @@ -1042,12 +1038,8 @@ vars([object]) instance object as argumentreturns a dictionary corresponding to the object'ssymbol table. Useful with "%" formatting operator. -xrange(start [, end Like range(), but doesn't actually store entire listall at -[, step]]) once. Good to use in "for" loops when there is abig range - and little memory. -zip(seq1[, seq2, Returns a list of tuples where each tuple contains the nth -...]) element of each of the argument sequences. - +zip(seq1[, seq2, Returns an iterator of tuples where each tuple contains +...]) the nth element of each of the argument sequences. @@ -1314,10 +1306,6 @@ in C that are linked into this interpreter. check_interval How often to check for thread switches or signals(measured in number of virtual machine instructions) -exc_type, exc_value, Deprecated since release 1.5. Use exc_info() instead. -exc_traceback -exitfunc User can set to a parameterless fcn. It will getcalled - before interpreter exits. last_type, Set only when an exception not handled andinterpreter last_value, prints an error. Used by debuggers. last_traceback @@ -1350,7 +1338,7 @@ setprofile(func) Sets a profile function for performance profiling. Info on exception currently being handled; this is atuple (exc_type, exc_value, exc_traceback).Warning: assigning the -exc_info() traceback return value to a loca variable in a +exc_info() traceback return value to a local variable in a function handling an exception will cause a circular reference. setdefaultencoding Change default Unicode encoding - defaults to 7-bit ASCII. @@ -1857,7 +1845,6 @@ dumbdbm A dumb and slow but simple dbm clone. [DEL:dump:DEL] [DEL:Print python code that reconstructs a variable.:DEL] email Comprehensive support for internet email. -exceptions Class based built-in exception hierarchy. filecmp File comparison. fileinput Helper class to quickly write a loop over all standard input files. @@ -1872,7 +1859,6 @@ www.pauahtun.org/pub/getargspy.zip getpass Utilities to get a password and/or the current user name. glob filename globbing. -gopherlib Gopher protocol client interface. [DEL:grep:DEL] [DEL:'grep' utilities.:DEL] gzip Read & write gzipped files. heapq Priority queue implemented using lists organized as heaps. @@ -1887,7 +1873,6 @@ imputil Privides a way of writing customised import hooks. inspect Tool for probing live Python objects. keyword List of Python keywords. -knee A Python re-implementation of hierarchical module import. linecache Cache lines from files. linuxaudiodev Lunix /dev/audio support. locale Support for number formatting using the current locale @@ -1900,8 +1885,6 @@ mhlib MH (mailbox) interface. mimetools Various tools used by MIME-reading or MIME-writing programs. mimetypes Guess the MIME type of a file. -MimeWriter Generic MIME writer. -mimify Mimification and unmimification of mail messages. mmap Interface to memory-mapped files - they behave like mutable strings./font> multifile Class to make multi-file messages easier to handle. @@ -1920,7 +1903,6 @@ pipes Conversion pipeline templates. pkgunil Utilities for working with Python packages. poplib A POP3 client class. Based on the J. Myers POP3 draft. -posixfile Extended (posix) file operations. posixpath Common operations on POSIX pathnames. pprint Support to pretty-print lists, tuples, & dictionaries recursively. @@ -1933,7 +1915,6 @@ pyclbr Parse a Python file and retrieve classes and methods. Queue A multi-producer, multi-consumer queue. quopri Conversions to/from quoted-printable transport encoding. -rand Don't use unless you want compatibility with C's rand(). random Random variable generators re Regular Expressions. repr Redo repr() but with limits on most sizes. @@ -1942,7 +1923,6 @@ rlcompleter Word completion for GNU readline 2.0. robotparser Parse robots.txt files, useful for web spiders. sched A generally useful event scheduler class. -sets Module for a set datatype. sgmllib A parser for SGML. shelve Manage shelves of pickled objects. shlex Lexical analyzer class for simple shell-like syntaxes. @@ -1954,7 +1934,6 @@ sndhdr Several routines that help recognizing sound. SocketServer Generic socket server classes. stat Constants and functions for interpreting stat/lstat struct. -statcache Maintain a cache of file stats. statvfs Constants for interpreting statvfs struct as returned by os.statvfs()and os.fstatvfs() (if they exist). string A collection of string operations. Modified: python/branches/py3k-struni/Modules/Setup.dist ============================================================================== --- python/branches/py3k-struni/Modules/Setup.dist (original) +++ python/branches/py3k-struni/Modules/Setup.dist Thu Jun 7 01:52:48 2007 @@ -247,11 +247,6 @@ #linuxaudiodev linuxaudiodev.c -# George Neville-Neil's timing module: - -#timing timingmodule.c - - # The _tkinter module. # # The command for _tkinter is long and site specific. Please Modified: python/branches/py3k-struni/Modules/_ctypes/callbacks.c ============================================================================== --- python/branches/py3k-struni/Modules/_ctypes/callbacks.c (original) +++ python/branches/py3k-struni/Modules/_ctypes/callbacks.c Thu Jun 7 01:52:48 2007 @@ -385,8 +385,8 @@ } { - PyObject *py_rclsid = PyLong_FromVoidPtr(rclsid); - PyObject *py_riid = PyLong_FromVoidPtr(riid); + PyObject *py_rclsid = PyLong_FromVoidPtr((void *)rclsid); + PyObject *py_riid = PyLong_FromVoidPtr((void *)riid); PyObject *py_ppv = PyLong_FromVoidPtr(ppv); if (!py_rclsid || !py_riid || !py_ppv) { Py_XDECREF(py_rclsid); Deleted: /python/branches/py3k-struni/Modules/md5.c ============================================================================== --- /python/branches/py3k-struni/Modules/md5.c Thu Jun 7 01:52:48 2007 +++ (empty file) @@ -1,381 +0,0 @@ -/* - Copyright (C) 1999, 2000, 2002 Aladdin Enterprises. All rights reserved. - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - L. Peter Deutsch - ghost at aladdin.com - - */ -/* $Id: md5.c,v 1.6 2002/04/13 19:20:28 lpd Exp $ */ -/* - Independent implementation of MD5 (RFC 1321). - - This code implements the MD5 Algorithm defined in RFC 1321, whose - text is available at - http://www.ietf.org/rfc/rfc1321.txt - The code is derived from the text of the RFC, including the test suite - (section A.5) but excluding the rest of Appendix A. It does not include - any code or documentation that is identified in the RFC as being - copyrighted. - - The original and principal author of md5.c is L. Peter Deutsch - . Other authors are noted in the change history - that follows (in reverse chronological order): - - 2002-04-13 lpd Clarified derivation from RFC 1321; now handles byte order - either statically or dynamically; added missing #include - in library. - 2002-03-11 lpd Corrected argument list for main(), and added int return - type, in test program and T value program. - 2002-02-21 lpd Added missing #include in test program. - 2000-07-03 lpd Patched to eliminate warnings about "constant is - unsigned in ANSI C, signed in traditional"; made test program - self-checking. - 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. - 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5). - 1999-05-03 lpd Original version. - */ - -#include "md5.h" -#include - -#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */ -#ifdef ARCH_IS_BIG_ENDIAN -# define BYTE_ORDER (ARCH_IS_BIG_ENDIAN ? 1 : -1) -#else -# define BYTE_ORDER 0 -#endif - -#define T_MASK ((md5_word_t)~0) -#define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87) -#define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9) -#define T3 0x242070db -#define T4 /* 0xc1bdceee */ (T_MASK ^ 0x3e423111) -#define T5 /* 0xf57c0faf */ (T_MASK ^ 0x0a83f050) -#define T6 0x4787c62a -#define T7 /* 0xa8304613 */ (T_MASK ^ 0x57cfb9ec) -#define T8 /* 0xfd469501 */ (T_MASK ^ 0x02b96afe) -#define T9 0x698098d8 -#define T10 /* 0x8b44f7af */ (T_MASK ^ 0x74bb0850) -#define T11 /* 0xffff5bb1 */ (T_MASK ^ 0x0000a44e) -#define T12 /* 0x895cd7be */ (T_MASK ^ 0x76a32841) -#define T13 0x6b901122 -#define T14 /* 0xfd987193 */ (T_MASK ^ 0x02678e6c) -#define T15 /* 0xa679438e */ (T_MASK ^ 0x5986bc71) -#define T16 0x49b40821 -#define T17 /* 0xf61e2562 */ (T_MASK ^ 0x09e1da9d) -#define T18 /* 0xc040b340 */ (T_MASK ^ 0x3fbf4cbf) -#define T19 0x265e5a51 -#define T20 /* 0xe9b6c7aa */ (T_MASK ^ 0x16493855) -#define T21 /* 0xd62f105d */ (T_MASK ^ 0x29d0efa2) -#define T22 0x02441453 -#define T23 /* 0xd8a1e681 */ (T_MASK ^ 0x275e197e) -#define T24 /* 0xe7d3fbc8 */ (T_MASK ^ 0x182c0437) -#define T25 0x21e1cde6 -#define T26 /* 0xc33707d6 */ (T_MASK ^ 0x3cc8f829) -#define T27 /* 0xf4d50d87 */ (T_MASK ^ 0x0b2af278) -#define T28 0x455a14ed -#define T29 /* 0xa9e3e905 */ (T_MASK ^ 0x561c16fa) -#define T30 /* 0xfcefa3f8 */ (T_MASK ^ 0x03105c07) -#define T31 0x676f02d9 -#define T32 /* 0x8d2a4c8a */ (T_MASK ^ 0x72d5b375) -#define T33 /* 0xfffa3942 */ (T_MASK ^ 0x0005c6bd) -#define T34 /* 0x8771f681 */ (T_MASK ^ 0x788e097e) -#define T35 0x6d9d6122 -#define T36 /* 0xfde5380c */ (T_MASK ^ 0x021ac7f3) -#define T37 /* 0xa4beea44 */ (T_MASK ^ 0x5b4115bb) -#define T38 0x4bdecfa9 -#define T39 /* 0xf6bb4b60 */ (T_MASK ^ 0x0944b49f) -#define T40 /* 0xbebfbc70 */ (T_MASK ^ 0x4140438f) -#define T41 0x289b7ec6 -#define T42 /* 0xeaa127fa */ (T_MASK ^ 0x155ed805) -#define T43 /* 0xd4ef3085 */ (T_MASK ^ 0x2b10cf7a) -#define T44 0x04881d05 -#define T45 /* 0xd9d4d039 */ (T_MASK ^ 0x262b2fc6) -#define T46 /* 0xe6db99e5 */ (T_MASK ^ 0x1924661a) -#define T47 0x1fa27cf8 -#define T48 /* 0xc4ac5665 */ (T_MASK ^ 0x3b53a99a) -#define T49 /* 0xf4292244 */ (T_MASK ^ 0x0bd6ddbb) -#define T50 0x432aff97 -#define T51 /* 0xab9423a7 */ (T_MASK ^ 0x546bdc58) -#define T52 /* 0xfc93a039 */ (T_MASK ^ 0x036c5fc6) -#define T53 0x655b59c3 -#define T54 /* 0x8f0ccc92 */ (T_MASK ^ 0x70f3336d) -#define T55 /* 0xffeff47d */ (T_MASK ^ 0x00100b82) -#define T56 /* 0x85845dd1 */ (T_MASK ^ 0x7a7ba22e) -#define T57 0x6fa87e4f -#define T58 /* 0xfe2ce6e0 */ (T_MASK ^ 0x01d3191f) -#define T59 /* 0xa3014314 */ (T_MASK ^ 0x5cfebceb) -#define T60 0x4e0811a1 -#define T61 /* 0xf7537e82 */ (T_MASK ^ 0x08ac817d) -#define T62 /* 0xbd3af235 */ (T_MASK ^ 0x42c50dca) -#define T63 0x2ad7d2bb -#define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e) - - -static void -md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) -{ - md5_word_t - a = pms->abcd[0], b = pms->abcd[1], - c = pms->abcd[2], d = pms->abcd[3]; - md5_word_t t; -#if BYTE_ORDER > 0 - /* Define storage only for big-endian CPUs. */ - md5_word_t X[16]; -#else - /* Define storage for little-endian or both types of CPUs. */ - md5_word_t xbuf[16]; - const md5_word_t *X; -#endif - - { -#if BYTE_ORDER == 0 - /* - * Determine dynamically whether this is a big-endian or - * little-endian machine, since we can use a more efficient - * algorithm on the latter. - */ - static const int w = 1; - - if (*((const md5_byte_t *)&w)) /* dynamic little-endian */ -#endif -#if BYTE_ORDER <= 0 /* little-endian */ - { - /* - * On little-endian machines, we can process properly aligned - * data without copying it. - */ - if (!((data - (const md5_byte_t *)0) & 3)) { - /* data are properly aligned */ - X = (const md5_word_t *)data; - } else { - /* not aligned */ - memcpy(xbuf, data, 64); - X = xbuf; - } - } -#endif -#if BYTE_ORDER == 0 - else /* dynamic big-endian */ -#endif -#if BYTE_ORDER >= 0 /* big-endian */ - { - /* - * On big-endian machines, we must arrange the bytes in the - * right order. - */ - const md5_byte_t *xp = data; - int i; - -# if BYTE_ORDER == 0 - X = xbuf; /* (dynamic only) */ -# else -# define xbuf X /* (static only) */ -# endif - for (i = 0; i < 16; ++i, xp += 4) - xbuf[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24); - } -#endif - } - -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) - - /* Round 1. */ - /* Let [abcd k s i] denote the operation - a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */ -#define F(x, y, z) (((x) & (y)) | (~(x) & (z))) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + F(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b - /* Do the following 16 operations. */ - SET(a, b, c, d, 0, 7, T1); - SET(d, a, b, c, 1, 12, T2); - SET(c, d, a, b, 2, 17, T3); - SET(b, c, d, a, 3, 22, T4); - SET(a, b, c, d, 4, 7, T5); - SET(d, a, b, c, 5, 12, T6); - SET(c, d, a, b, 6, 17, T7); - SET(b, c, d, a, 7, 22, T8); - SET(a, b, c, d, 8, 7, T9); - SET(d, a, b, c, 9, 12, T10); - SET(c, d, a, b, 10, 17, T11); - SET(b, c, d, a, 11, 22, T12); - SET(a, b, c, d, 12, 7, T13); - SET(d, a, b, c, 13, 12, T14); - SET(c, d, a, b, 14, 17, T15); - SET(b, c, d, a, 15, 22, T16); -#undef SET - - /* Round 2. */ - /* Let [abcd k s i] denote the operation - a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */ -#define G(x, y, z) (((x) & (z)) | ((y) & ~(z))) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + G(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b - /* Do the following 16 operations. */ - SET(a, b, c, d, 1, 5, T17); - SET(d, a, b, c, 6, 9, T18); - SET(c, d, a, b, 11, 14, T19); - SET(b, c, d, a, 0, 20, T20); - SET(a, b, c, d, 5, 5, T21); - SET(d, a, b, c, 10, 9, T22); - SET(c, d, a, b, 15, 14, T23); - SET(b, c, d, a, 4, 20, T24); - SET(a, b, c, d, 9, 5, T25); - SET(d, a, b, c, 14, 9, T26); - SET(c, d, a, b, 3, 14, T27); - SET(b, c, d, a, 8, 20, T28); - SET(a, b, c, d, 13, 5, T29); - SET(d, a, b, c, 2, 9, T30); - SET(c, d, a, b, 7, 14, T31); - SET(b, c, d, a, 12, 20, T32); -#undef SET - - /* Round 3. */ - /* Let [abcd k s t] denote the operation - a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */ -#define H(x, y, z) ((x) ^ (y) ^ (z)) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + H(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b - /* Do the following 16 operations. */ - SET(a, b, c, d, 5, 4, T33); - SET(d, a, b, c, 8, 11, T34); - SET(c, d, a, b, 11, 16, T35); - SET(b, c, d, a, 14, 23, T36); - SET(a, b, c, d, 1, 4, T37); - SET(d, a, b, c, 4, 11, T38); - SET(c, d, a, b, 7, 16, T39); - SET(b, c, d, a, 10, 23, T40); - SET(a, b, c, d, 13, 4, T41); - SET(d, a, b, c, 0, 11, T42); - SET(c, d, a, b, 3, 16, T43); - SET(b, c, d, a, 6, 23, T44); - SET(a, b, c, d, 9, 4, T45); - SET(d, a, b, c, 12, 11, T46); - SET(c, d, a, b, 15, 16, T47); - SET(b, c, d, a, 2, 23, T48); -#undef SET - - /* Round 4. */ - /* Let [abcd k s t] denote the operation - a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */ -#define I(x, y, z) ((y) ^ ((x) | ~(z))) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + I(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b - /* Do the following 16 operations. */ - SET(a, b, c, d, 0, 6, T49); - SET(d, a, b, c, 7, 10, T50); - SET(c, d, a, b, 14, 15, T51); - SET(b, c, d, a, 5, 21, T52); - SET(a, b, c, d, 12, 6, T53); - SET(d, a, b, c, 3, 10, T54); - SET(c, d, a, b, 10, 15, T55); - SET(b, c, d, a, 1, 21, T56); - SET(a, b, c, d, 8, 6, T57); - SET(d, a, b, c, 15, 10, T58); - SET(c, d, a, b, 6, 15, T59); - SET(b, c, d, a, 13, 21, T60); - SET(a, b, c, d, 4, 6, T61); - SET(d, a, b, c, 11, 10, T62); - SET(c, d, a, b, 2, 15, T63); - SET(b, c, d, a, 9, 21, T64); -#undef SET - - /* Then perform the following additions. (That is increment each - of the four registers by the value it had before this block - was started.) */ - pms->abcd[0] += a; - pms->abcd[1] += b; - pms->abcd[2] += c; - pms->abcd[3] += d; -} - -void -md5_init(md5_state_t *pms) -{ - pms->count[0] = pms->count[1] = 0; - pms->abcd[0] = 0x67452301; - pms->abcd[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476; - pms->abcd[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301; - pms->abcd[3] = 0x10325476; -} - -void -md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes) -{ - const md5_byte_t *p = data; - int left = nbytes; - int offset = (pms->count[0] >> 3) & 63; - md5_word_t nbits = (md5_word_t)(nbytes << 3); - - if (nbytes <= 0) - return; - - /* Update the message length. */ - pms->count[1] += nbytes >> 29; - pms->count[0] += nbits; - if (pms->count[0] < nbits) - pms->count[1]++; - - /* Process an initial partial block. */ - if (offset) { - int copy = (offset + nbytes > 64 ? 64 - offset : nbytes); - - memcpy(pms->buf + offset, p, copy); - if (offset + copy < 64) - return; - p += copy; - left -= copy; - md5_process(pms, pms->buf); - } - - /* Process full blocks. */ - for (; left >= 64; p += 64, left -= 64) - md5_process(pms, p); - - /* Process a final partial block. */ - if (left) - memcpy(pms->buf, p, left); -} - -void -md5_finish(md5_state_t *pms, md5_byte_t digest[16]) -{ - static const md5_byte_t pad[64] = { - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - md5_byte_t data[8]; - int i; - - /* Save the length before padding. */ - for (i = 0; i < 8; ++i) - data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3)); - /* Pad to 56 bytes mod 64. */ - md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1); - /* Append the length. */ - md5_append(pms, data, 8); - for (i = 0; i < 16; ++i) - digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3)); -} Deleted: /python/branches/py3k-struni/Modules/md5.h ============================================================================== --- /python/branches/py3k-struni/Modules/md5.h Thu Jun 7 01:52:48 2007 +++ (empty file) @@ -1,91 +0,0 @@ -/* - Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved. - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - L. Peter Deutsch - ghost at aladdin.com - - */ -/* $Id$ */ -/* - Independent implementation of MD5 (RFC 1321). - - This code implements the MD5 Algorithm defined in RFC 1321, whose - text is available at - http://www.ietf.org/rfc/rfc1321.txt - The code is derived from the text of the RFC, including the test suite - (section A.5) but excluding the rest of Appendix A. It does not include - any code or documentation that is identified in the RFC as being - copyrighted. - - The original and principal author of md5.h is L. Peter Deutsch - . Other authors are noted in the change history - that follows (in reverse chronological order): - - 2002-04-13 lpd Removed support for non-ANSI compilers; removed - references to Ghostscript; clarified derivation from RFC 1321; - now handles byte order either statically or dynamically. - 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. - 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5); - added conditionalization for C++ compilation from Martin - Purschke . - 1999-05-03 lpd Original version. - */ - -#ifndef md5_INCLUDED -# define md5_INCLUDED - -/* - * This package supports both compile-time and run-time determination of CPU - * byte order. If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be - * compiled to run only on little-endian CPUs; if ARCH_IS_BIG_ENDIAN is - * defined as non-zero, the code will be compiled to run only on big-endian - * CPUs; if ARCH_IS_BIG_ENDIAN is not defined, the code will be compiled to - * run on either big- or little-endian CPUs, but will run slightly less - * efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined. - */ - -typedef unsigned char md5_byte_t; /* 8-bit byte */ -typedef unsigned int md5_word_t; /* 32-bit word */ - -/* Define the state of the MD5 Algorithm. */ -typedef struct md5_state_s { - md5_word_t count[2]; /* message length in bits, lsw first */ - md5_word_t abcd[4]; /* digest buffer */ - md5_byte_t buf[64]; /* accumulate block */ -} md5_state_t; - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* Initialize the algorithm. */ -void md5_init(md5_state_t *pms); - -/* Append a string to the message. */ -void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes); - -/* Finish the message and return the digest. */ -void md5_finish(md5_state_t *pms, md5_byte_t digest[16]); - -#ifdef __cplusplus -} /* end extern "C" */ -#endif - -#endif /* md5_INCLUDED */ Deleted: /python/branches/py3k-struni/Modules/md5module.c ============================================================================== --- /python/branches/py3k-struni/Modules/md5module.c Thu Jun 7 01:52:48 2007 +++ (empty file) @@ -1,312 +0,0 @@ - -/* MD5 module */ - -/* This module provides an interface to the RSA Data Security, - Inc. MD5 Message-Digest Algorithm, described in RFC 1321. - It requires the files md5c.c and md5.h (which are slightly changed - from the versions in the RFC to avoid the "global.h" file.) */ - - -/* MD5 objects */ - -#include "Python.h" -#include "structmember.h" -#include "md5.h" - -typedef struct { - PyObject_HEAD - md5_state_t md5; /* the context holder */ -} md5object; - -static PyTypeObject MD5type; - -#define is_md5object(v) ((v)->ob_type == &MD5type) - -static md5object * -newmd5object(void) -{ - md5object *md5p; - - md5p = PyObject_New(md5object, &MD5type); - if (md5p == NULL) - return NULL; - - md5_init(&md5p->md5); /* actual initialisation */ - return md5p; -} - - -/* MD5 methods */ - -static void -md5_dealloc(md5object *md5p) -{ - PyObject_Del(md5p); -} - - -/* MD5 methods-as-attributes */ - -static PyObject * -md5_update(md5object *self, PyObject *args) -{ - unsigned char *cp; - int len; - - if (!PyArg_ParseTuple(args, "s#:update", &cp, &len)) - return NULL; - - md5_append(&self->md5, cp, len); - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(update_doc, -"update (arg)\n\ -\n\ -Update the md5 object with the string arg. Repeated calls are\n\ -equivalent to a single call with the concatenation of all the\n\ -arguments."); - - -static PyObject * -md5_digest(md5object *self) -{ - md5_state_t mdContext; - unsigned char aDigest[16]; - - /* make a temporary copy, and perform the final */ - mdContext = self->md5; - md5_finish(&mdContext, aDigest); - - return PyString_FromStringAndSize((char *)aDigest, 16); -} - -PyDoc_STRVAR(digest_doc, -"digest() -> string\n\ -\n\ -Return the digest of the strings passed to the update() method so\n\ -far. This is a 16-byte string which may contain non-ASCII characters,\n\ -including null bytes."); - - -static PyObject * -md5_hexdigest(md5object *self) -{ - md5_state_t mdContext; - unsigned char digest[16]; - unsigned char hexdigest[32]; - int i, j; - - /* make a temporary copy, and perform the final */ - mdContext = self->md5; - md5_finish(&mdContext, digest); - - /* Make hex version of the digest */ - for(i=j=0; i<16; i++) { - char c; - c = (digest[i] >> 4) & 0xf; - c = (c>9) ? c+'a'-10 : c + '0'; - hexdigest[j++] = c; - c = (digest[i] & 0xf); - c = (c>9) ? c+'a'-10 : c + '0'; - hexdigest[j++] = c; - } - return PyString_FromStringAndSize((char*)hexdigest, 32); -} - - -PyDoc_STRVAR(hexdigest_doc, -"hexdigest() -> string\n\ -\n\ -Like digest(), but returns the digest as a string of hexadecimal digits."); - - -static PyObject * -md5_copy(md5object *self) -{ - md5object *md5p; - - if ((md5p = newmd5object()) == NULL) - return NULL; - - md5p->md5 = self->md5; - - return (PyObject *)md5p; -} - -PyDoc_STRVAR(copy_doc, -"copy() -> md5 object\n\ -\n\ -Return a copy (``clone'') of the md5 object."); - - -static PyMethodDef md5_methods[] = { - {"update", (PyCFunction)md5_update, METH_VARARGS, update_doc}, - {"digest", (PyCFunction)md5_digest, METH_NOARGS, digest_doc}, - {"hexdigest", (PyCFunction)md5_hexdigest, METH_NOARGS, hexdigest_doc}, - {"copy", (PyCFunction)md5_copy, METH_NOARGS, copy_doc}, - {NULL, NULL} /* sentinel */ -}; - -static PyObject * -md5_get_block_size(PyObject *self, void *closure) -{ - return PyInt_FromLong(64); -} - -static PyObject * -md5_get_digest_size(PyObject *self, void *closure) -{ - return PyInt_FromLong(16); -} - -static PyObject * -md5_get_name(PyObject *self, void *closure) -{ - return PyString_FromStringAndSize("MD5", 3); -} - -static PyGetSetDef md5_getseters[] = { - {"digest_size", - (getter)md5_get_digest_size, NULL, - NULL, - NULL}, - {"block_size", - (getter)md5_get_block_size, NULL, - NULL, - NULL}, - {"name", - (getter)md5_get_name, NULL, - NULL, - NULL}, - /* the old md5 and sha modules support 'digest_size' as in PEP 247. - * the old sha module also supported 'digestsize'. ugh. */ - {"digestsize", - (getter)md5_get_digest_size, NULL, - NULL, - NULL}, - {NULL} /* Sentinel */ -}; - - -PyDoc_STRVAR(module_doc, -"This module implements the interface to RSA's MD5 message digest\n\ -algorithm (see also Internet RFC 1321). Its use is quite\n\ -straightforward: use the new() to create an md5 object. You can now\n\ -feed this object with arbitrary strings using the update() method, and\n\ -at any point you can ask it for the digest (a strong kind of 128-bit\n\ -checksum, a.k.a. ``fingerprint'') of the concatenation of the strings\n\ -fed to it so far using the digest() method.\n\ -\n\ -Functions:\n\ -\n\ -new([arg]) -- return a new md5 object, initialized with arg if provided\n\ -md5([arg]) -- DEPRECATED, same as new, but for compatibility\n\ -\n\ -Special Objects:\n\ -\n\ -MD5Type -- type object for md5 objects"); - -PyDoc_STRVAR(md5type_doc, -"An md5 represents the object used to calculate the MD5 checksum of a\n\ -string of information.\n\ -\n\ -Methods:\n\ -\n\ -update() -- updates the current digest with an additional string\n\ -digest() -- return the current digest value\n\ -hexdigest() -- return the current digest as a string of hexadecimal digits\n\ -copy() -- return a copy of the current md5 object"); - -static PyTypeObject MD5type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "_md5.md5", /*tp_name*/ - sizeof(md5object), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)md5_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - md5type_doc, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - md5_methods, /*tp_methods*/ - 0, /*tp_members*/ - md5_getseters, /*tp_getset*/ -}; - - -/* MD5 functions */ - -static PyObject * -MD5_new(PyObject *self, PyObject *args) -{ - md5object *md5p; - unsigned char *cp = NULL; - int len = 0; - - if (!PyArg_ParseTuple(args, "|s#:new", &cp, &len)) - return NULL; - - if ((md5p = newmd5object()) == NULL) - return NULL; - - if (cp) - md5_append(&md5p->md5, cp, len); - - return (PyObject *)md5p; -} - -PyDoc_STRVAR(new_doc, -"new([arg]) -> md5 object\n\ -\n\ -Return a new md5 object. If arg is present, the method call update(arg)\n\ -is made."); - - -/* List of functions exported by this module */ - -static PyMethodDef md5_functions[] = { - {"new", (PyCFunction)MD5_new, METH_VARARGS, new_doc}, - {NULL, NULL} /* Sentinel */ -}; - - -/* Initialize this module. */ - -PyMODINIT_FUNC -init_md5(void) -{ - PyObject *m, *d; - - MD5type.ob_type = &PyType_Type; - if (PyType_Ready(&MD5type) < 0) - return; - m = Py_InitModule3("_md5", md5_functions, module_doc); - if (m == NULL) - return; - d = PyModule_GetDict(m); - PyDict_SetItemString(d, "MD5Type", (PyObject *)&MD5type); - PyModule_AddIntConstant(m, "digest_size", 16); - /* No need to check the error here, the caller will do that */ -} Deleted: /python/branches/py3k-struni/Modules/shamodule.c ============================================================================== --- /python/branches/py3k-struni/Modules/shamodule.c Thu Jun 7 01:52:48 2007 +++ (empty file) @@ -1,593 +0,0 @@ -/* SHA module */ - -/* This module provides an interface to NIST's Secure Hash Algorithm */ - -/* See below for information about the original code this module was - based upon. Additional work performed by: - - Andrew Kuchling (amk at amk.ca) - Greg Stein (gstein at lyra.org) - - Copyright (C) 2005 Gregory P. Smith (greg at electricrain.com) - Licensed to PSF under a Contributor Agreement. - -*/ - -/* SHA objects */ - -#include "Python.h" -#include "structmember.h" - - -/* Endianness testing and definitions */ -#define TestEndianness(variable) {int i=1; variable=PCT_BIG_ENDIAN;\ - if (*((char*)&i)==1) variable=PCT_LITTLE_ENDIAN;} - -#define PCT_LITTLE_ENDIAN 1 -#define PCT_BIG_ENDIAN 0 - -/* Some useful types */ - -typedef unsigned char SHA_BYTE; - -#if SIZEOF_INT == 4 -typedef unsigned int SHA_INT32; /* 32-bit integer */ -#else -/* not defined. compilation will die. */ -#endif - -/* The SHA block size and message digest sizes, in bytes */ - -#define SHA_BLOCKSIZE 64 -#define SHA_DIGESTSIZE 20 - -/* The structure for storing SHS info */ - -typedef struct { - PyObject_HEAD - SHA_INT32 digest[5]; /* Message digest */ - SHA_INT32 count_lo, count_hi; /* 64-bit bit count */ - SHA_BYTE data[SHA_BLOCKSIZE]; /* SHA data buffer */ - int Endianness; - int local; /* unprocessed amount in data */ -} SHAobject; - -/* When run on a little-endian CPU we need to perform byte reversal on an - array of longwords. */ - -static void longReverse(SHA_INT32 *buffer, int byteCount, int Endianness) -{ - SHA_INT32 value; - - if ( Endianness == PCT_BIG_ENDIAN ) - return; - - byteCount /= sizeof(*buffer); - while (byteCount--) { - value = *buffer; - value = ( ( value & 0xFF00FF00L ) >> 8 ) | \ - ( ( value & 0x00FF00FFL ) << 8 ); - *buffer++ = ( value << 16 ) | ( value >> 16 ); - } -} - -static void SHAcopy(SHAobject *src, SHAobject *dest) -{ - dest->Endianness = src->Endianness; - dest->local = src->local; - dest->count_lo = src->count_lo; - dest->count_hi = src->count_hi; - memcpy(dest->digest, src->digest, sizeof(src->digest)); - memcpy(dest->data, src->data, sizeof(src->data)); -} - - -/* ------------------------------------------------------------------------ - * - * This code for the SHA algorithm was noted as public domain. The original - * headers are pasted below. - * - * Several changes have been made to make it more compatible with the - * Python environment and desired interface. - * - */ - -/* NIST Secure Hash Algorithm */ -/* heavily modified by Uwe Hollerbach */ -/* from Peter C. Gutmann's implementation as found in */ -/* Applied Cryptography by Bruce Schneier */ -/* Further modifications to include the "UNRAVEL" stuff, below */ - -/* This code is in the public domain */ - -/* UNRAVEL should be fastest & biggest */ -/* UNROLL_LOOPS should be just as big, but slightly slower */ -/* both undefined should be smallest and slowest */ - -#define UNRAVEL -/* #define UNROLL_LOOPS */ - -/* The SHA f()-functions. The f1 and f3 functions can be optimized to - save one boolean operation each - thanks to Rich Schroeppel, - rcs at cs.arizona.edu for discovering this */ - -/*#define f1(x,y,z) ((x & y) | (~x & z)) // Rounds 0-19 */ -#define f1(x,y,z) (z ^ (x & (y ^ z))) /* Rounds 0-19 */ -#define f2(x,y,z) (x ^ y ^ z) /* Rounds 20-39 */ -/*#define f3(x,y,z) ((x & y) | (x & z) | (y & z)) // Rounds 40-59 */ -#define f3(x,y,z) ((x & y) | (z & (x | y))) /* Rounds 40-59 */ -#define f4(x,y,z) (x ^ y ^ z) /* Rounds 60-79 */ - -/* SHA constants */ - -#define CONST1 0x5a827999L /* Rounds 0-19 */ -#define CONST2 0x6ed9eba1L /* Rounds 20-39 */ -#define CONST3 0x8f1bbcdcL /* Rounds 40-59 */ -#define CONST4 0xca62c1d6L /* Rounds 60-79 */ - -/* 32-bit rotate */ - -#define R32(x,n) ((x << n) | (x >> (32 - n))) - -/* the generic case, for when the overall rotation is not unraveled */ - -#define FG(n) \ - T = R32(A,5) + f##n(B,C,D) + E + *WP++ + CONST##n; \ - E = D; D = C; C = R32(B,30); B = A; A = T - -/* specific cases, for when the overall rotation is unraveled */ - -#define FA(n) \ - T = R32(A,5) + f##n(B,C,D) + E + *WP++ + CONST##n; B = R32(B,30) - -#define FB(n) \ - E = R32(T,5) + f##n(A,B,C) + D + *WP++ + CONST##n; A = R32(A,30) - -#define FC(n) \ - D = R32(E,5) + f##n(T,A,B) + C + *WP++ + CONST##n; T = R32(T,30) - -#define FD(n) \ - C = R32(D,5) + f##n(E,T,A) + B + *WP++ + CONST##n; E = R32(E,30) - -#define FE(n) \ - B = R32(C,5) + f##n(D,E,T) + A + *WP++ + CONST##n; D = R32(D,30) - -#define FT(n) \ - A = R32(B,5) + f##n(C,D,E) + T + *WP++ + CONST##n; C = R32(C,30) - -/* do SHA transformation */ - -static void -sha_transform(SHAobject *sha_info) -{ - int i; - SHA_INT32 T, A, B, C, D, E, W[80], *WP; - - memcpy(W, sha_info->data, sizeof(sha_info->data)); - longReverse(W, (int)sizeof(sha_info->data), sha_info->Endianness); - - for (i = 16; i < 80; ++i) { - W[i] = W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16]; - - /* extra rotation fix */ - W[i] = R32(W[i], 1); - } - A = sha_info->digest[0]; - B = sha_info->digest[1]; - C = sha_info->digest[2]; - D = sha_info->digest[3]; - E = sha_info->digest[4]; - WP = W; -#ifdef UNRAVEL - FA(1); FB(1); FC(1); FD(1); FE(1); FT(1); FA(1); FB(1); FC(1); FD(1); - FE(1); FT(1); FA(1); FB(1); FC(1); FD(1); FE(1); FT(1); FA(1); FB(1); - FC(2); FD(2); FE(2); FT(2); FA(2); FB(2); FC(2); FD(2); FE(2); FT(2); - FA(2); FB(2); FC(2); FD(2); FE(2); FT(2); FA(2); FB(2); FC(2); FD(2); - FE(3); FT(3); FA(3); FB(3); FC(3); FD(3); FE(3); FT(3); FA(3); FB(3); - FC(3); FD(3); FE(3); FT(3); FA(3); FB(3); FC(3); FD(3); FE(3); FT(3); - FA(4); FB(4); FC(4); FD(4); FE(4); FT(4); FA(4); FB(4); FC(4); FD(4); - FE(4); FT(4); FA(4); FB(4); FC(4); FD(4); FE(4); FT(4); FA(4); FB(4); - sha_info->digest[0] += E; - sha_info->digest[1] += T; - sha_info->digest[2] += A; - sha_info->digest[3] += B; - sha_info->digest[4] += C; -#else /* !UNRAVEL */ -#ifdef UNROLL_LOOPS - FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); - FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); - FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); - FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); - FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); - FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); - FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); - FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); -#else /* !UNROLL_LOOPS */ - for (i = 0; i < 20; ++i) { FG(1); } - for (i = 20; i < 40; ++i) { FG(2); } - for (i = 40; i < 60; ++i) { FG(3); } - for (i = 60; i < 80; ++i) { FG(4); } -#endif /* !UNROLL_LOOPS */ - sha_info->digest[0] += A; - sha_info->digest[1] += B; - sha_info->digest[2] += C; - sha_info->digest[3] += D; - sha_info->digest[4] += E; -#endif /* !UNRAVEL */ -} - -/* initialize the SHA digest */ - -static void -sha_init(SHAobject *sha_info) -{ - TestEndianness(sha_info->Endianness) - - sha_info->digest[0] = 0x67452301L; - sha_info->digest[1] = 0xefcdab89L; - sha_info->digest[2] = 0x98badcfeL; - sha_info->digest[3] = 0x10325476L; - sha_info->digest[4] = 0xc3d2e1f0L; - sha_info->count_lo = 0L; - sha_info->count_hi = 0L; - sha_info->local = 0; -} - -/* update the SHA digest */ - -static void -sha_update(SHAobject *sha_info, SHA_BYTE *buffer, int count) -{ - int i; - SHA_INT32 clo; - - clo = sha_info->count_lo + ((SHA_INT32) count << 3); - if (clo < sha_info->count_lo) { - ++sha_info->count_hi; - } - sha_info->count_lo = clo; - sha_info->count_hi += (SHA_INT32) count >> 29; - if (sha_info->local) { - i = SHA_BLOCKSIZE - sha_info->local; - if (i > count) { - i = count; - } - memcpy(((SHA_BYTE *) sha_info->data) + sha_info->local, buffer, i); - count -= i; - buffer += i; - sha_info->local += i; - if (sha_info->local == SHA_BLOCKSIZE) { - sha_transform(sha_info); - } - else { - return; - } - } - while (count >= SHA_BLOCKSIZE) { - memcpy(sha_info->data, buffer, SHA_BLOCKSIZE); - buffer += SHA_BLOCKSIZE; - count -= SHA_BLOCKSIZE; - sha_transform(sha_info); - } - memcpy(sha_info->data, buffer, count); - sha_info->local = count; -} - -/* finish computing the SHA digest */ - -static void -sha_final(unsigned char digest[20], SHAobject *sha_info) -{ - int count; - SHA_INT32 lo_bit_count, hi_bit_count; - - lo_bit_count = sha_info->count_lo; - hi_bit_count = sha_info->count_hi; - count = (int) ((lo_bit_count >> 3) & 0x3f); - ((SHA_BYTE *) sha_info->data)[count++] = 0x80; - if (count > SHA_BLOCKSIZE - 8) { - memset(((SHA_BYTE *) sha_info->data) + count, 0, - SHA_BLOCKSIZE - count); - sha_transform(sha_info); - memset((SHA_BYTE *) sha_info->data, 0, SHA_BLOCKSIZE - 8); - } - else { - memset(((SHA_BYTE *) sha_info->data) + count, 0, - SHA_BLOCKSIZE - 8 - count); - } - - /* GJS: note that we add the hi/lo in big-endian. sha_transform will - swap these values into host-order. */ - sha_info->data[56] = (hi_bit_count >> 24) & 0xff; - sha_info->data[57] = (hi_bit_count >> 16) & 0xff; - sha_info->data[58] = (hi_bit_count >> 8) & 0xff; - sha_info->data[59] = (hi_bit_count >> 0) & 0xff; - sha_info->data[60] = (lo_bit_count >> 24) & 0xff; - sha_info->data[61] = (lo_bit_count >> 16) & 0xff; - sha_info->data[62] = (lo_bit_count >> 8) & 0xff; - sha_info->data[63] = (lo_bit_count >> 0) & 0xff; - sha_transform(sha_info); - digest[ 0] = (unsigned char) ((sha_info->digest[0] >> 24) & 0xff); - digest[ 1] = (unsigned char) ((sha_info->digest[0] >> 16) & 0xff); - digest[ 2] = (unsigned char) ((sha_info->digest[0] >> 8) & 0xff); - digest[ 3] = (unsigned char) ((sha_info->digest[0] ) & 0xff); - digest[ 4] = (unsigned char) ((sha_info->digest[1] >> 24) & 0xff); - digest[ 5] = (unsigned char) ((sha_info->digest[1] >> 16) & 0xff); - digest[ 6] = (unsigned char) ((sha_info->digest[1] >> 8) & 0xff); - digest[ 7] = (unsigned char) ((sha_info->digest[1] ) & 0xff); - digest[ 8] = (unsigned char) ((sha_info->digest[2] >> 24) & 0xff); - digest[ 9] = (unsigned char) ((sha_info->digest[2] >> 16) & 0xff); - digest[10] = (unsigned char) ((sha_info->digest[2] >> 8) & 0xff); - digest[11] = (unsigned char) ((sha_info->digest[2] ) & 0xff); - digest[12] = (unsigned char) ((sha_info->digest[3] >> 24) & 0xff); - digest[13] = (unsigned char) ((sha_info->digest[3] >> 16) & 0xff); - digest[14] = (unsigned char) ((sha_info->digest[3] >> 8) & 0xff); - digest[15] = (unsigned char) ((sha_info->digest[3] ) & 0xff); - digest[16] = (unsigned char) ((sha_info->digest[4] >> 24) & 0xff); - digest[17] = (unsigned char) ((sha_info->digest[4] >> 16) & 0xff); - digest[18] = (unsigned char) ((sha_info->digest[4] >> 8) & 0xff); - digest[19] = (unsigned char) ((sha_info->digest[4] ) & 0xff); -} - -/* - * End of copied SHA code. - * - * ------------------------------------------------------------------------ - */ - -static PyTypeObject SHAtype; - - -static SHAobject * -newSHAobject(void) -{ - return (SHAobject *)PyObject_New(SHAobject, &SHAtype); -} - -/* Internal methods for a hashing object */ - -static void -SHA_dealloc(PyObject *ptr) -{ - PyObject_Del(ptr); -} - - -/* External methods for a hashing object */ - -PyDoc_STRVAR(SHA_copy__doc__, "Return a copy of the hashing object."); - -static PyObject * -SHA_copy(SHAobject *self, PyObject *unused) -{ - SHAobject *newobj; - - if ( (newobj = newSHAobject())==NULL) - return NULL; - - SHAcopy(self, newobj); - return (PyObject *)newobj; -} - -PyDoc_STRVAR(SHA_digest__doc__, -"Return the digest value as a string of binary data."); - -static PyObject * -SHA_digest(SHAobject *self, PyObject *unused) -{ - unsigned char digest[SHA_DIGESTSIZE]; - SHAobject temp; - - SHAcopy(self, &temp); - sha_final(digest, &temp); - return PyString_FromStringAndSize((const char *)digest, sizeof(digest)); -} - -PyDoc_STRVAR(SHA_hexdigest__doc__, -"Return the digest value as a string of hexadecimal digits."); - -static PyObject * -SHA_hexdigest(SHAobject *self, PyObject *unused) -{ - unsigned char digest[SHA_DIGESTSIZE]; - SHAobject temp; - PyObject *retval; - char *hex_digest; - int i, j; - - /* Get the raw (binary) digest value */ - SHAcopy(self, &temp); - sha_final(digest, &temp); - - /* Create a new string */ - retval = PyString_FromStringAndSize(NULL, sizeof(digest) * 2); - if (!retval) - return NULL; - hex_digest = PyString_AsString(retval); - if (!hex_digest) { - Py_DECREF(retval); - return NULL; - } - - /* Make hex version of the digest */ - for(i=j=0; i> 4) & 0xf; - c = (c>9) ? c+'a'-10 : c + '0'; - hex_digest[j++] = c; - c = (digest[i] & 0xf); - c = (c>9) ? c+'a'-10 : c + '0'; - hex_digest[j++] = c; - } - return retval; -} - -PyDoc_STRVAR(SHA_update__doc__, -"Update this hashing object's state with the provided string."); - -static PyObject * -SHA_update(SHAobject *self, PyObject *args) -{ - unsigned char *cp; - int len; - - if (!PyArg_ParseTuple(args, "s#:update", &cp, &len)) - return NULL; - - sha_update(self, cp, len); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyMethodDef SHA_methods[] = { - {"copy", (PyCFunction)SHA_copy, METH_NOARGS, SHA_copy__doc__}, - {"digest", (PyCFunction)SHA_digest, METH_NOARGS, SHA_digest__doc__}, - {"hexdigest", (PyCFunction)SHA_hexdigest, METH_NOARGS, SHA_hexdigest__doc__}, - {"update", (PyCFunction)SHA_update, METH_VARARGS, SHA_update__doc__}, - {NULL, NULL} /* sentinel */ -}; - -static PyObject * -SHA_get_block_size(PyObject *self, void *closure) -{ - return PyInt_FromLong(SHA_BLOCKSIZE); -} - -static PyObject * -SHA_get_digest_size(PyObject *self, void *closure) -{ - return PyInt_FromLong(SHA_DIGESTSIZE); -} - -static PyObject * -SHA_get_name(PyObject *self, void *closure) -{ - return PyString_FromStringAndSize("SHA1", 4); -} - -static PyGetSetDef SHA_getseters[] = { - {"digest_size", - (getter)SHA_get_digest_size, NULL, - NULL, - NULL}, - {"block_size", - (getter)SHA_get_block_size, NULL, - NULL, - NULL}, - {"name", - (getter)SHA_get_name, NULL, - NULL, - NULL}, - /* the old md5 and sha modules support 'digest_size' as in PEP 247. - * the old sha module also supported 'digestsize'. ugh. */ - {"digestsize", - (getter)SHA_get_digest_size, NULL, - NULL, - NULL}, - {NULL} /* Sentinel */ -}; - -static PyTypeObject SHAtype = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "_sha.sha", /*tp_name*/ - sizeof(SHAobject), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods */ - SHA_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - SHA_methods, /* tp_methods */ - 0, /* tp_members */ - SHA_getseters, /* tp_getset */ -}; - - -/* The single module-level function: new() */ - -PyDoc_STRVAR(SHA_new__doc__, -"Return a new SHA hashing object. An optional string argument\n\ -may be provided; if present, this string will be automatically\n\ -hashed."); - -static PyObject * -SHA_new(PyObject *self, PyObject *args, PyObject *kwdict) -{ - static char *kwlist[] = {"string", NULL}; - SHAobject *new; - unsigned char *cp = NULL; - int len; - - if (!PyArg_ParseTupleAndKeywords(args, kwdict, "|s#:new", kwlist, - &cp, &len)) { - return NULL; - } - - if ((new = newSHAobject()) == NULL) - return NULL; - - sha_init(new); - - if (PyErr_Occurred()) { - Py_DECREF(new); - return NULL; - } - if (cp) - sha_update(new, cp, len); - - return (PyObject *)new; -} - - -/* List of functions exported by this module */ - -static struct PyMethodDef SHA_functions[] = { - {"new", (PyCFunction)SHA_new, METH_VARARGS|METH_KEYWORDS, SHA_new__doc__}, - {NULL, NULL} /* Sentinel */ -}; - - -/* Initialize this module. */ - -#define insint(n,v) { PyModule_AddIntConstant(m,n,v); } - -PyMODINIT_FUNC -init_sha(void) -{ - PyObject *m; - - SHAtype.ob_type = &PyType_Type; - if (PyType_Ready(&SHAtype) < 0) - return; - m = Py_InitModule("_sha", SHA_functions); - if (m == NULL) - return; - - /* Add some symbolic constants to the module */ - insint("blocksize", 1); /* For future use, in case some hash - functions require an integral number of - blocks */ - insint("digestsize", 20); - insint("digest_size", 20); -} Deleted: /python/branches/py3k-struni/Modules/timing.h ============================================================================== --- /python/branches/py3k-struni/Modules/timing.h Thu Jun 7 01:52:48 2007 +++ (empty file) @@ -1,67 +0,0 @@ -/* - * Copyright (c) 1993 George V. Neville-Neil - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by George V. Neville-Neil - * 4. The name, George Neville-Neil may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _TIMING_H_ -#define _TIMING_H_ - -#ifdef TIME_WITH_SYS_TIME -#include -#include -#else /* !TIME_WITH_SYS_TIME */ -#ifdef HAVE_SYS_TIME_H -#include -#else /* !HAVE_SYS_TIME_H */ -#include -#endif /* !HAVE_SYS_TIME_H */ -#endif /* !TIME_WITH_SYS_TIME */ - -static struct timeval aftertp, beforetp; - -#define BEGINTIMING gettimeofday(&beforetp, NULL) - -#define ENDTIMING gettimeofday(&aftertp, NULL); \ - if(beforetp.tv_usec > aftertp.tv_usec) \ - { \ - aftertp.tv_usec += 1000000; \ - aftertp.tv_sec--; \ - } - -#define TIMINGUS (((aftertp.tv_sec - beforetp.tv_sec) * 1000000) + \ - (aftertp.tv_usec - beforetp.tv_usec)) - -#define TIMINGMS (((aftertp.tv_sec - beforetp.tv_sec) * 1000) + \ - ((aftertp.tv_usec - beforetp.tv_usec) / 1000)) - -#define TIMINGS ((aftertp.tv_sec - beforetp.tv_sec) + \ - (aftertp.tv_usec - beforetp.tv_usec) / 1000000) - -#endif /* _TIMING_H_ */ Deleted: /python/branches/py3k-struni/Modules/timingmodule.c ============================================================================== --- /python/branches/py3k-struni/Modules/timingmodule.c Thu Jun 7 01:52:48 2007 +++ (empty file) @@ -1,58 +0,0 @@ -/* - * Author: George V. Neville-Neil - */ - -#include "Python.h" - -/* Our stuff... */ -#include "timing.h" - -static PyObject * -start_timing(PyObject *self) -{ - Py_INCREF(Py_None); - BEGINTIMING; - return Py_None; -} - -static PyObject * -finish_timing(PyObject *self) -{ - ENDTIMING - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -seconds(PyObject *self) -{ - return PyInt_FromLong(TIMINGS); -} - -static PyObject * -milli(PyObject *self) -{ - return PyInt_FromLong(TIMINGMS); -} - -static PyObject * -micro(PyObject *self) -{ - return PyInt_FromLong(TIMINGUS); -} - - -static PyMethodDef timing_methods[] = { - {"start", (PyCFunction)start_timing, METH_NOARGS}, - {"finish", (PyCFunction)finish_timing, METH_NOARGS}, - {"seconds", (PyCFunction)seconds, METH_NOARGS}, - {"milli", (PyCFunction)milli, METH_NOARGS}, - {"micro", (PyCFunction)micro, METH_NOARGS}, - {NULL, NULL} -}; - - -PyMODINIT_FUNC inittiming(void) -{ - (void)Py_InitModule("timing", timing_methods); -} Modified: python/branches/py3k-struni/Objects/abstract.c ============================================================================== --- python/branches/py3k-struni/Objects/abstract.c (original) +++ python/branches/py3k-struni/Objects/abstract.c Thu Jun 7 01:52:48 2007 @@ -2131,8 +2131,9 @@ PyObject_IsInstance(PyObject *inst, PyObject *cls) { PyObject *t, *v, *tb; + PyObject *checker; PyErr_Fetch(&t, &v, &tb); - PyObject *checker = PyObject_GetAttrString(cls, "__instancecheck__"); + checker = PyObject_GetAttrString(cls, "__instancecheck__"); PyErr_Restore(t, v, tb); if (checker != NULL) { PyObject *res; @@ -2201,8 +2202,9 @@ PyObject_IsSubclass(PyObject *derived, PyObject *cls) { PyObject *t, *v, *tb; + PyObject *checker; PyErr_Fetch(&t, &v, &tb); - PyObject *checker = PyObject_GetAttrString(cls, "__subclasscheck__"); + checker = PyObject_GetAttrString(cls, "__subclasscheck__"); PyErr_Restore(t, v, tb); if (checker != NULL) { PyObject *res; Modified: python/branches/py3k-struni/PC/WinMain.c ============================================================================== --- python/branches/py3k-struni/PC/WinMain.c (original) +++ python/branches/py3k-struni/PC/WinMain.c Thu Jun 7 01:52:48 2007 @@ -1,10 +1,10 @@ /* Minimal main program -- everything is loaded from the library. */ +#include "Python.h" + #define WIN32_LEAN_AND_MEAN #include -#include "Python.h" - int WINAPI WinMain( HINSTANCE hInstance, /* handle to current instance */ HINSTANCE hPrevInstance, /* handle to previous instance */ Modified: python/branches/py3k-struni/PC/_winreg.c ============================================================================== --- python/branches/py3k-struni/PC/_winreg.c (original) +++ python/branches/py3k-struni/PC/_winreg.c Thu Jun 7 01:52:48 2007 @@ -12,10 +12,10 @@ */ -#include "windows.h" #include "Python.h" #include "structmember.h" #include "malloc.h" /* for alloca */ +#include "windows.h" static BOOL PyHKEY_AsHKEY(PyObject *ob, HKEY *pRes, BOOL bNoneOK); static PyObject *PyHKEY_FromHKEY(HKEY h); Modified: python/branches/py3k-struni/PC/dl_nt.c ============================================================================== --- python/branches/py3k-struni/PC/dl_nt.c (original) +++ python/branches/py3k-struni/PC/dl_nt.c Thu Jun 7 01:52:48 2007 @@ -7,11 +7,9 @@ forgotten) from the programmer. */ -#include "windows.h" -/* NT and Python share these */ -#include "pyconfig.h" #include "Python.h" +#include "windows.h" char dllVersionBuffer[16] = ""; // a private buffer Modified: python/branches/py3k-struni/PC/os2emx/Makefile ============================================================================== --- python/branches/py3k-struni/PC/os2emx/Makefile (original) +++ python/branches/py3k-struni/PC/os2emx/Makefile Thu Jun 7 01:52:48 2007 @@ -300,12 +300,8 @@ Modules/itertoolsmodule.c \ Modules/_localemodule.c \ Modules/mathmodule.c \ - Modules/md5.c \ - Modules/md5module.c \ Modules/operator.c \ Modules/_randommodule.c \ - Modules/rgbimgmodule.c \ - Modules/shamodule.c \ Modules/sha256module.c \ Modules/sha512module.c \ Modules/_sre.c \ @@ -313,7 +309,6 @@ Modules/symtablemodule.c \ Modules/termios.c \ Modules/timemodule.c \ - Modules/timingmodule.c \ Modules/_weakref.c \ Modules/xxsubtype.c \ Modules/zipimport.c) Modified: python/branches/py3k-struni/PC/os2emx/config.c ============================================================================== --- python/branches/py3k-struni/PC/os2emx/config.c (original) +++ python/branches/py3k-struni/PC/os2emx/config.c Thu Jun 7 01:52:48 2007 @@ -65,14 +65,12 @@ extern void initmath(); extern void init_md5(); extern void initoperator(); -extern void initrgbimg(); extern void init_sha(); extern void init_sha256(); extern void init_sha512(); extern void init_struct(); extern void inittermios(); extern void inittime(); -extern void inittiming(); extern void initxxsubtype(); extern void initzipimport(); #if !HAVE_DYNAMIC_LOADING @@ -127,16 +125,12 @@ {"imageop", initimageop}, {"itertools", inititertools}, {"math", initmath}, - {"_md5", init_md5}, {"operator", initoperator}, - {"rgbimg", initrgbimg}, - {"_sha", init_sha}, {"_sha256", init_sha256}, {"_sha512", init_sha512}, {"_struct", init_struct}, {"termios", inittermios}, {"time", inittime}, - {"timing", inittiming}, {"xxsubtype", initxxsubtype}, {"zipimport", initzipimport}, #if !HAVE_DYNAMIC_LOADING Modified: python/branches/py3k-struni/PC/os2emx/python25.def ============================================================================== --- python/branches/py3k-struni/PC/os2emx/python25.def (original) +++ python/branches/py3k-struni/PC/os2emx/python25.def Thu Jun 7 01:52:48 2007 @@ -1255,26 +1255,12 @@ ; From python25_s.lib(mathmodule) ; "initmath" -; From python25_s.lib(md5) - "md5_finish" - "md5_init" - "md5_append" - -; From python25_s.lib(md5module) -; "init_md5" - ; From python25_s.lib(operator) ; "initoperator" ; From python25_s.lib(_randommodule) ; "init_random" -; From python25_s.lib(rgbimgmodule) -; "initrgbimg" - -; From python25_s.lib(shamodule) -; "init_sha" - ; From python25_s.lib(sha256module) ; "init_sha256" @@ -1298,9 +1284,6 @@ "_PyTime_DoubleToTimet" ; "inittimezone" -; From python25_s.lib(timingmodule) -; "inittiming" - ; From python25_s.lib(_weakref) ; "init_weakref" Modified: python/branches/py3k-struni/PC/os2vacpp/makefile ============================================================================== --- python/branches/py3k-struni/PC/os2vacpp/makefile (original) +++ python/branches/py3k-struni/PC/os2vacpp/makefile Thu Jun 7 01:52:48 2007 @@ -371,19 +371,6 @@ $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h -almodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - arraymodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ @@ -439,46 +426,6 @@ $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ $(PY_INCLUDE)\tupleobject.h -cdmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -cgensupport.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_MODULES)\cgensupport.h $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h \ - $(PY_INCLUDE)\complexobject.h pyconfig.h $(PY_INCLUDE)\dictobject.h \ - $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h \ - $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h \ - $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -clmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - cmathmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ @@ -616,33 +563,6 @@ $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ $(PY_INCLUDE)\tupleobject.h -flmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\structmember.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -fmmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - fpectlmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ @@ -700,20 +620,6 @@ $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ $(PY_INCLUDE)\tupleobject.h -glmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_MODULES)\cgensupport.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - grpmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ @@ -741,19 +647,6 @@ $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h -imgfile.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - main.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ @@ -781,21 +674,6 @@ $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ $(PY_INCLUDE)\tupleobject.h -md5c.obj: pyconfig.h $(PY_MODULES)\md5.h - -md5module.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_MODULES)\md5.h $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - mpzmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ @@ -852,20 +730,6 @@ $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\token.h \ $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h -pcremodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_MODULES)\pcre-internal.h \ - $(PY_MODULES)\pcre.h $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h \ - $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h \ - $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - posix.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ @@ -894,19 +758,6 @@ $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ $(PY_INCLUDE)\tupleobject.h -puremodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - pwdmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ @@ -921,20 +772,6 @@ $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ $(PY_INCLUDE)\tupleobject.h -pypcre.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\graminit.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_MODULES)\pcre-internal.h $(PY_MODULES)\pcre.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - readline.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ @@ -962,20 +799,6 @@ $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ $(PY_INCLUDE)\tupleobject.h -rgbimgmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - selectmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ @@ -990,19 +813,6 @@ $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h -sgimodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - signalmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ @@ -1032,33 +842,6 @@ $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ $(PY_INCLUDE)\tupleobject.h -soundex.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -stdwinmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - structmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ @@ -1087,21 +870,6 @@ $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\structmember.h \ $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h -svmodule.obj: $(PY_INCLUDE)\abstract.h $(OS2TCPIP)\Include\sys\time.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\compile.h \ - $(PY_INCLUDE)\complexobject.h pyconfig.h $(PY_INCLUDE)\dictobject.h \ - $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h \ - $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h \ - $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h \ - $(PY_MODULES)\yuv.h - syslogmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ @@ -1157,20 +925,6 @@ $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ $(PY_INCLUDE)\tupleobject.h -timingmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_MODULES)\timing.h \ - $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - xxmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ Modified: python/branches/py3k-struni/PC/os2vacpp/makefile.omk ============================================================================== --- python/branches/py3k-struni/PC/os2vacpp/makefile.omk (original) +++ python/branches/py3k-struni/PC/os2vacpp/makefile.omk Thu Jun 7 01:52:48 2007 @@ -170,45 +170,30 @@ # Omitted Modules (and Description/Reason): # # Multimedia: - # almodule.c -- Non-OS/2 Audio Channel Facility (?) - # cdmodule.c -- Wrapper of Non-OS/2 CD Audio Functions # audioop.c -- Various Compute Operations on Audio Samples # imageop.c -- Various Compute Operations on Video Samples - # imgfile.c -- Wrapper of SGI ImageLib API - # rgbimgmodule.c -- Non-OS/2 Image Read/Write Capability (Primitive) # sunaudiodev.c -- Wrapper of Sun Audio Device API - # clmodule.c -- Wrapper of SGI Image/Audio Compression API # Database: # dbmmodule.c -- Wrapper of DBM Database API (Generic Flavor) - # bsddbmodule.c -- Wrapper of DBM Database API (BSD Flavor) # gdbmmodule.c -- Wrapper of DBM Database API (GNU Flavor) # Cryptography: # cryptmodule.c -- Simple Wrapper for crypt() Function - # rotormodule.c -- Implementation of Enigma Crypto Based on Rotors -# cgensupport.obj \ # fcntlmodule.obj \ -# fmmodule.obj \ # fpectlmodule.obj \ # fpetestmodule.obj \ # Unix-Specific getpath.obj \ -# glmodule.obj \ # grpmodule.obj \ # mpzmodule.obj \ # nismodule.obj \ # parsermodule.obj \ -# pcremodule.obj \ # pwdmodule.obj \ -# pypcre.obj \ # readline.obj \ # resource.obj \ -# sgimodule.obj \ -# svmodule.obj \ # syslogmodule.obj \ # termios.obj \ -# timingmodule.obj \ # User Interface: # _tkinter.obj \ @@ -358,14 +343,6 @@ pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ traceback.h tupleobject.h -almodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - arraymodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ import.h intobject.h intrcheck.h listobject.h longobject.h \ @@ -398,30 +375,6 @@ pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ traceback.h tupleobject.h -cdmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -cgensupport.obj: abstract.h ceval.h cgensupport.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -clmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - cmathmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ import.h intobject.h intrcheck.h listobject.h longobject.h \ @@ -502,22 +455,6 @@ pyerrors.h pyfpe.h pystate.h python.h pythonrun.h rangeobject.h \ sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h -flmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h \ - structmember.h sysmodule.h traceback.h tupleobject.h - -fmmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - fpectlmodule.obj: abstract.h ceval.h classobject.h cobject.h \ complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ funcobject.h import.h intobject.h intrcheck.h listobject.h \ @@ -552,14 +489,6 @@ python.h pythonrun.h rangeobject.h sliceobject.h stringobject.h \ sysmodule.h traceback.h tupleobject.h -glmodule.obj: abstract.h ceval.h cgensupport.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - grpmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ grp.h import.h intobject.h intrcheck.h listobject.h longobject.h \ @@ -576,14 +505,6 @@ pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ traceback.h tupleobject.h -imgfile.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - main.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ import.h intobject.h intrcheck.h listobject.h longobject.h \ @@ -600,16 +521,6 @@ pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ stringobject.h sysmodule.h traceback.h tupleobject.h -md5c.obj: pyconfig.h md5.h - -md5module.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h md5.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - mpzmodule.obj: abstract.h ceval.h classobject.h cobject.h \ complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ funcobject.h import.h intobject.h intrcheck.h listobject.h \ @@ -643,14 +554,6 @@ rangeobject.h sliceobject.h stringobject.h sysmodule.h token.h \ traceback.h tupleobject.h -pcremodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pcre-internal.h pcre.h pydebug.h pyerrors.h \ - pyfpe.h pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - posix.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ import.h intobject.h intrcheck.h listobject.h longobject.h \ @@ -667,14 +570,6 @@ python.h pythonrun.h rangeobject.h sliceobject.h stringobject.h \ sysmodule.h traceback.h tupleobject.h -puremodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - pwdmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ import.h intobject.h intrcheck.h listobject.h longobject.h \ @@ -683,14 +578,6 @@ python.h pythonrun.h rangeobject.h sliceobject.h stringobject.h \ sysmodule.h traceback.h tupleobject.h -pypcre.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - graminit.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pcre-internal.h pcre.h pydebug.h \ - pyerrors.h pyfpe.h pystate.h python.h pythonrun.h rangeobject.h \ - sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h - readline.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ import.h intobject.h intrcheck.h listobject.h longobject.h \ @@ -707,22 +594,6 @@ pyerrors.h pyfpe.h pystate.h python.h pythonrun.h rangeobject.h \ sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h -rgbimgmodule.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -rotormodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h mymath.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - selectmodule.obj: abstract.h ceval.h classobject.h cobject.h \ complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ funcobject.h import.h intobject.h intrcheck.h listobject.h \ @@ -731,14 +602,6 @@ pyerrors.h pyfpe.h pystate.h python.h pythonrun.h rangeobject.h \ sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h -sgimodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - signalmodule.obj: abstract.h ceval.h classobject.h cobject.h \ complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ funcobject.h import.h intobject.h intrcheck.h listobject.h \ @@ -756,22 +619,6 @@ pyfpe.h pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ stringobject.h sysmodule.h traceback.h tupleobject.h -soundex.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -stdwinmodule.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - structmodule.obj: abstract.h ceval.h classobject.h cobject.h \ complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ funcobject.h import.h intobject.h intrcheck.h listobject.h \ @@ -789,15 +636,6 @@ sliceobject.h stringobject.h structmember.h sysmodule.h \ traceback.h tupleobject.h -svmodule.obj: abstract.h c:\mptn\include\sys\time.h ceval.h classobject.h \ - cobject.h compile.h complexobject.h pyconfig.h dictobject.h \ - fileobject.h floatobject.h funcobject.h import.h intobject.h \ - intrcheck.h listobject.h longobject.h methodobject.h modsupport.h \ - moduleobject.h mymalloc.h myproto.h object.h objimpl.h pydebug.h \ - pyerrors.h pyfpe.h pystate.h python.h pythonrun.h rangeobject.h \ - sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h \ - yuv.h - syslogmodule.obj: abstract.h ceval.h classobject.h cobject.h \ complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ funcobject.h import.h intobject.h intrcheck.h listobject.h \ @@ -830,14 +668,6 @@ python.h pythonrun.h rangeobject.h sliceobject.h stringobject.h \ sysmodule.h traceback.h tupleobject.h -timingmodule.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h timing.h traceback.h tupleobject.h - xxmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ import.h intobject.h intrcheck.h listobject.h longobject.h \ Modified: python/branches/py3k-struni/PC/pyconfig.h ============================================================================== --- python/branches/py3k-struni/PC/pyconfig.h (original) +++ python/branches/py3k-struni/PC/pyconfig.h Thu Jun 7 01:52:48 2007 @@ -488,22 +488,13 @@ /* Define if you want to use the GNU readline library */ /* #define WITH_READLINE 1 */ -/* Define as the integral type used for Unicode representation. */ -#define PY_UNICODE_TYPE unsigned short - /* Define as the size of the unicode type. */ -#define Py_UNICODE_SIZE SIZEOF_SHORT - -/* Define if you have a useable wchar_t type defined in wchar.h; useable - means wchar_t must be 16-bit unsigned type. (see - Include/unicodeobject.h). */ -#if Py_UNICODE_SIZE == 2 -#define HAVE_USABLE_WCHAR_T +/* This is enough for unicodeobject.h to do the "right thing" on Windows. */ +#define Py_UNICODE_SIZE 2 /* Define to indicate that the Python Unicode representation can be passed as-is to Win32 Wide API. */ #define Py_WIN_WIDE_FILENAMES -#endif /* Use Python's own small-block memory-allocator. */ #define WITH_PYMALLOC 1 Modified: python/branches/py3k-struni/PC/winsound.c ============================================================================== --- python/branches/py3k-struni/PC/winsound.c (original) +++ python/branches/py3k-struni/PC/winsound.c Thu Jun 7 01:52:48 2007 @@ -35,9 +35,9 @@ winsound.PlaySound(None, 0) */ +#include #include #include -#include #ifdef HAVE_CONIO_H #include /* port functions on Win9x */ #endif Modified: python/branches/py3k-struni/PCbuild/pythoncore.vcproj ============================================================================== --- python/branches/py3k-struni/PCbuild/pythoncore.vcproj (original) +++ python/branches/py3k-struni/PCbuild/pythoncore.vcproj Thu Jun 7 01:52:48 2007 @@ -626,12 +626,6 @@ RelativePath="..\Modules\mathmodule.c"> - - - - - - - - Modified: python/branches/py3k-struni/Python/ast.c ============================================================================== --- python/branches/py3k-struni/Python/ast.c (original) +++ python/branches/py3k-struni/Python/ast.c Thu Jun 7 01:52:48 2007 @@ -324,6 +324,29 @@ } } +static const char* FORBIDDEN[] = { + "None", + "True", + "False", + NULL, +}; + +static int +forbidden_name(expr_ty e, const node *n) +{ + const char *id; + const char **p; + assert(PyString_Check(e->v.Name.id)); + id = PyString_AS_STRING(e->v.Name.id); + for (p = FORBIDDEN; *p; p++) { + if (strcmp(*p, id) == 0) { + ast_error(n, "assignment to keyword"); + return 1; + } + } + return 0; +} + /* Set the context ctx for expr_ty e, recursively traversing e. Only sets context for expr kinds that "can appear in assignment context" @@ -366,9 +389,9 @@ return 0; break; case Name_kind: - if (ctx == Store && - !strcmp(PyString_AS_STRING(e->v.Name.id), "None")) { - return ast_error(n, "assignment to None"); + if (ctx == Store) { + if (forbidden_name(e, n)) + return 0; /* forbidden_name() calls ast_error() */ } e->v.Name.ctx = ctx; break; @@ -1227,6 +1250,7 @@ { /* atom: '(' [yield_expr|testlist_comp] ')' | '[' [testlist_comp] ']' | '{' [dictmaker|testlist_comp] '}' | NAME | NUMBER | STRING+ + | '...' | 'None' | 'True' | 'False' */ node *ch = CHILD(n, 0); int bytesmode = 0; @@ -1894,7 +1918,9 @@ } else if (e->kind != Name_kind) { ast_error(CHILD(ch, 0), "keyword can't be an expression"); return NULL; - } + } else if (forbidden_name(e, ch)) { + return NULL; + } key = e->v.Name.id; e = ast_for_expr(c, CHILD(ch, 2)); if (!e) @@ -1981,11 +2007,8 @@ "expression not possible"); return NULL; case Name_kind: { - const char *var_name = PyString_AS_STRING(expr1->v.Name.id); - if (var_name[0] == 'N' && !strcmp(var_name, "None")) { - ast_error(ch, "assignment to None"); + if (forbidden_name(expr1, ch)) return NULL; - } break; } case Attribute_kind: Modified: python/branches/py3k-struni/Python/bltinmodule.c ============================================================================== --- python/branches/py3k-struni/Python/bltinmodule.c (original) +++ python/branches/py3k-struni/Python/bltinmodule.c Thu Jun 7 01:52:48 2007 @@ -1698,17 +1698,6 @@ On Unix, GNU readline is used if enabled. The prompt string, if given,\n\ is printed without a trailing newline before reading."); -static PyObject * -builtin_reload(PyObject *self, PyObject *v) -{ - return PyImport_ReloadModule(v); -} - -PyDoc_STRVAR(reload_doc, -"reload(module) -> module\n\ -\n\ -Reload the module. The module must have been successfully imported before."); - static PyObject * builtin_repr(PyObject *self, PyObject *v) @@ -2006,7 +1995,6 @@ {"ord", builtin_ord, METH_O, ord_doc}, {"pow", builtin_pow, METH_VARARGS, pow_doc}, {"print", (PyCFunction)builtin_print, METH_VARARGS | METH_KEYWORDS, print_doc}, - {"reload", builtin_reload, METH_O, reload_doc}, {"repr", builtin_repr, METH_O, repr_doc}, {"round", (PyCFunction)builtin_round, METH_VARARGS | METH_KEYWORDS, round_doc}, {"setattr", builtin_setattr, METH_VARARGS, setattr_doc}, Modified: python/branches/py3k-struni/Python/ceval.c ============================================================================== --- python/branches/py3k-struni/Python/ceval.c (original) +++ python/branches/py3k-struni/Python/ceval.c Thu Jun 7 01:52:48 2007 @@ -2939,10 +2939,6 @@ Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); - /* For b/w compatibility */ - PySys_SetObject("exc_type", type); - PySys_SetObject("exc_value", value); - PySys_SetObject("exc_traceback", tb); } static void @@ -2973,11 +2969,6 @@ Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); - /* For b/w compatibility */ - PySys_SetObject("exc_type", frame->f_exc_type); - PySys_SetObject("exc_value", frame->f_exc_value); - PySys_SetObject("exc_traceback", frame->f_exc_traceback); - /* Clear the frame's exception info. */ tmp_type = frame->f_exc_type; tmp_value = frame->f_exc_value; Modified: python/branches/py3k-struni/Python/dynload_win.c ============================================================================== --- python/branches/py3k-struni/Python/dynload_win.c (original) +++ python/branches/py3k-struni/Python/dynload_win.c Thu Jun 7 01:52:48 2007 @@ -1,7 +1,6 @@ /* Support for dynamic loading of extension modules */ -#include #ifdef HAVE_DIRECT_H #include #endif @@ -9,6 +8,7 @@ #include "Python.h" #include "importdl.h" +#include const struct filedescr _PyImport_DynLoadFiletab[] = { #ifdef _DEBUG Modified: python/branches/py3k-struni/Python/graminit.c ============================================================================== --- python/branches/py3k-struni/Python/graminit.c (original) +++ python/branches/py3k-struni/Python/graminit.c Thu Jun 7 01:52:48 2007 @@ -1285,7 +1285,7 @@ {1, arcs_62_2}, {1, arcs_62_3}, }; -static arc arcs_63_0[7] = { +static arc arcs_63_0[10] = { {13, 1}, {146, 2}, {148, 3}, @@ -1293,6 +1293,9 @@ {151, 4}, {152, 5}, {77, 4}, + {153, 4}, + {154, 4}, + {155, 4}, }; static arc arcs_63_1[3] = { {46, 6}, @@ -1324,7 +1327,7 @@ {150, 4}, }; static state states_63[9] = { - {7, arcs_63_0}, + {10, arcs_63_0}, {3, arcs_63_1}, {2, arcs_63_2}, {2, arcs_63_3}, @@ -1338,7 +1341,7 @@ {24, 1}, }; static arc arcs_64_1[3] = { - {153, 2}, + {156, 2}, {30, 3}, {0, 1}, }; @@ -1370,7 +1373,7 @@ {15, 5}, }; static arc arcs_65_2[1] = { - {154, 6}, + {157, 6}, }; static arc arcs_65_3[1] = { {21, 5}, @@ -1394,14 +1397,14 @@ {1, arcs_65_6}, }; static arc arcs_66_0[1] = { - {155, 1}, + {158, 1}, }; static arc arcs_66_1[2] = { {30, 2}, {0, 1}, }; static arc arcs_66_2[2] = { - {155, 1}, + {158, 1}, {0, 2}, }; static state states_66[3] = { @@ -1419,11 +1422,11 @@ }; static arc arcs_67_2[3] = { {24, 3}, - {156, 4}, + {159, 4}, {0, 2}, }; static arc arcs_67_3[2] = { - {156, 4}, + {159, 4}, {0, 3}, }; static arc arcs_67_4[1] = { @@ -1488,7 +1491,7 @@ }; static arc arcs_71_1[4] = { {25, 2}, - {153, 3}, + {156, 3}, {30, 4}, {0, 1}, }; @@ -1529,7 +1532,7 @@ {1, arcs_71_8}, }; static arc arcs_72_0[1] = { - {157, 1}, + {160, 1}, }; static arc arcs_72_1[1] = { {21, 2}, @@ -1565,7 +1568,7 @@ {1, arcs_72_7}, }; static arc arcs_73_0[3] = { - {158, 1}, + {161, 1}, {31, 2}, {32, 3}, }; @@ -1580,7 +1583,7 @@ {24, 6}, }; static arc arcs_73_4[4] = { - {158, 1}, + {161, 1}, {31, 2}, {32, 3}, {0, 4}, @@ -1609,7 +1612,7 @@ {24, 1}, }; static arc arcs_74_1[3] = { - {153, 2}, + {156, 2}, {29, 3}, {0, 1}, }; @@ -1626,8 +1629,8 @@ {1, arcs_74_3}, }; static arc arcs_75_0[2] = { - {153, 1}, - {160, 1}, + {156, 1}, + {163, 1}, }; static arc arcs_75_1[1] = { {0, 1}, @@ -1649,7 +1652,7 @@ {105, 4}, }; static arc arcs_76_4[2] = { - {159, 5}, + {162, 5}, {0, 4}, }; static arc arcs_76_5[1] = { @@ -1670,7 +1673,7 @@ {107, 2}, }; static arc arcs_77_2[2] = { - {159, 3}, + {162, 3}, {0, 2}, }; static arc arcs_77_3[1] = { @@ -1704,7 +1707,7 @@ {1, arcs_79_1}, }; static arc arcs_80_0[1] = { - {163, 1}, + {166, 1}, }; static arc arcs_80_1[2] = { {9, 2}, @@ -1720,11 +1723,11 @@ }; static dfa dfas[81] = { {256, "single_input", 0, 3, states_0, - "\004\050\060\200\000\000\000\050\170\052\034\144\011\040\004\000\200\041\224\041\010"}, + "\004\050\060\200\000\000\000\050\170\052\034\144\011\040\004\000\200\041\224\017\101"}, {257, "file_input", 0, 2, states_1, - "\204\050\060\200\000\000\000\050\170\052\034\144\011\040\004\000\200\041\224\041\010"}, + "\204\050\060\200\000\000\000\050\170\052\034\144\011\040\004\000\200\041\224\017\101"}, {258, "eval_input", 0, 3, states_2, - "\000\040\040\200\000\000\000\000\000\040\000\000\000\040\004\000\200\041\224\001\000"}, + "\000\040\040\200\000\000\000\000\000\040\000\000\000\040\004\000\200\041\224\017\000"}, {259, "decorator", 0, 7, states_3, "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {260, "decorators", 0, 2, states_4, @@ -1744,13 +1747,13 @@ {267, "vfpdef", 0, 2, states_11, "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {268, "stmt", 0, 2, states_12, - "\000\050\060\200\000\000\000\050\170\052\034\144\011\040\004\000\200\041\224\041\010"}, + "\000\050\060\200\000\000\000\050\170\052\034\144\011\040\004\000\200\041\224\017\101"}, {269, "simple_stmt", 0, 4, states_13, - "\000\040\040\200\000\000\000\050\170\052\034\000\000\040\004\000\200\041\224\001\010"}, + "\000\040\040\200\000\000\000\050\170\052\034\000\000\040\004\000\200\041\224\017\100"}, {270, "small_stmt", 0, 2, states_14, - "\000\040\040\200\000\000\000\050\170\052\034\000\000\040\004\000\200\041\224\001\010"}, + "\000\040\040\200\000\000\000\050\170\052\034\000\000\040\004\000\200\041\224\017\100"}, {271, "expr_stmt", 0, 6, states_15, - "\000\040\040\200\000\000\000\000\000\040\000\000\000\040\004\000\200\041\224\001\000"}, + "\000\040\040\200\000\000\000\000\000\040\000\000\000\040\004\000\200\041\224\017\000"}, {272, "augassign", 0, 2, states_16, "\000\000\000\000\000\200\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {273, "del_stmt", 0, 3, states_17, @@ -1758,7 +1761,7 @@ {274, "pass_stmt", 0, 2, states_18, "\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {275, "flow_stmt", 0, 2, states_19, - "\000\000\000\000\000\000\000\000\170\000\000\000\000\000\000\000\000\000\000\000\010"}, + "\000\000\000\000\000\000\000\000\170\000\000\000\000\000\000\000\000\000\000\000\100"}, {276, "break_stmt", 0, 2, states_20, "\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000"}, {277, "continue_stmt", 0, 2, states_21, @@ -1766,7 +1769,7 @@ {278, "return_stmt", 0, 3, states_22, "\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000"}, {279, "yield_stmt", 0, 2, states_23, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\010"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\100"}, {280, "raise_stmt", 0, 7, states_24, "\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000\000\000"}, {281, "import_stmt", 0, 2, states_25, @@ -1792,7 +1795,7 @@ {291, "assert_stmt", 0, 5, states_35, "\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000"}, {292, "compound_stmt", 0, 2, states_36, - "\000\010\020\000\000\000\000\000\000\000\000\144\011\000\000\000\000\000\000\040\000"}, + "\000\010\020\000\000\000\000\000\000\000\000\144\011\000\000\000\000\000\000\000\001"}, {293, "if_stmt", 0, 8, states_37, "\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000"}, {294, "while_stmt", 0, 8, states_38, @@ -1808,67 +1811,67 @@ {299, "except_clause", 0, 5, states_43, "\000\000\000\000\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000"}, {300, "suite", 0, 5, states_44, - "\004\040\040\200\000\000\000\050\170\052\034\000\000\040\004\000\200\041\224\001\010"}, + "\004\040\040\200\000\000\000\050\170\052\034\000\000\040\004\000\200\041\224\017\100"}, {301, "test", 0, 6, states_45, - "\000\040\040\200\000\000\000\000\000\040\000\000\000\040\004\000\200\041\224\001\000"}, + "\000\040\040\200\000\000\000\000\000\040\000\000\000\040\004\000\200\041\224\017\000"}, {302, "test_nocond", 0, 2, states_46, - "\000\040\040\200\000\000\000\000\000\040\000\000\000\040\004\000\200\041\224\001\000"}, + "\000\040\040\200\000\000\000\000\000\040\000\000\000\040\004\000\200\041\224\017\000"}, {303, "lambdef", 0, 5, states_47, "\000\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000"}, {304, "lambdef_nocond", 0, 5, states_48, "\000\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000"}, {305, "or_test", 0, 2, states_49, - "\000\040\040\200\000\000\000\000\000\040\000\000\000\000\004\000\200\041\224\001\000"}, + "\000\040\040\200\000\000\000\000\000\040\000\000\000\000\004\000\200\041\224\017\000"}, {306, "and_test", 0, 2, states_50, - "\000\040\040\200\000\000\000\000\000\040\000\000\000\000\004\000\200\041\224\001\000"}, + "\000\040\040\200\000\000\000\000\000\040\000\000\000\000\004\000\200\041\224\017\000"}, {307, "not_test", 0, 3, states_51, - "\000\040\040\200\000\000\000\000\000\040\000\000\000\000\004\000\200\041\224\001\000"}, + "\000\040\040\200\000\000\000\000\000\040\000\000\000\000\004\000\200\041\224\017\000"}, {308, "comparison", 0, 2, states_52, - "\000\040\040\200\000\000\000\000\000\040\000\000\000\000\000\000\200\041\224\001\000"}, + "\000\040\040\200\000\000\000\000\000\040\000\000\000\000\000\000\200\041\224\017\000"}, {309, "comp_op", 0, 4, states_53, "\000\000\000\000\000\000\000\000\000\000\000\200\000\000\304\037\000\000\000\000\000"}, {310, "star_expr", 0, 3, states_54, - "\000\040\040\200\000\000\000\000\000\040\000\000\000\000\000\000\200\041\224\001\000"}, + "\000\040\040\200\000\000\000\000\000\040\000\000\000\000\000\000\200\041\224\017\000"}, {311, "expr", 0, 2, states_55, - "\000\040\040\000\000\000\000\000\000\040\000\000\000\000\000\000\200\041\224\001\000"}, + "\000\040\040\000\000\000\000\000\000\040\000\000\000\000\000\000\200\041\224\017\000"}, {312, "xor_expr", 0, 2, states_56, - "\000\040\040\000\000\000\000\000\000\040\000\000\000\000\000\000\200\041\224\001\000"}, + "\000\040\040\000\000\000\000\000\000\040\000\000\000\000\000\000\200\041\224\017\000"}, {313, "and_expr", 0, 2, states_57, - "\000\040\040\000\000\000\000\000\000\040\000\000\000\000\000\000\200\041\224\001\000"}, + "\000\040\040\000\000\000\000\000\000\040\000\000\000\000\000\000\200\041\224\017\000"}, {314, "shift_expr", 0, 2, states_58, - "\000\040\040\000\000\000\000\000\000\040\000\000\000\000\000\000\200\041\224\001\000"}, + "\000\040\040\000\000\000\000\000\000\040\000\000\000\000\000\000\200\041\224\017\000"}, {315, "arith_expr", 0, 2, states_59, - "\000\040\040\000\000\000\000\000\000\040\000\000\000\000\000\000\200\041\224\001\000"}, + "\000\040\040\000\000\000\000\000\000\040\000\000\000\000\000\000\200\041\224\017\000"}, {316, "term", 0, 2, states_60, - "\000\040\040\000\000\000\000\000\000\040\000\000\000\000\000\000\200\041\224\001\000"}, + "\000\040\040\000\000\000\000\000\000\040\000\000\000\000\000\000\200\041\224\017\000"}, {317, "factor", 0, 3, states_61, - "\000\040\040\000\000\000\000\000\000\040\000\000\000\000\000\000\200\041\224\001\000"}, + "\000\040\040\000\000\000\000\000\000\040\000\000\000\000\000\000\200\041\224\017\000"}, {318, "power", 0, 4, states_62, - "\000\040\040\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\224\001\000"}, + "\000\040\040\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\224\017\000"}, {319, "atom", 0, 9, states_63, - "\000\040\040\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\224\001\000"}, + "\000\040\040\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\224\017\000"}, {320, "testlist_comp", 0, 5, states_64, - "\000\040\040\200\000\000\000\000\000\040\000\000\000\040\004\000\200\041\224\001\000"}, + "\000\040\040\200\000\000\000\000\000\040\000\000\000\040\004\000\200\041\224\017\000"}, {321, "trailer", 0, 7, states_65, "\000\040\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\004\000\000"}, {322, "subscriptlist", 0, 3, states_66, - "\000\040\040\202\000\000\000\000\000\040\000\000\000\040\004\000\200\041\224\001\000"}, + "\000\040\040\202\000\000\000\000\000\040\000\000\000\040\004\000\200\041\224\017\000"}, {323, "subscript", 0, 5, states_67, - "\000\040\040\202\000\000\000\000\000\040\000\000\000\040\004\000\200\041\224\001\000"}, + "\000\040\040\202\000\000\000\000\000\040\000\000\000\040\004\000\200\041\224\017\000"}, {324, "sliceop", 0, 3, states_68, "\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {325, "exprlist", 0, 3, states_69, - "\000\040\040\200\000\000\000\000\000\040\000\000\000\000\000\000\200\041\224\001\000"}, + "\000\040\040\200\000\000\000\000\000\040\000\000\000\000\000\000\200\041\224\017\000"}, {326, "testlist", 0, 3, states_70, - "\000\040\040\200\000\000\000\000\000\040\000\000\000\040\004\000\200\041\224\001\000"}, + "\000\040\040\200\000\000\000\000\000\040\000\000\000\040\004\000\200\041\224\017\000"}, {327, "dictorsetmaker", 0, 9, states_71, - "\000\040\040\200\000\000\000\000\000\040\000\000\000\040\004\000\200\041\224\001\000"}, + "\000\040\040\200\000\000\000\000\000\040\000\000\000\040\004\000\200\041\224\017\000"}, {328, "classdef", 0, 8, states_72, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\040\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001"}, {329, "arglist", 0, 8, states_73, - "\000\040\040\200\001\000\000\000\000\040\000\000\000\040\004\000\200\041\224\001\000"}, + "\000\040\040\200\001\000\000\000\000\040\000\000\000\040\004\000\200\041\224\017\000"}, {330, "argument", 0, 4, states_74, - "\000\040\040\200\000\000\000\000\000\040\000\000\000\040\004\000\200\041\224\001\000"}, + "\000\040\040\200\000\000\000\000\000\040\000\000\000\040\004\000\200\041\224\017\000"}, {331, "comp_iter", 0, 2, states_75, "\000\000\000\000\000\000\000\000\000\000\000\104\000\000\000\000\000\000\000\000\000"}, {332, "comp_for", 0, 6, states_76, @@ -1876,13 +1879,13 @@ {333, "comp_if", 0, 4, states_77, "\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000"}, {334, "testlist1", 0, 2, states_78, - "\000\040\040\200\000\000\000\000\000\040\000\000\000\040\004\000\200\041\224\001\000"}, + "\000\040\040\200\000\000\000\000\000\040\000\000\000\040\004\000\200\041\224\017\000"}, {335, "encoding_decl", 0, 2, states_79, "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {336, "yield_expr", 0, 3, states_80, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\010"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\100"}, }; -static label labels[164] = { +static label labels[167] = { {0, "EMPTY"}, {256, 0}, {4, 0}, @@ -2036,6 +2039,9 @@ {27, 0}, {2, 0}, {3, 0}, + {1, "None"}, + {1, "True"}, + {1, "False"}, {332, 0}, {322, 0}, {323, 0}, @@ -2051,6 +2057,6 @@ grammar _PyParser_Grammar = { 81, dfas, - {164, labels}, + {167, labels}, 256 }; Modified: python/branches/py3k-struni/Python/import.c ============================================================================== --- python/branches/py3k-struni/Python/import.c (original) +++ python/branches/py3k-struni/Python/import.c Thu Jun 7 01:52:48 2007 @@ -371,7 +371,6 @@ /* List of names to clear in sys */ static char* sys_deletes[] = { "path", "argv", "ps1", "ps2", - "exc_type", "exc_value", "exc_traceback", "last_type", "last_value", "last_traceback", "path_hooks", "path_importer_cache", "meta_path", NULL @@ -2413,7 +2412,7 @@ if (modules_reloading == NULL) { Py_FatalError("PyImport_ReloadModule: " - "no modules_reloading dictionary!"); + "no modules_reloading dictionary!"); return NULL; } @@ -2457,7 +2456,7 @@ "reload(): parent %.200s not in sys.modules", PyString_AS_STRING(parentname)); Py_DECREF(parentname); - imp_modules_reloading_clear(); + imp_modules_reloading_clear(); return NULL; } Py_DECREF(parentname); Modified: python/branches/py3k-struni/Python/sysmodule.c ============================================================================== --- python/branches/py3k-struni/Python/sysmodule.c (original) +++ python/branches/py3k-struni/Python/sysmodule.c Thu Jun 7 01:52:48 2007 @@ -163,33 +163,6 @@ ); static PyObject * -sys_exc_clear(PyObject *self, PyObject *noargs) -{ - PyThreadState *tstate = PyThreadState_GET(); - PyObject *tmp_type, *tmp_value, *tmp_tb; - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = NULL; - tstate->exc_value = NULL; - tstate->exc_traceback = NULL; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(exc_clear_doc, -"exc_clear() -> None\n\ -\n\ -Clear global information on the current exception. Subsequent calls to\n\ -exc_info() will return (None,None,None) until another exception is raised\n\ -in the current thread or the execution stack returns to a frame where\n\ -another exception is being handled." -); - -static PyObject * sys_exit(PyObject *self, PyObject *args) { PyObject *exit_code = 0; @@ -765,7 +738,6 @@ current_frames_doc}, {"displayhook", sys_displayhook, METH_O, displayhook_doc}, {"exc_info", sys_exc_info, METH_NOARGS, exc_info_doc}, - {"exc_clear", sys_exc_clear, METH_NOARGS, exc_clear_doc}, {"excepthook", sys_excepthook, METH_VARARGS, excepthook_doc}, {"exit", sys_exit, METH_VARARGS, exit_doc}, {"getdefaultencoding", (PyCFunction)sys_getdefaultencoding, @@ -907,12 +879,6 @@ last_traceback -- traceback of last uncaught exception\n\ These three are only available in an interactive session after a\n\ traceback has been printed.\n\ -\n\ -exc_type -- type of exception currently being handled\n\ -exc_value -- value of exception currently being handled\n\ -exc_traceback -- traceback of exception currently being handled\n\ - The function exc_info() should be used instead of these three,\n\ - because it is thread-safe.\n\ " ) /* concatenating string here */ @@ -953,7 +919,6 @@ displayhook() -- print an object to the screen, and save it in __builtin__._\n\ excepthook() -- print an exception and its traceback to sys.stderr\n\ exc_info() -- return thread-safe information about the current exception\n\ -exc_clear() -- clear the exception state for the current thread\n\ exit() -- exit the interpreter by raising SystemExit\n\ getdlopenflags() -- returns flags to be used for dlopen() calls\n\ getrefcount() -- return the reference count for an object (plus one :-)\n\ Modified: python/branches/py3k-struni/README ============================================================================== --- python/branches/py3k-struni/README (original) +++ python/branches/py3k-struni/README Thu Jun 7 01:52:48 2007 @@ -463,10 +463,10 @@ array, audioop, binascii, cPickle, cStringIO, cmath, crypt, curses, errno, fcntl, gdbm, grp, - _locale, math, md5, new, operator, parser, pcre, - posix, pwd, readline, regex, reop, - select, signal, socket, soundex, struct, - syslog, termios, time, timing, zlib, audioop + _locale, math, new, operator, parser, + posix, pwd, readline, regex, + select, signal, socket, struct, + syslog, termios, time, zlib, audioop 3) make SHELL=/usr/local/bin/bash @@ -520,9 +520,8 @@ _codecs, _locale, _socket, _symtable, _testcapi, _weakref array, binascii, cmath, cPickle, crypt, cStringIO, dbm - errno, fcntl, grp, math, md5, operator, parser, pwd - rotor, select, struct, syslog, termios, - time, timing + errno, fcntl, grp, math, operator, parser, pwd + rotor, select, struct, syslog, termios, time 4) Once the python executable and library have been built, make will execute setup.py, which will attempt to build remaining Modified: python/branches/py3k-struni/setup.py ============================================================================== --- python/branches/py3k-struni/setup.py (original) +++ python/branches/py3k-struni/setup.py Thu Jun 7 01:52:48 2007 @@ -477,11 +477,6 @@ else: missing.append('syslog') - # George Neville-Neil's timing module: - # Deprecated in PEP 4 http://www.python.org/peps/pep-0004.html - # http://mail.python.org/pipermail/python-dev/2006-January/060023.html - #exts.append( Extension('timing', ['timingmodule.c']) ) - # # Here ends the simple stuff. From here on, modules need certain # libraries, are platform-specific, or present other surprises. @@ -612,16 +607,7 @@ include_dirs = ssl_incs, library_dirs = ssl_libs, libraries = ['ssl', 'crypto']) ) - missing.extend(['_sha', '_md5']) else: - # The _sha module implements the SHA1 hash algorithm. - exts.append( Extension('_sha', ['shamodule.c']) ) - # The _md5 module implements the RSA Data Security, Inc. MD5 - # Message-Digest Algorithm, described in RFC 1321. The - # necessary files md5.c and md5.h are included here. - exts.append( Extension('_md5', - sources = ['md5module.c', 'md5.c'], - depends = ['md5.h']) ) missing.append('_hashlib') if (openssl_ver < 0x00908000): From python-3000-checkins at python.org Thu Jun 7 02:54:21 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 7 Jun 2007 02:54:21 +0200 (CEST) Subject: [Python-3000-checkins] r55796 - in python/branches/py3k-struni: Lib/io.py Lib/test/test_tarfile.py Parser/tokenizer.c Message-ID: <20070607005421.74B961E4005@bag.python.org> Author: guido.van.rossum Date: Thu Jun 7 02:54:15 2007 New Revision: 55796 Modified: python/branches/py3k-struni/Lib/io.py python/branches/py3k-struni/Lib/test/test_tarfile.py python/branches/py3k-struni/Parser/tokenizer.c Log: tokenizer.c: make coding markup work again. io.open() now takes all positional parameters (so we can conveniently call it from C code). test_tarfile.py no longer uses u"..." literals, but is otherwise still badly broken. This is a checkpoint; some more stuff now breaks. Modified: python/branches/py3k-struni/Lib/io.py ============================================================================== --- python/branches/py3k-struni/Lib/io.py (original) +++ python/branches/py3k-struni/Lib/io.py Thu Jun 7 02:54:15 2007 @@ -49,7 +49,7 @@ self.characters_written = characters_written -def open(file, mode="r", buffering=None, *, encoding=None, newline=None): +def open(file, mode="r", buffering=None, encoding=None, newline=None): """Replacement for the built-in open function. Args: @@ -59,7 +59,6 @@ buffering: optional int >= 0 giving the buffer size; values can be: 0 = unbuffered, 1 = line buffered, larger = fully buffered. - Keywords (for text modes only; *must* be given as keyword arguments): encoding: optional string giving the text encoding. newline: optional newlines specifier; must be None, '\n' or '\r\n'; specifies the line ending expected on input and written on Modified: python/branches/py3k-struni/Lib/test/test_tarfile.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_tarfile.py (original) +++ python/branches/py3k-struni/Lib/test/test_tarfile.py Thu Jun 7 02:54:15 2007 @@ -432,17 +432,17 @@ tarinfo = tar.getmember("pax/regtype1") self.assertEqual(tarinfo.uname, "foo") self.assertEqual(tarinfo.gname, "bar") - self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), u"???????") + self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), "???????") tarinfo = tar.getmember("pax/regtype2") self.assertEqual(tarinfo.uname, "") self.assertEqual(tarinfo.gname, "bar") - self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), u"???????") + self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), "???????") tarinfo = tar.getmember("pax/regtype3") self.assertEqual(tarinfo.uname, "tarfile") self.assertEqual(tarinfo.gname, "tarfile") - self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), u"???????") + self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), "???????") def test_pax_number_fields(self): # All following number fields are read from the pax header. @@ -727,11 +727,11 @@ def test_pax_global_header(self): pax_headers = { - u"foo": u"bar", - u"uid": u"0", - u"mtime": u"1.23", - u"test": u"???", - u"???": u"test"} + "foo": "bar", + "uid": "0", + "mtime": "1.23", + "test": "???", + "???": "test"} tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT, \ pax_headers=pax_headers) @@ -756,11 +756,11 @@ def test_pax_extended_header(self): # The fields from the pax header have priority over the # TarInfo. - pax_headers = {u"path": u"foo", u"uid": u"123"} + pax_headers = {"path": "foo", "uid": "123"} tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT, encoding="iso8859-1") t = tarfile.TarInfo() - t.name = u"???" # non-ASCII + t.name = "???" # non-ASCII t.uid = 8**8 # too large t.pax_headers = pax_headers tar.addfile(t) @@ -808,11 +808,11 @@ else: tar.addfile(tarinfo) - tarinfo.name = u"???" + tarinfo.name = "???" self.assertRaises(UnicodeError, tar.addfile, tarinfo) tarinfo.name = "foo" - tarinfo.uname = u"???" + tarinfo.uname = "???" self.assertRaises(UnicodeError, tar.addfile, tarinfo) def test_unicode_argument(self): @@ -825,7 +825,7 @@ tar.close() def test_uname_unicode(self): - for name in (u"???", "???"): + for name in ("???", "???"): t = tarfile.TarInfo("foo") t.uname = name t.gname = name @@ -860,9 +860,9 @@ def test_error_handlers(self): # Test if the unicode error handlers work correctly for characters # that cannot be expressed in a given encoding. - self._create_unicode_name(u"???") + self._create_unicode_name("???") - for handler, name in (("utf-8", u"???".encode("utf8")), + for handler, name in (("utf-8", "???".encode("utf8")), ("replace", "???"), ("ignore", "")): tar = tarfile.open(tmpname, format=self.format, encoding="ascii", errors=handler) @@ -874,11 +874,11 @@ def test_error_handler_utf8(self): # Create a pathname that has one component representable using # iso8859-1 and the other only in iso8859-15. - self._create_unicode_name(u"???/?") + self._create_unicode_name("???/?") tar = tarfile.open(tmpname, format=self.format, encoding="iso8859-1", errors="utf-8") - self.assertEqual(tar.getnames()[0], "???/" + u"?".encode("utf8")) + self.assertEqual(tar.getnames()[0], "???/" + "?".encode("utf8")) class AppendTest(unittest.TestCase): Modified: python/branches/py3k-struni/Parser/tokenizer.c ============================================================================== --- python/branches/py3k-struni/Parser/tokenizer.c (original) +++ python/branches/py3k-struni/Parser/tokenizer.c Thu Jun 7 02:54:15 2007 @@ -396,25 +396,29 @@ static int fp_setreadl(struct tok_state *tok, const char* enc) { - PyObject *reader, *stream, *readline; + PyObject *readline = NULL, *stream = NULL, *io = NULL; + int ok = 0; - /* XXX: constify filename argument. */ - stream = PyFile_FromFile(tok->fp, (char*)tok->filename, "rb", NULL); - if (stream == NULL) - return 0; + io = PyImport_ImportModule("io"); + if (io == NULL) + goto cleanup; - reader = PyCodec_StreamReader(enc, stream, NULL); - Py_DECREF(stream); - if (reader == NULL) - return 0; + stream = PyObject_CallMethod(io, "open", "ssis", + tok->filename, "r", -1, enc); + if (stream == NULL) + goto cleanup; - readline = PyObject_GetAttrString(reader, "readline"); - Py_DECREF(reader); + readline = PyObject_GetAttrString(stream, "readline"); if (readline == NULL) - return 0; + goto cleanup; tok->decoding_readline = readline; - return 1; + ok = 1; + + cleanup: + Py_XDECREF(stream); + Py_XDECREF(io); + return ok; } /* Fetch the next byte from TOK. */ From python-3000-checkins at python.org Thu Jun 7 09:01:01 2007 From: python-3000-checkins at python.org (neal.norwitz) Date: Thu, 7 Jun 2007 09:01:01 +0200 (CEST) Subject: [Python-3000-checkins] r55797 - in python/branches/p3yk/Lib: bsddb/dbtables.py cgitb.py copy.py dis.py distutils/cmd.py distutils/dist.py distutils/extension.py distutils/text_file.py distutils/unixccompiler.py idlelib/CallTips.py idlelib/ObjectBrowser.py idlelib/rpc.py inspect.py lib-tk/ScrolledText.py lib-tk/Tkinter.py logging/__init__.py logging/config.py logging/handlers.py new.py optparse.py pickle.py pickletools.py plat-mac/aepack.py plat-mac/aetypes.py plat-mac/gensuitemodule.py pydoc.py sre_parse.py subprocess.py test/test_descr.py test/test_isinstance.py test/test_logging.py test/test_optparse.py test/test_pyclbr.py types.py unittest.py urllib2.py warnings.py wsgiref/headers.py wsgiref/validate.py xml/sax/saxutils.py xmlrpclib.py Message-ID: <20070607070101.340F31E4006@bag.python.org> Author: neal.norwitz Date: Thu Jun 7 09:00:57 2007 New Revision: 55797 Modified: python/branches/p3yk/Lib/bsddb/dbtables.py python/branches/p3yk/Lib/cgitb.py python/branches/p3yk/Lib/copy.py python/branches/p3yk/Lib/dis.py python/branches/p3yk/Lib/distutils/cmd.py python/branches/p3yk/Lib/distutils/dist.py python/branches/p3yk/Lib/distutils/extension.py python/branches/p3yk/Lib/distutils/text_file.py python/branches/p3yk/Lib/distutils/unixccompiler.py python/branches/p3yk/Lib/idlelib/CallTips.py python/branches/p3yk/Lib/idlelib/ObjectBrowser.py python/branches/p3yk/Lib/idlelib/rpc.py python/branches/p3yk/Lib/inspect.py python/branches/p3yk/Lib/lib-tk/ScrolledText.py python/branches/p3yk/Lib/lib-tk/Tkinter.py python/branches/p3yk/Lib/logging/__init__.py python/branches/p3yk/Lib/logging/config.py python/branches/p3yk/Lib/logging/handlers.py python/branches/p3yk/Lib/new.py python/branches/p3yk/Lib/optparse.py python/branches/p3yk/Lib/pickle.py python/branches/p3yk/Lib/pickletools.py python/branches/p3yk/Lib/plat-mac/aepack.py python/branches/p3yk/Lib/plat-mac/aetypes.py python/branches/p3yk/Lib/plat-mac/gensuitemodule.py python/branches/p3yk/Lib/pydoc.py python/branches/p3yk/Lib/sre_parse.py python/branches/p3yk/Lib/subprocess.py python/branches/p3yk/Lib/test/test_descr.py python/branches/p3yk/Lib/test/test_isinstance.py python/branches/p3yk/Lib/test/test_logging.py python/branches/p3yk/Lib/test/test_optparse.py python/branches/p3yk/Lib/test/test_pyclbr.py python/branches/p3yk/Lib/types.py python/branches/p3yk/Lib/unittest.py python/branches/p3yk/Lib/urllib2.py python/branches/p3yk/Lib/warnings.py python/branches/p3yk/Lib/wsgiref/headers.py python/branches/p3yk/Lib/wsgiref/validate.py python/branches/p3yk/Lib/xml/sax/saxutils.py python/branches/p3yk/Lib/xmlrpclib.py Log: Get rid of some remnants of classic classes. types.ClassType == type. Also get rid of almost all uses of the types module and use the builtin name. Modified: python/branches/p3yk/Lib/bsddb/dbtables.py ============================================================================== --- python/branches/p3yk/Lib/bsddb/dbtables.py (original) +++ python/branches/p3yk/Lib/bsddb/dbtables.py Thu Jun 7 09:00:57 2007 @@ -22,7 +22,6 @@ import copy import xdrlib import random -from types import ListType, StringType import cPickle as pickle try: @@ -229,7 +228,7 @@ raises TableDBError if it already exists or for other DB errors. """ - assert isinstance(columns, ListType) + assert isinstance(columns, list) txn = None try: # checking sanity of the table and column names here on @@ -270,7 +269,7 @@ """Return a list of columns in the given table. [] if the table doesn't exist. """ - assert isinstance(table, StringType) + assert isinstance(table, str) if contains_metastrings(table): raise ValueError, "bad table name: contains reserved metastrings" @@ -300,7 +299,7 @@ additional columns present in the given list as well as all of its current columns. """ - assert isinstance(columns, ListType) + assert isinstance(columns, list) try: self.CreateTable(table, columns) except TableAlreadyExists: Modified: python/branches/p3yk/Lib/cgitb.py ============================================================================== --- python/branches/p3yk/Lib/cgitb.py (original) +++ python/branches/p3yk/Lib/cgitb.py Thu Jun 7 09:00:57 2007 @@ -96,10 +96,10 @@ def html(einfo, context=5): """Return a nice HTML document describing a given traceback.""" - import os, types, time, traceback, linecache, inspect, pydoc + import os, time, traceback, linecache, inspect, pydoc etype, evalue, etb = einfo - if type(etype) is types.ClassType: + if isinstance(etype, type): etype = etype.__name__ pyver = 'Python ' + sys.version.split()[0] + ': ' + sys.executable date = time.ctime(time.time()) @@ -188,10 +188,10 @@ def text(einfo, context=5): """Return a plain text document describing a given traceback.""" - import os, types, time, traceback, linecache, inspect, pydoc + import os, time, traceback, linecache, inspect, pydoc etype, evalue, etb = einfo - if type(etype) is types.ClassType: + if isinstance(etype, type): etype = etype.__name__ pyver = 'Python ' + sys.version.split()[0] + ': ' + sys.executable date = time.ctime(time.time()) Modified: python/branches/p3yk/Lib/copy.py ============================================================================== --- python/branches/p3yk/Lib/copy.py (original) +++ python/branches/p3yk/Lib/copy.py Thu Jun 7 09:00:57 2007 @@ -100,12 +100,15 @@ def _copy_immutable(x): return x for t in (type(None), int, float, bool, str, tuple, - frozenset, type, range, types.ClassType, + frozenset, type, range, types.BuiltinFunctionType, types.FunctionType): d[t] = _copy_immutable -for name in ("ComplexType", "UnicodeType", "CodeType"): - t = getattr(types, name, None) +t = getattr(types, "CodeType", None) +if t is not None: + d[t] = _copy_immutable +for name in ("complex", "unicode"): + t = globals()['__builtins__'].get(name) if t is not None: d[t] = _copy_immutable @@ -195,7 +198,6 @@ pass d[type] = _deepcopy_atomic d[range] = _deepcopy_atomic -d[types.ClassType] = _deepcopy_atomic d[types.BuiltinFunctionType] = _deepcopy_atomic d[types.FunctionType] = _deepcopy_atomic Modified: python/branches/p3yk/Lib/dis.py ============================================================================== --- python/branches/p3yk/Lib/dis.py (original) +++ python/branches/p3yk/Lib/dis.py Thu Jun 7 09:00:57 2007 @@ -26,7 +26,7 @@ items = sorted(x.__dict__.items()) for name, x1 in items: if isinstance(x1, (types.MethodType, types.FunctionType, - types.CodeType, types.ClassType, type)): + types.CodeType, type)): print("Disassembly of %s:" % name) try: dis(x1) Modified: python/branches/p3yk/Lib/distutils/cmd.py ============================================================================== --- python/branches/p3yk/Lib/distutils/cmd.py (original) +++ python/branches/p3yk/Lib/distutils/cmd.py Thu Jun 7 09:00:57 2007 @@ -9,7 +9,6 @@ __revision__ = "$Id$" import sys, os, re -from types import * from distutils.errors import * from distutils import util, dir_util, file_util, archive_util, dep_util from distutils import log @@ -222,7 +221,7 @@ if val is None: setattr(self, option, default) return default - elif type(val) is not StringType: + elif not isinstance(val, str): raise DistutilsOptionError, \ "'%s' must be a %s (got `%s`)" % (option, what, val) return val @@ -242,12 +241,12 @@ val = getattr(self, option) if val is None: return - elif type(val) is StringType: + elif isinstance(val, str): setattr(self, option, re.split(r',\s*|\s+', val)) else: - if type(val) is ListType: + if isinstance(val, list): types = map(type, val) - ok = (types == [StringType] * len(val)) + ok = (types == [str] * len(val)) else: ok = 0 @@ -421,9 +420,9 @@ # Allow 'infiles' to be a single string - if type(infiles) is StringType: + if isinstance(infiles, str): infiles = (infiles,) - elif type(infiles) not in (ListType, TupleType): + elif not isinstance(infiles, (list, tuple)): raise TypeError, \ "'infiles' must be a string, or a list or tuple of strings" Modified: python/branches/p3yk/Lib/distutils/dist.py ============================================================================== --- python/branches/p3yk/Lib/distutils/dist.py (original) +++ python/branches/p3yk/Lib/distutils/dist.py Thu Jun 7 09:00:57 2007 @@ -9,7 +9,6 @@ __revision__ = "$Id$" import sys, os, re -from types import * from copy import copy try: @@ -527,7 +526,7 @@ # Also make sure that the command object provides a list of its # known options. if not (hasattr(cmd_class, 'user_options') and - type(cmd_class.user_options) is ListType): + isinstance(cmd_class.user_options, list)): raise DistutilsClassError, \ ("command class %s must provide " + "'user_options' attribute (a list of tuples)") % \ @@ -543,7 +542,7 @@ # Check for help_options in command class. They have a different # format (tuple of four) so we need to preprocess them here. if (hasattr(cmd_class, 'help_options') and - type(cmd_class.help_options) is ListType): + isinstance(cmd_class.help_options, list)): help_options = fix_help_options(cmd_class.help_options) else: help_options = [] @@ -561,7 +560,7 @@ return if (hasattr(cmd_class, 'help_options') and - type(cmd_class.help_options) is ListType): + isinstance(cmd_class.help_options, list)): help_option_found=0 for (help_option, short, desc, func) in cmd_class.help_options: if hasattr(opts, parser.get_attr_name(help_option)): @@ -598,13 +597,13 @@ keywords = self.metadata.keywords if keywords is not None: - if type(keywords) is StringType: + if isinstance(keywords, str): keywordlist = keywords.split(',') self.metadata.keywords = [x.strip() for x in keywordlist] platforms = self.metadata.platforms if platforms is not None: - if type(platforms) is StringType: + if isinstance(platforms, str): platformlist = platforms.split(',') self.metadata.platforms = [x.strip() for x in platformlist] @@ -646,12 +645,12 @@ print() for command in self.commands: - if type(command) is ClassType and issubclass(command, Command): + if isinstance(command, type) and issubclass(command, Command): klass = command else: klass = self.get_command_class(command) if (hasattr(klass, 'help_options') and - type(klass.help_options) is ListType): + isinstance(klass.help_options, list)): parser.set_option_table(klass.user_options + fix_help_options(klass.help_options)) else: @@ -906,7 +905,7 @@ neg_opt = {} try: - is_string = type(value) is StringType + is_string = isinstance(value, str) if option in neg_opt and is_string: setattr(command_obj, neg_opt[option], not strtobool(value)) elif option in bool_opts and is_string: Modified: python/branches/p3yk/Lib/distutils/extension.py ============================================================================== --- python/branches/p3yk/Lib/distutils/extension.py (original) +++ python/branches/p3yk/Lib/distutils/extension.py Thu Jun 7 09:00:57 2007 @@ -6,7 +6,6 @@ __revision__ = "$Id$" import os, sys -from types import * try: import warnings @@ -103,9 +102,9 @@ language=None, **kw # To catch unknown keywords ): - assert type(name) is StringType, "'name' must be a string" - assert (type(sources) is ListType and - map(type, sources) == [StringType]*len(sources)), \ + assert isinstance(name, str), "'name' must be a string" + assert (isinstance(sources, list) and + map(type, sources) == [str]*len(sources)), \ "'sources' must be a list of strings" self.name = name Modified: python/branches/p3yk/Lib/distutils/text_file.py ============================================================================== --- python/branches/p3yk/Lib/distutils/text_file.py (original) +++ python/branches/p3yk/Lib/distutils/text_file.py Thu Jun 7 09:00:57 2007 @@ -6,7 +6,6 @@ __revision__ = "$Id$" -from types import * import sys, os @@ -137,7 +136,7 @@ if line is None: line = self.current_line outmsg.append(self.filename + ", ") - if type (line) in (ListType, TupleType): + if isinstance (line, (list, tuple)): outmsg.append("lines %d-%d: " % tuple (line)) else: outmsg.append("line %d: " % line) @@ -239,7 +238,7 @@ line = buildup_line + line # careful: pay attention to line number when incrementing it - if type (self.current_line) is ListType: + if isinstance (self.current_line, list): self.current_line[1] = self.current_line[1] + 1 else: self.current_line = [self.current_line, @@ -250,7 +249,7 @@ return None # still have to be careful about incrementing the line number! - if type (self.current_line) is ListType: + if isinstance (self.current_line, list): self.current_line = self.current_line[1] + 1 else: self.current_line = self.current_line + 1 Modified: python/branches/p3yk/Lib/distutils/unixccompiler.py ============================================================================== --- python/branches/p3yk/Lib/distutils/unixccompiler.py (original) +++ python/branches/p3yk/Lib/distutils/unixccompiler.py Thu Jun 7 09:00:57 2007 @@ -16,7 +16,6 @@ __revision__ = "$Id$" import os, sys -from types import StringType, NoneType from copy import copy from distutils import sysconfig @@ -212,7 +211,7 @@ lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs, libraries) - if type(output_dir) not in (StringType, NoneType): + if not isinstance(output_dir, (str, type(None)): raise TypeError, "'output_dir' must be a string or None" if output_dir is not None: output_filename = os.path.join(output_dir, output_filename) Modified: python/branches/p3yk/Lib/idlelib/CallTips.py ============================================================================== --- python/branches/p3yk/Lib/idlelib/CallTips.py (original) +++ python/branches/p3yk/Lib/idlelib/CallTips.py Thu Jun 7 09:00:57 2007 @@ -131,14 +131,14 @@ arg_text = "" if ob is not None: arg_offset = 0 - if type(ob) in (types.ClassType, types.TypeType): + if isinstance(ob, type): # Look for the highest __init__ in the class chain. fob = _find_constructor(ob) if fob is None: fob = lambda: None else: arg_offset = 1 - elif type(ob)==types.MethodType: + elif isinstace(ob, types.MethodType): # bit of a hack for methods - turn it into a function # but we drop the "self" param. fob = ob.im_func @@ -146,7 +146,7 @@ else: fob = ob # Try to build one for Python defined functions - if type(fob) in [types.FunctionType, types.LambdaType]: + if isinstance(fob, (types.FunctionType, types.LambdaType)): argcount = fob.__code__.co_argcount real_args = fob.__code__.co_varnames[arg_offset:argcount] defaults = fob.__defaults__ or [] Modified: python/branches/p3yk/Lib/idlelib/ObjectBrowser.py ============================================================================== --- python/branches/p3yk/Lib/idlelib/ObjectBrowser.py (original) +++ python/branches/p3yk/Lib/idlelib/ObjectBrowser.py Thu Jun 7 09:00:57 2007 @@ -101,17 +101,14 @@ pass return keys -from types import * - dispatch = { - IntType: AtomicObjectTreeItem, - LongType: AtomicObjectTreeItem, - FloatType: AtomicObjectTreeItem, - StringType: AtomicObjectTreeItem, - TupleType: SequenceTreeItem, - ListType: SequenceTreeItem, - DictType: DictTreeItem, - ClassType: ClassTreeItem, + int: AtomicObjectTreeItem, + float: AtomicObjectTreeItem, + str: AtomicObjectTreeItem, + tuple: SequenceTreeItem, + list: SequenceTreeItem, + dict: DictTreeItem, + type: ClassTreeItem, } def make_objecttreeitem(labeltext, object, setfunction=None): Modified: python/branches/p3yk/Lib/idlelib/rpc.py ============================================================================== --- python/branches/p3yk/Lib/idlelib/rpc.py (original) +++ python/branches/p3yk/Lib/idlelib/rpc.py Thu Jun 7 09:00:57 2007 @@ -287,7 +287,7 @@ def _proxify(self, obj): if isinstance(obj, RemoteProxy): return RPCProxy(self, obj.oid) - if isinstance(obj, types.ListType): + if isinstance(obj, list): return map(self._proxify, obj) # XXX Check for other types -- not currently needed return obj @@ -574,7 +574,7 @@ attr = getattr(obj, name) if hasattr(attr, '__call__'): methods[name] = 1 - if type(obj) == types.ClassType: + if isinstance(obj, type): for super in obj.__bases__: _getmethods(super, methods) Modified: python/branches/p3yk/Lib/inspect.py ============================================================================== --- python/branches/p3yk/Lib/inspect.py (original) +++ python/branches/p3yk/Lib/inspect.py Thu Jun 7 09:00:57 2007 @@ -47,7 +47,7 @@ Class objects provide these attributes: __doc__ documentation string __module__ name of module in which this class was defined""" - return isinstance(object, types.ClassType) or hasattr(object, '__bases__') + return isinstance(object, type) or hasattr(object, '__bases__') def ismethod(object): """Return true if the object is an instance method. @@ -313,7 +313,7 @@ doc = object.__doc__ except AttributeError: return None - if not isinstance(doc, types.StringTypes): + if not isinstance(doc, basestring): return None try: lines = doc.expandtabs().split('\n') Modified: python/branches/p3yk/Lib/lib-tk/ScrolledText.py ============================================================================== --- python/branches/p3yk/Lib/lib-tk/ScrolledText.py (original) +++ python/branches/p3yk/Lib/lib-tk/ScrolledText.py Thu Jun 7 09:00:57 2007 @@ -21,7 +21,7 @@ cnf = _cnfmerge((cnf, kw)) fcnf = {} for k in cnf.keys(): - if type(k) == ClassType or k == 'name': + if isinstace(k, type) or k == 'name': fcnf[k] = cnf[k] del cnf[k] self.frame = Frame(master, **fcnf) Modified: python/branches/p3yk/Lib/lib-tk/Tkinter.py ============================================================================== --- python/branches/p3yk/Lib/lib-tk/Tkinter.py (original) +++ python/branches/p3yk/Lib/lib-tk/Tkinter.py Thu Jun 7 09:00:57 2007 @@ -38,7 +38,6 @@ import _tkinter # If this fails your Python may not be configured for Tk tkinter = _tkinter # b/w compat for export TclError = _tkinter.TclError -from types import * from Tkconstants import * try: import MacOS; _MacOS = MacOS; del MacOS @@ -61,11 +60,11 @@ except AttributeError: _tkinter.deletefilehandler = None -def _flatten(tuple): +def _flatten(seq): """Internal function.""" res = () - for item in tuple: - if type(item) in (TupleType, ListType): + for item in seq: + if isinstance(item, (tuple, list)): res = res + _flatten(item) elif item is not None: res = res + (item,) @@ -76,9 +75,9 @@ def _cnfmerge(cnfs): """Internal function.""" - if type(cnfs) is DictionaryType: + if isinstance(cnfs, dict): return cnfs - elif type(cnfs) in (NoneType, StringType): + elif isinstance(cnfs, (type(None), str)): return cnfs else: cnf = {} @@ -867,7 +866,7 @@ data = self.tk.split( self.tk.call('winfo', 'visualsavailable', self._w, includeids and 'includeids' or None)) - if type(data) is StringType: + if isinstance(data, str): data = [self.tk.split(data)] return map(self.__winfo_parseitem, data) def __winfo_parseitem(self, t): @@ -934,7 +933,7 @@ self.tk.call('bindtags', self._w, tagList) def _bind(self, what, sequence, func, add, needcleanup=1): """Internal function.""" - if type(func) is StringType: + if isinstance(func, str): self.tk.call(what + (sequence, func)) elif func: funcid = self._register(func, self._substitute, @@ -1181,7 +1180,7 @@ self.tk.call(_flatten((self._w, cmd)))): cnf[x[0][1:]] = (x[0][1:],) + x[1:] return cnf - if type(cnf) is StringType: + if isinstance(cnf, str): x = self.tk.split( self.tk.call(_flatten((self._w, cmd, '-'+cnf)))) return (x[0][1:],) + x[1:] @@ -1262,7 +1261,7 @@ bbox = grid_bbox def _grid_configure(self, command, index, cnf, kw): """Internal function.""" - if type(cnf) is StringType and not kw: + if isinstance(cnf, str) and not kw: if cnf[-1:] == '_': cnf = cnf[:-1] if cnf[:1] != '-': @@ -1923,7 +1922,7 @@ BaseWidget._setup(self, master, cnf) classes = [] for k in cnf.keys(): - if type(k) is ClassType: + if isinstance(k, type): classes.append((k, cnf[k])) del cnf[k] self.tk.call( @@ -2136,7 +2135,7 @@ """Internal function.""" args = _flatten(args) cnf = args[-1] - if type(cnf) in (DictionaryType, TupleType): + if isinstance(cnf, (dict, tuple)): args = args[:-1] else: cnf = {} @@ -3695,7 +3694,7 @@ 'paneconfigure', tagOrId)): cnf[x[0][1:]] = (x[0][1:],) + x[1:] return cnf - if type(cnf) == StringType and not kw: + if isinstance(cnf, str) and not kw: x = self.tk.split(self.tk.call( self._w, 'paneconfigure', tagOrId, '-'+cnf)) return (x[0][1:],) + x[1:] Modified: python/branches/p3yk/Lib/logging/__init__.py ============================================================================== --- python/branches/p3yk/Lib/logging/__init__.py (original) +++ python/branches/p3yk/Lib/logging/__init__.py Thu Jun 7 09:00:57 2007 @@ -26,7 +26,7 @@ To use, simply 'import logging' and log away! """ -import sys, os, types, time, cStringIO, traceback +import sys, os, time, cStringIO, traceback try: import codecs @@ -48,6 +48,8 @@ # Miscellaneous module data #--------------------------------------------------------------------------- +_unicode = 'unicode' in dir(__builtins__) + # # _srcfile is used when walking the stack to check when we've got the first # caller stack frame. @@ -234,7 +236,7 @@ # 'Value is %d' instead of 'Value is 0'. # For the use case of passing a dictionary, this should not be a # problem. - if args and (len(args) == 1) and args[0] and (type(args[0]) == types.DictType): + if args and (len(args) == 1) and args[0] and isinstance(args[0], dict): args = args[0] self.args = args self.levelname = getLevelName(level) @@ -275,11 +277,11 @@ Return the message for this LogRecord after merging any user-supplied arguments with the message. """ - if not hasattr(types, "UnicodeType"): #if no unicode support... + if not _unicode: #if no unicode support... msg = str(self.msg) else: msg = self.msg - if type(msg) not in (types.UnicodeType, types.StringType): + if not isinstance(msg, basestring): try: msg = str(self.msg) except UnicodeError: @@ -743,7 +745,7 @@ try: msg = self.format(record) fs = "%s\n" - if not hasattr(types, "UnicodeType"): #if no unicode support... + if not _unicode: #if no unicode support... self.stream.write(fs % msg) else: try: @@ -1053,7 +1055,7 @@ logger.log(level, "We have a %s", "mysterious problem", exc_info=1) """ - if type(level) != types.IntType: + if not isinstance(level, int): if raiseExceptions: raise TypeError, "level must be an integer" else: @@ -1103,7 +1105,7 @@ else: fn, lno, func = "(unknown file)", 0, "(unknown function)" if exc_info: - if type(exc_info) != types.TupleType: + if not isinstance(exc_info, tuple): exc_info = sys.exc_info() record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra) self.handle(record) Modified: python/branches/p3yk/Lib/logging/config.py ============================================================================== --- python/branches/p3yk/Lib/logging/config.py (original) +++ python/branches/p3yk/Lib/logging/config.py Thu Jun 7 09:00:57 2007 @@ -27,7 +27,7 @@ To use, simply 'import logging' and log away! """ -import sys, logging, logging.handlers, socket, struct, os, traceback, types +import sys, logging, logging.handlers, socket, struct, os, traceback try: import thread @@ -289,7 +289,7 @@ traceback.print_exc() os.remove(file) except socket.error as e: - if type(e.args) != types.TupleType: + if not isinstancetype(e.args, tuple): raise else: errcode = e.args[0] Modified: python/branches/p3yk/Lib/logging/handlers.py ============================================================================== --- python/branches/p3yk/Lib/logging/handlers.py (original) +++ python/branches/p3yk/Lib/logging/handlers.py Thu Jun 7 09:00:57 2007 @@ -27,7 +27,7 @@ To use, simply 'import logging' and log away! """ -import sys, logging, socket, types, os, struct, time, glob +import sys, logging, socket, os, struct, time, glob try: import cPickle as pickle except ImportError: @@ -637,7 +637,7 @@ self.address = address self.facility = facility - if type(address) == types.StringType: + if isinstance(address, str): self.unixsocket = 1 self._connect_unixsocket(address) else: @@ -669,9 +669,9 @@ priority_names mapping dictionaries are used to convert them to integers. """ - if type(facility) == types.StringType: + if isinstance(facility, str): facility = self.facility_names[facility] - if type(priority) == types.StringType: + if isinstance(priority, str): priority = self.priority_names[priority] return (facility << 3) | priority @@ -738,16 +738,16 @@ for the credentials argument. """ logging.Handler.__init__(self) - if type(mailhost) == types.TupleType: + if isinstance(mailhost, tuple): self.mailhost, self.mailport = mailhost else: self.mailhost, self.mailport = mailhost, None - if type(credentials) == types.TupleType: + if isinstance(credentials, tuple): self.username, self.password = credentials else: self.username = None self.fromaddr = fromaddr - if type(toaddrs) == types.StringType: + if isinstance(toaddrs, str): toaddrs = [toaddrs] self.toaddrs = toaddrs self.subject = subject Modified: python/branches/p3yk/Lib/new.py ============================================================================== --- python/branches/p3yk/Lib/new.py (original) +++ python/branches/p3yk/Lib/new.py Thu Jun 7 09:00:57 2007 @@ -4,7 +4,7 @@ Objects of most types can now be created by calling the type object. """ -from types import ClassType as classobj +classobj = type from types import FunctionType as function from types import MethodType as instancemethod from types import ModuleType as module Modified: python/branches/p3yk/Lib/optparse.py ============================================================================== --- python/branches/p3yk/Lib/optparse.py (original) +++ python/branches/p3yk/Lib/optparse.py Thu Jun 7 09:00:57 2007 @@ -67,7 +67,6 @@ """ import sys, os -import types import textwrap def _repr(self): @@ -641,7 +640,7 @@ # Python 2.1 and earlier, and is short-circuited by the # first check on modern Pythons.) import __builtin__ - if ( type(self.type) is types.TypeType or + if ( isinstance(self.type, type) or (hasattr(self.type, "__name__") and getattr(__builtin__, self.type.__name__, None) is self.type) ): self.type = self.type.__name__ @@ -660,7 +659,7 @@ if self.choices is None: raise OptionError( "must supply a list of choices for type 'choice'", self) - elif type(self.choices) not in (types.TupleType, types.ListType): + elif not isinstance(self.choices, (tuple, list)): raise OptionError( "choices must be a list of strings ('%s' supplied)" % str(type(self.choices)).split("'")[1], self) @@ -704,12 +703,12 @@ raise OptionError( "callback not callable: %r" % self.callback, self) if (self.callback_args is not None and - type(self.callback_args) is not types.TupleType): + not isinstance(self.callback_args, tuple)): raise OptionError( "callback_args, if supplied, must be a tuple: not %r" % self.callback_args, self) if (self.callback_kwargs is not None and - type(self.callback_kwargs) is not types.DictType): + not isinstance(self.callback_kwargs, dict)): raise OptionError( "callback_kwargs, if supplied, must be a dict: not %r" % self.callback_kwargs, self) @@ -817,7 +816,7 @@ SUPPRESS_USAGE = "SUPPRESS"+"USAGE" def isbasestring(x): - return isinstance(x, types.StringType) or isinstance(x, types.UnicodeType) + return isinstance(x, basestring) class Values: @@ -834,7 +833,7 @@ def __eq__(self, other): if isinstance(other, Values): return self.__dict__ == other.__dict__ - elif isinstance(other, types.DictType): + elif isinstance(other, dict): return self.__dict__ == other else: return NotImplemented @@ -995,7 +994,7 @@ """add_option(Option) add_option(opt_str, ..., kwarg=val, ...) """ - if type(args[0]) is types.StringType: + if isinstance(args[0], str): option = self.option_class(*args, **kwargs) elif len(args) == 1 and not kwargs: option = args[0] @@ -1306,7 +1305,7 @@ def add_option_group(self, *args, **kwargs): # XXX lots of overlap with OptionContainer.add_option() - if type(args[0]) is types.StringType: + if isinstance(args[0], str): group = OptionGroup(self, *args, **kwargs) elif len(args) == 1 and not kwargs: group = args[0] Modified: python/branches/p3yk/Lib/pickle.py ============================================================================== --- python/branches/p3yk/Lib/pickle.py (original) +++ python/branches/p3yk/Lib/pickle.py Thu Jun 7 09:00:57 2007 @@ -26,7 +26,7 @@ __version__ = "$Revision$" # Code version -from types import * +from types import FunctionType, BuiltinFunctionType from copy_reg import dispatch_table from copy_reg import _extension_registry, _inverted_registry, _extension_cache import marshal @@ -89,11 +89,11 @@ except ImportError: PyStringMap = None -# UnicodeType may or may not be exported (normally imported from types) +# unicode may or may not be exported (normally imported from types) try: - UnicodeType + unicode except NameError: - UnicodeType = None + unicode = None # Pickle opcodes. See pickletools.py for extensive docs. The listing # here is in kind-of alphabetical order of 1-character pickle code. @@ -287,7 +287,7 @@ # Check for a class with a custom metaclass; treat as regular class try: - issc = issubclass(t, TypeType) + issc = issubclass(t, type) except TypeError: # t is not a class (old Boost; see SF #502085) issc = 0 if issc: @@ -312,12 +312,12 @@ (t.__name__, obj)) # Check for string returned by reduce(), meaning "save as global" - if type(rv) is StringType: + if isinstance(rv, str): self.save_global(obj, rv) return # Assert that reduce() returned a tuple - if type(rv) is not TupleType: + if not isinstance(rv, tuple): raise PicklingError("%s must return string or tuple" % reduce) # Assert that it returned an appropriately sized tuple @@ -346,7 +346,7 @@ # This API is called by some subclasses # Assert that args is a tuple or None - if not isinstance(args, TupleType): + if not isinstance(args, tuple): raise PicklingError("args from reduce() should be a tuple") # Assert that func is callable @@ -424,7 +424,7 @@ def save_none(self, obj): self.write(NONE) - dispatch[NoneType] = save_none + dispatch[type(None)] = save_none def save_bool(self, obj): if self.proto >= 2: @@ -456,7 +456,7 @@ # Text pickle, or int too big to fit in signed 4-byte format. self.write(INT + repr(obj) + '\n') # XXX save_int is merged into save_long - # dispatch[IntType] = save_int + # dispatch[int] = save_int def save_long(self, obj, pack=struct.pack): if self.bin: @@ -487,14 +487,14 @@ self.write(LONG4 + pack("d', obj)) else: self.write(FLOAT + repr(obj) + '\n') - dispatch[FloatType] = save_float + dispatch[float] = save_float def save_string(self, obj, pack=struct.pack): if self.bin: @@ -506,7 +506,7 @@ else: self.write(STRING + repr(obj) + '\n') self.memoize(obj) - dispatch[StringType] = save_string + dispatch[str] = save_string def save_unicode(self, obj, pack=struct.pack): if self.bin: @@ -518,9 +518,9 @@ obj = obj.replace("\n", "\\u000a") self.write(UNICODE + obj.encode('raw-unicode-escape') + '\n') self.memoize(obj) - dispatch[UnicodeType] = save_unicode + dispatch[unicode] = save_unicode - if StringType == UnicodeType: + if str == unicode: # This is true for Jython def save_string(self, obj, pack=struct.pack): unicode = obj.isunicode() @@ -546,7 +546,7 @@ else: self.write(STRING + repr(obj) + '\n') self.memoize(obj) - dispatch[StringType] = save_string + dispatch[str] = save_string def save_tuple(self, obj): write = self.write @@ -599,7 +599,7 @@ self.write(TUPLE) self.memoize(obj) - dispatch[TupleType] = save_tuple + dispatch[tuple] = save_tuple # save_empty_tuple() isn't used by anything in Python 2.3. However, I # found a Pickler subclass in Zope3 that calls it, so it's not harmless @@ -618,7 +618,7 @@ self.memoize(obj) self._batch_appends(iter(obj)) - dispatch[ListType] = save_list + dispatch[list] = save_list # Keep in synch with cPickle's BATCHSIZE. Nothing will break if it gets # out of synch, though. @@ -667,8 +667,8 @@ self.memoize(obj) self._batch_setitems(iter(obj.items())) - dispatch[DictionaryType] = save_dict - if not PyStringMap is None: + dispatch[dict] = save_dict + if PyStringMap is not None: dispatch[PyStringMap] = save_dict def _batch_setitems(self, items): @@ -746,10 +746,9 @@ write(GLOBAL + module + '\n' + name + '\n') self.memoize(obj) - dispatch[ClassType] = save_global dispatch[FunctionType] = save_global dispatch[BuiltinFunctionType] = save_global - dispatch[TypeType] = save_global + dispatch[type] = save_global # Pickling helpers @@ -1024,7 +1023,7 @@ del self.stack[k:] instantiated = 0 if (not args and - type(klass) is ClassType and + isinstance(klass, type) and not hasattr(klass, "__getinitargs__")): value = _EmptyClass() value.__class__ = klass Modified: python/branches/p3yk/Lib/pickletools.py ============================================================================== --- python/branches/p3yk/Lib/pickletools.py (original) +++ python/branches/p3yk/Lib/pickletools.py Thu Jun 7 09:00:57 2007 @@ -1517,7 +1517,7 @@ opcode is followed by code to create setstate's argument, and then a BUILD opcode to apply __setstate__ to that argument. - If type(callable) is not ClassType, REDUCE complains unless the + If not isinstance(callable, type), REDUCE complains unless the callable has been registered with the copy_reg module's safe_constructors dict, or the callable has a magic '__safe_for_unpickling__' attribute with a true value. I'm not sure @@ -1573,9 +1573,6 @@ + The argtuple is empty (markobject was at the top of the stack at the start). - + It's an old-style class object (the type of the class object is - ClassType). - + The class object does not have a __getinitargs__ attribute. then we want to create an old-style class instance without invoking Modified: python/branches/p3yk/Lib/plat-mac/aepack.py ============================================================================== --- python/branches/p3yk/Lib/plat-mac/aepack.py (original) +++ python/branches/p3yk/Lib/plat-mac/aepack.py Thu Jun 7 09:00:57 2007 @@ -13,8 +13,6 @@ # import struct -import types -from types import * from Carbon import AE from Carbon.AppleEvents import * import MacOS @@ -74,7 +72,7 @@ """Pack a python object into an AE descriptor""" if forcetype: - if type(x) is StringType: + if isinstance(x, str): return AE.AECreateDesc(forcetype, x) else: return pack(x).AECoerceDesc(forcetype) @@ -90,29 +88,29 @@ return AE.AECreateDesc('fsrf', x.data) if isinstance(x, AliasType): return AE.AECreateDesc('alis', x.data) - if isinstance(x, IntType): + if isinstance(x, int): return AE.AECreateDesc('long', struct.pack('l', x)) - if isinstance(x, FloatType): + if isinstance(x, float): return AE.AECreateDesc('doub', struct.pack('d', x)) - if isinstance(x, StringType): + if isinstance(x, str): return AE.AECreateDesc('TEXT', x) - if isinstance(x, UnicodeType): + if isinstance(x, unicode): data = x.encode('utf16') if data[:2] == '\xfe\xff': data = data[2:] return AE.AECreateDesc('utxt', data) - if isinstance(x, ListType): + if isinstance(x, list): list = AE.AECreateList('', 0) for item in x: list.AEPutDesc(0, pack(item)) return list - if isinstance(x, DictionaryType): + if isinstance(x, dict): record = AE.AECreateList('', 1) for key, value in x.items(): packkey(record, key, value) #record.AEPutParamDesc(key, pack(value)) return record - if type(x) == types.ClassType and issubclass(x, ObjectSpecifier): + if isinstance(x, type) and issubclass(x, ObjectSpecifier): # Note: we are getting a class object here, not an instance return AE.AECreateDesc('type', x.want) if hasattr(x, '__aepack__'): @@ -340,7 +338,7 @@ # to __class__ is safe. Moreover, shouldn't there be a better # initializer for the classes in the suites? def mkobjectfrommodule(dict, modulename): - if type(dict['want']) == types.ClassType and issubclass(dict['want'], ObjectSpecifier): + if isinstance(dict['want'], type) and issubclass(dict['want'], ObjectSpecifier): # The type has already been converted to Python. Convert back:-( classtype = dict['want'] dict['want'] = aetypes.mktype(classtype.want) Modified: python/branches/p3yk/Lib/plat-mac/aetypes.py ============================================================================== --- python/branches/p3yk/Lib/plat-mac/aetypes.py (original) +++ python/branches/p3yk/Lib/plat-mac/aetypes.py Thu Jun 7 09:00:57 2007 @@ -2,7 +2,6 @@ from Carbon.AppleEvents import * import struct -from types import * # # convoluted, since there are cyclic dependencies between this file and @@ -14,7 +13,7 @@ def nice(s): """'nice' representation of an object""" - if type(s) is StringType: return repr(s) + if isinstance(s, str): return repr(s) else: return str(s) class Unknown: @@ -222,7 +221,7 @@ return "Logical(%r, %r)" % (self.logc, self.term) def __str__(self): - if type(self.term) == ListType and len(self.term) == 2: + if isinstance(self.term, list) and len(self.term) == 2: return "%s %s %s" % (nice(self.term[0]), self.logc.strip(), nice(self.term[1])) @@ -481,13 +480,13 @@ def __init__(self, want, seld, fr = None): t = type(seld) - if t == StringType: + if isinstance(t, str): form = 'name' elif IsRange(seld): form = 'rang' elif IsComparison(seld) or IsLogical(seld): form = 'test' - elif t == TupleType: + elif isinstance(t, tuple): # Breakout: specify both form and seld in a tuple # (if you want ID or rele or somesuch) form, seld = seld @@ -513,7 +512,7 @@ def __str__(self): seld = self.seld - if type(seld) == StringType: + if isinstance(seld, str): ss = repr(seld) elif IsRange(seld): start, stop = seld.start, seld.stop Modified: python/branches/p3yk/Lib/plat-mac/gensuitemodule.py ============================================================================== --- python/branches/p3yk/Lib/plat-mac/gensuitemodule.py (original) +++ python/branches/p3yk/Lib/plat-mac/gensuitemodule.py Thu Jun 7 09:00:57 2007 @@ -279,9 +279,9 @@ def simplify(item): """Recursively replace singleton tuples by their constituent item""" - if type(item) is types.ListType: + if isinstance(item, list): return map(simplify, item) - elif type(item) == types.TupleType and len(item) == 2: + elif isinstance(item, tuple) and len(item) == 2: return simplify(item[1]) else: return item @@ -352,7 +352,7 @@ def generic(what, f, *args): if type(what) == types.FunctionType: return what(f, *args) - if type(what) == types.ListType: + if isinstance(what, list): record = [] for thing in what: item = generic(thing[:1], f, *thing[1:]) Modified: python/branches/p3yk/Lib/pydoc.py ============================================================================== --- python/branches/p3yk/Lib/pydoc.py (original) +++ python/branches/p3yk/Lib/pydoc.py Thu Jun 7 09:00:57 2007 @@ -235,7 +235,7 @@ def __str__(self): exc = self.exc - if type(exc) is types.ClassType: + if isinstance(exc, type): exc = exc.__name__ return 'problem in %s - %s: %s' % (self.filename, exc, self.value) Modified: python/branches/p3yk/Lib/sre_parse.py ============================================================================== --- python/branches/p3yk/Lib/sre_parse.py (original) +++ python/branches/p3yk/Lib/sre_parse.py Thu Jun 7 09:00:57 2007 @@ -101,7 +101,7 @@ self.width = None def dump(self, level=0): nl = 1 - seqtypes = type(()), type([]) + seqtypes = (tuple, list) for op, av in self.data: print(level*" " + op, end=' '); nl = 0 if op == "in": @@ -117,7 +117,7 @@ print(level*" " + "or") a.dump(level+1); nl = 1 i = i + 1 - elif type(av) in seqtypes: + elif isinstance(av, seqtypes): for a in av: if isinstance(a, SubPattern): if not nl: print() @@ -709,7 +709,7 @@ else: pappend((LITERAL, literal)) sep = source[:0] - if type(sep) is type(""): + if isinstance(sep, str): makechar = chr else: makechar = unichr Modified: python/branches/p3yk/Lib/subprocess.py ============================================================================== --- python/branches/p3yk/Lib/subprocess.py (original) +++ python/branches/p3yk/Lib/subprocess.py Thu Jun 7 09:00:57 2007 @@ -287,7 +287,6 @@ mswindows = (sys.platform == "win32") import os -import types import traceback # Exception classes used by this module. @@ -694,7 +693,7 @@ errread, errwrite): """Execute program (MS Windows version)""" - if not isinstance(args, types.StringTypes): + if not isinstance(args, basestring): args = list2cmdline(args) # Process startup details @@ -909,7 +908,7 @@ errread, errwrite): """Execute program (POSIX version)""" - if isinstance(args, types.StringTypes): + if isinstance(args, basestring): args = [args] else: args = list(args) Modified: python/branches/p3yk/Lib/test/test_descr.py ============================================================================== --- python/branches/p3yk/Lib/test/test_descr.py (original) +++ python/branches/p3yk/Lib/test/test_descr.py Thu Jun 7 09:00:57 2007 @@ -4103,7 +4103,8 @@ N1 = sys.maxint + 1 # might trigger OverflowErrors instead of TypeErrors N2 = sys.maxint # if sizeof(int) < sizeof(long), might trigger # ValueErrors instead of TypeErrors - for metaclass in [type, types.ClassType]: + if 1: + metaclass = type for name, expr, iexpr in [ ('__add__', 'x + y', 'x += y'), ('__sub__', 'x - y', 'x -= y'), Modified: python/branches/p3yk/Lib/test/test_isinstance.py ============================================================================== --- python/branches/p3yk/Lib/test/test_isinstance.py (original) +++ python/branches/p3yk/Lib/test/test_isinstance.py Thu Jun 7 09:00:57 2007 @@ -15,7 +15,7 @@ # (leading to an "undetected error" in the debug build). Set up is, # isinstance(inst, cls) where: # - # - cls isn't a ClassType, a TypeType, or a TupleType + # - cls isn't a a type, or a tuple # - cls has a __bases__ attribute # - inst has a __class__ attribute # - inst.__class__ as no __bases__ attribute Modified: python/branches/p3yk/Lib/test/test_logging.py ============================================================================== --- python/branches/p3yk/Lib/test/test_logging.py (original) +++ python/branches/p3yk/Lib/test/test_logging.py Thu Jun 7 09:00:57 2007 @@ -25,7 +25,7 @@ """ import select -import os, sys, struct, types, pickle, cStringIO +import os, sys, struct, pickle, cStringIO import socket, tempfile, threading, time import logging, logging.handlers, logging.config from test.test_support import run_with_locale Modified: python/branches/p3yk/Lib/test/test_optparse.py ============================================================================== --- python/branches/p3yk/Lib/test/test_optparse.py (original) +++ python/branches/p3yk/Lib/test/test_optparse.py Thu Jun 7 09:00:57 2007 @@ -12,7 +12,6 @@ import os import re import copy -import types import unittest from StringIO import StringIO @@ -171,7 +170,7 @@ except InterceptedError as err: self.assert_( - type(output) is types.StringType, + isinstance(output, str), "expected output to be an ordinary string, not %r" % type(output)) @@ -432,18 +431,12 @@ self.parser.add_option("-s", type="str") self.assertEquals(self.parser.get_option("-s").type, "string") - def test_new_type_object(self): + def test_type_object(self): self.parser.add_option("-s", type=str) self.assertEquals(self.parser.get_option("-s").type, "string") self.parser.add_option("-x", type=int) self.assertEquals(self.parser.get_option("-x").type, "int") - def test_old_type_object(self): - self.parser.add_option("-s", type=types.StringType) - self.assertEquals(self.parser.get_option("-s").type, "string") - self.parser.add_option("-x", type=types.IntType) - self.assertEquals(self.parser.get_option("-x").type, "int") - # Custom type for testing processing of default values. _time_units = { 's' : 1, 'm' : 60, 'h' : 60*60, 'd' : 60*60*24 } @@ -1470,7 +1463,7 @@ os.environ['COLUMNS'] = orig_columns def assertHelpEquals(self, expected_output): - if type(expected_output) is types.UnicodeType: + if isinstance(expected_output, unicode): encoding = self.parser._get_encoding(sys.stdout) expected_output = expected_output.encode(encoding, "replace") Modified: python/branches/p3yk/Lib/test/test_pyclbr.py ============================================================================== --- python/branches/p3yk/Lib/test/test_pyclbr.py (original) +++ python/branches/p3yk/Lib/test/test_pyclbr.py Thu Jun 7 09:00:57 2007 @@ -4,7 +4,7 @@ ''' from test.test_support import run_unittest import unittest, sys -from types import ClassType, FunctionType, MethodType, BuiltinFunctionType +from types import FunctionType, MethodType, BuiltinFunctionType import pyclbr from unittest import TestCase @@ -95,7 +95,7 @@ continue # skip functions that came from somewhere else self.assertEquals(py_item.__module__, value.module) else: - self.failUnless(isinstance(py_item, (ClassType, type))) + self.failUnless(isinstance(py_item, type)) if py_item.__module__ != moduleName: continue # skip classes that came from somewhere else @@ -133,14 +133,14 @@ # Now check for missing stuff. def defined_in(item, module): - if isinstance(item, ClassType): + if isinstance(item, type): return item.__module__ == module.__name__ if isinstance(item, FunctionType): return item.__globals__ is module.__dict__ return False for name in dir(module): item = getattr(module, name) - if isinstance(item, (ClassType, FunctionType)): + if isinstance(item, (type, FunctionType)): if defined_in(item, module): self.assertHaskey(dict, name, ignore) Modified: python/branches/p3yk/Lib/types.py ============================================================================== --- python/branches/p3yk/Lib/types.py (original) +++ python/branches/p3yk/Lib/types.py Thu Jun 7 09:00:57 2007 @@ -50,7 +50,7 @@ class _C: def _m(self): pass -ClassType = type(_C) +ClassType = type UnboundMethodType = type(_C._m) # Same as MethodType MethodType = type(_C()._m) Modified: python/branches/p3yk/Lib/unittest.py ============================================================================== --- python/branches/p3yk/Lib/unittest.py (original) +++ python/branches/p3yk/Lib/unittest.py Thu Jun 7 09:00:57 2007 @@ -412,8 +412,7 @@ # sanity checks if not hasattr(test, '__call__'): raise TypeError("the test to add must be callable") - if (isinstance(test, (type, types.ClassType)) and - issubclass(test, (TestCase, TestSuite))): + if isinstance(test, type) and issubclass(test, (TestCase, TestSuite)): raise TypeError("TestCases and TestSuites must be instantiated " "before passing them to addTest()") self._tests.append(test) @@ -525,8 +524,7 @@ tests = [] for name in dir(module): obj = getattr(module, name) - if (isinstance(obj, (type, types.ClassType)) and - issubclass(obj, TestCase)): + if isinstance(obj, type) and issubclass(obj, TestCase): tests.append(self.loadTestsFromTestCase(obj)) return self.suiteClass(tests) @@ -556,11 +554,10 @@ if type(obj) == types.ModuleType: return self.loadTestsFromModule(obj) - elif (isinstance(obj, (type, types.ClassType)) and - issubclass(obj, TestCase)): + elif isinstance(obj, type) and issubclass(obj, TestCase): return self.loadTestsFromTestCase(obj) - elif (type(obj) == types.UnboundMethodType and - isinstance(parent, (type, types.ClassType)) and + elif (isinstance(obj, types.UnboundMethodType) and + isinstance(parent, type) and issubclass(parent, TestCase)): return TestSuite([parent(obj.__name__)]) elif isinstance(obj, TestSuite): @@ -816,7 +813,7 @@ self.module) def runTests(self): - if isinstance(self.testRunner, (type, types.ClassType)): + if isinstance(self.testRunner, type): try: testRunner = self.testRunner(verbosity=self.verbosity) except TypeError: Modified: python/branches/p3yk/Lib/urllib2.py ============================================================================== --- python/branches/p3yk/Lib/urllib2.py (original) +++ python/branches/p3yk/Lib/urllib2.py Thu Jun 7 09:00:57 2007 @@ -431,9 +431,8 @@ If any of the handlers passed as arguments are subclasses of the default handlers, the default handlers will not be used. """ - import types def isclass(obj): - return isinstance(obj, types.ClassType) or hasattr(obj, "__bases__") + return isinstance(obj, type) or hasattr(obj, "__bases__") opener = OpenerDirector() default_classes = [ProxyHandler, UnknownHandler, HTTPHandler, Modified: python/branches/p3yk/Lib/warnings.py ============================================================================== --- python/branches/p3yk/Lib/warnings.py (original) +++ python/branches/p3yk/Lib/warnings.py Thu Jun 7 09:00:57 2007 @@ -3,7 +3,7 @@ # Note: function level imports should *not* be used # in this module as it may cause import lock deadlock. # See bug 683658. -import sys, types +import sys import linecache __all__ = ["warn", "showwarning", "formatwarning", "filterwarnings", @@ -151,8 +151,7 @@ assert action in ("error", "ignore", "always", "default", "module", "once"), "invalid action: %r" % (action,) assert isinstance(message, basestring), "message must be a string" - assert isinstance(category, (type, types.ClassType)), \ - "category must be a class" + assert isinstance(category, type), "category must be a class" assert issubclass(category, Warning), "category must be a Warning subclass" assert isinstance(module, basestring), "module must be a string" assert isinstance(lineno, int) and lineno >= 0, \ Modified: python/branches/p3yk/Lib/wsgiref/headers.py ============================================================================== --- python/branches/p3yk/Lib/wsgiref/headers.py (original) +++ python/branches/p3yk/Lib/wsgiref/headers.py Thu Jun 7 09:00:57 2007 @@ -5,8 +5,6 @@ written by Barry Warsaw. """ -from types import ListType, TupleType - # Regular expression that matches `special' characters in parameters, the # existance of which force quoting of the parameter value. import re @@ -44,7 +42,7 @@ """Manage a collection of HTTP response headers""" def __init__(self,headers): - if type(headers) is not ListType: + if not isinstance(headers, list): raise TypeError("Headers must be a list of name/value tuples") self._headers = headers Modified: python/branches/p3yk/Lib/wsgiref/validate.py ============================================================================== --- python/branches/p3yk/Lib/wsgiref/validate.py (original) +++ python/branches/p3yk/Lib/wsgiref/validate.py Thu Jun 7 09:00:57 2007 @@ -113,7 +113,6 @@ import re import sys -from types import DictType, StringType, TupleType, ListType import warnings header_re = re.compile(r'^[a-zA-Z][a-zA-Z0-9\-_]*$') @@ -191,20 +190,20 @@ def read(self, *args): assert_(len(args) <= 1) v = self.input.read(*args) - assert_(type(v) is type("")) + assert_(isinstance(v, str)) return v def readline(self): v = self.input.readline() - assert_(type(v) is type("")) + assert_(isinstance(v, str)) return v def readlines(self, *args): assert_(len(args) <= 1) lines = self.input.readlines(*args) - assert_(type(lines) is type([])) + assert_(isinstance(lines, list)) for line in lines: - assert_(type(line) is type("")) + assert_(isinstance(line, str)) return lines def __iter__(self): @@ -223,7 +222,7 @@ self.errors = wsgi_errors def write(self, s): - assert_(type(s) is type("")) + assert_(isinstance(s, str)) self.errors.write(s) def flush(self): @@ -242,7 +241,7 @@ self.writer = wsgi_writer def __call__(self, s): - assert_(type(s) is type("")) + assert_(isinstance(s, str)) self.writer(s) class PartialIteratorWrapper: @@ -288,7 +287,7 @@ "Iterator garbage collected without being closed") def check_environ(environ): - assert_(type(environ) is DictType, + assert_(isinstance(environ, dict), "Environment is not of the right type: %r (environment: %r)" % (type(environ), environ)) @@ -315,11 +314,11 @@ if '.' in key: # Extension, we don't care about its type continue - assert_(type(environ[key]) is StringType, + assert_(isinstance(environ[key], str), "Environmental variable %s is not a string: %r (value: %r)" % (key, type(environ[key]), environ[key])) - assert_(type(environ['wsgi.version']) is TupleType, + assert_(isinstance(environ['wsgi.version'], tuple), "wsgi.version should be a tuple (%r)" % (environ['wsgi.version'],)) assert_(environ['wsgi.url_scheme'] in ('http', 'https'), "wsgi.url_scheme unknown: %r" % environ['wsgi.url_scheme']) @@ -365,7 +364,7 @@ % (wsgi_errors, attr)) def check_status(status): - assert_(type(status) is StringType, + assert_(isinstance(status, str), "Status must be a string (not %r)" % status) # Implicitly check that we can turn it into an integer: status_code = status.split(None, 1)[0] @@ -380,12 +379,12 @@ % status, WSGIWarning) def check_headers(headers): - assert_(type(headers) is ListType, + assert_(isinstance(headers, list), "Headers (%r) must be of type list: %r" % (headers, type(headers))) header_names = {} for item in headers: - assert_(type(item) is TupleType, + assert_(isinstance(item, tuple), "Individual headers (%r) must be of type tuple: %r" % (item, type(item))) assert_(len(item) == 2) @@ -419,7 +418,7 @@ assert_(0, "No Content-Type header found in headers (%s)" % headers) def check_exc_info(exc_info): - assert_(exc_info is None or type(exc_info) is type(()), + assert_(exc_info is None or isinstance(exc_info, tuple), "exc_info (%r) is not a tuple: %r" % (exc_info, type(exc_info))) # More exc_info checks? Modified: python/branches/p3yk/Lib/xml/sax/saxutils.py ============================================================================== --- python/branches/p3yk/Lib/xml/sax/saxutils.py (original) +++ python/branches/p3yk/Lib/xml/sax/saxutils.py Thu Jun 7 09:00:57 2007 @@ -3,15 +3,10 @@ convenience of application and driver writers. """ -import os, urlparse, urllib, types +import os, urlparse, urllib from . import handler from . import xmlreader -try: - _StringTypes = [types.StringType, types.UnicodeType] -except AttributeError: - _StringTypes = [types.StringType] - # See whether the xmlcharrefreplace error handler is # supported try: @@ -277,7 +272,7 @@ """This function takes an InputSource and an optional base URL and returns a fully resolved InputSource object ready for reading.""" - if type(source) in _StringTypes: + if isinstance(source, basestring): source = xmlreader.InputSource(source) elif hasattr(source, "read"): f = source Modified: python/branches/p3yk/Lib/xmlrpclib.py ============================================================================== --- python/branches/p3yk/Lib/xmlrpclib.py (original) +++ python/branches/p3yk/Lib/xmlrpclib.py Thu Jun 7 09:00:57 2007 @@ -138,8 +138,6 @@ import re, time, operator -from types import * - # -------------------------------------------------------------------- # Internal stuff @@ -304,7 +302,7 @@ """ def __init__(self, value=0): - if not isinstance(value, StringType): + if not isinstance(value, str): if datetime and isinstance(value, datetime.datetime): self.value = value.strftime("%Y%m%dT%H:%M:%S") return @@ -315,7 +313,7 @@ today = datetime.datetime.now().strftime("%Y%m%d") self.value = value.strftime(today+"T%H:%M:%S") return - if not isinstance(value, (TupleType, time.struct_time)): + if not isinstance(value, (tuple, time.struct_time)): if value == 0: value = time.time() value = time.localtime(value) @@ -592,7 +590,7 @@ if not self.allow_none: raise TypeError, "cannot marshal None unless allow_none is enabled" write("") - dispatch[NoneType] = dump_nil + dispatch[type(None)] = dump_nil def dump_int(self, value, write): # in case ints are > 32 bits @@ -601,7 +599,7 @@ write("") write(str(value)) write("\n") - dispatch[IntType] = dump_int + #dispatch[int] = dump_int if _bool_is_builtin: def dump_bool(self, value, write): @@ -616,19 +614,19 @@ write("") write(str(int(value))) write("\n") - dispatch[LongType] = dump_long + dispatch[int] = dump_long def dump_double(self, value, write): write("") write(repr(value)) write("\n") - dispatch[FloatType] = dump_double + dispatch[float] = dump_double def dump_string(self, value, write, escape=escape): write("") write(escape(value)) write("\n") - dispatch[StringType] = dump_string + dispatch[str] = dump_string if unicode: def dump_unicode(self, value, write, escape=escape): @@ -636,7 +634,7 @@ write("") write(escape(value)) write("\n") - dispatch[UnicodeType] = dump_unicode + dispatch[unicode] = dump_unicode def dump_array(self, value, write): i = id(value) @@ -649,8 +647,8 @@ dump(v, write) write("\n") del self.memo[i] - dispatch[TupleType] = dump_array - dispatch[ListType] = dump_array + dispatch[tuple] = dump_array + dispatch[list] = dump_array def dump_struct(self, value, write, escape=escape): i = id(value) @@ -661,8 +659,8 @@ write("\n") for k, v in value.items(): write("\n") - if type(k) is not StringType: - if unicode and type(k) is UnicodeType: + if not isinstance(k, str): + if unicode and isinstance(k, unicode): k = k.encode(self.encoding) else: raise TypeError, "dictionary key must be string" @@ -671,7 +669,7 @@ write("\n") write("\n") del self.memo[i] - dispatch[DictType] = dump_struct + dispatch[dict] = dump_struct if datetime: def dump_datetime(self, value, write): @@ -1019,12 +1017,10 @@ where necessary. """ - assert isinstance(params, TupleType) or isinstance(params, Fault),\ - "argument must be tuple or Fault instance" - + assert isinstance(params, (tuple, Fault)), "argument must be tuple or Fault instance" if isinstance(params, Fault): methodresponse = 1 - elif methodresponse and isinstance(params, TupleType): + elif methodresponse and isinstance(params, tuple): assert len(params) == 1, "response tuple must be a singleton" if not encoding: @@ -1045,7 +1041,7 @@ # standard XML-RPC wrappings if methodname: # a method call - if not isinstance(methodname, StringType): + if not isinstance(methodname, str): methodname = methodname.encode(encoding) data = ( xmlheader, @@ -1180,7 +1176,7 @@ def get_host_info(self, host): x509 = {} - if isinstance(host, TupleType): + if isinstance(host, tuple): host, x509 = host import urllib @@ -1230,7 +1226,7 @@ host, extra_headers, x509 = self.get_host_info(host) connection.putheader("Host", host) if extra_headers: - if isinstance(extra_headers, DictType): + if isinstance(extra_headers, dict): extra_headers = extra_headers.items() for key, value in extra_headers: connection.putheader(key, value) From python-3000-checkins at python.org Thu Jun 7 09:12:39 2007 From: python-3000-checkins at python.org (neal.norwitz) Date: Thu, 7 Jun 2007 09:12:39 +0200 (CEST) Subject: [Python-3000-checkins] r55798 - python/branches/p3yk/Tools/versioncheck/pyversioncheck.py Message-ID: <20070607071239.829A31E4006@bag.python.org> Author: neal.norwitz Date: Thu Jun 7 09:12:36 2007 New Revision: 55798 Modified: python/branches/p3yk/Tools/versioncheck/pyversioncheck.py Log: Remove a use of types, verify commit hook works Modified: python/branches/p3yk/Tools/versioncheck/pyversioncheck.py ============================================================================== --- python/branches/p3yk/Tools/versioncheck/pyversioncheck.py (original) +++ python/branches/p3yk/Tools/versioncheck/pyversioncheck.py Thu Jun 7 09:12:36 2007 @@ -1,5 +1,4 @@ """pyversioncheck - Module to help with checking versions""" -import types import rfc822 import urllib import sys @@ -35,7 +34,7 @@ def checkonly(package, url, version, verbose=0): if verbose >= VERBOSE_EACHFILE: print '%s:'%package - if type(url) == types.StringType: + if isinstance(url, str): ok, newversion, fp = _check1version(package, url, version, verbose) else: for u in url: From python-3000-checkins at python.org Thu Jun 7 13:26:17 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Thu, 7 Jun 2007 13:26:17 +0200 (CEST) Subject: [Python-3000-checkins] r55799 - python/branches/py3k-struni/Lib/test/test_codecs.py Message-ID: <20070607112617.CC6A31E4015@bag.python.org> Author: walter.doerwald Date: Thu Jun 7 13:26:16 2007 New Revision: 55799 Modified: python/branches/py3k-struni/Lib/test/test_codecs.py Log: Fix tests for unicode-internal codec. Modified: python/branches/py3k-struni/Lib/test/test_codecs.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_codecs.py (original) +++ python/branches/py3k-struni/Lib/test/test_codecs.py Thu Jun 7 13:26:16 2007 @@ -631,34 +631,34 @@ # points" above 0x10ffff on UCS-4 builds. if sys.maxunicode > 0xffff: ok = [ - ("\x00\x10\xff\xff", "\U0010ffff"), - ("\x00\x00\x01\x01", "\U00000101"), - ("", ""), + (b"\x00\x10\xff\xff", "\U0010ffff"), + (b"\x00\x00\x01\x01", "\U00000101"), + (b"", ""), ] not_ok = [ - "\x7f\xff\xff\xff", - "\x80\x00\x00\x00", - "\x81\x00\x00\x00", - "\x00", - "\x00\x00\x00\x00\x00", + b"\x7f\xff\xff\xff", + b"\x80\x00\x00\x00", + b"\x81\x00\x00\x00", + b"\x00", + b"\x00\x00\x00\x00\x00", ] for internal, uni in ok: if sys.byteorder == "little": - internal = "".join(reversed(internal)) + internal = bytes(reversed(internal)) self.assertEquals(uni, internal.decode("unicode_internal")) for internal in not_ok: if sys.byteorder == "little": - internal = "".join(reversed(internal)) + internal = bytes(reversed(internal)) self.assertRaises(UnicodeDecodeError, internal.decode, "unicode_internal") def test_decode_error_attributes(self): if sys.maxunicode > 0xffff: try: - "\x00\x00\x00\x00\x00\x11\x11\x00".decode("unicode_internal") + b"\x00\x00\x00\x00\x00\x11\x11\x00".decode("unicode_internal") except UnicodeDecodeError as ex: self.assertEquals("unicode_internal", ex.encoding) - self.assertEquals("\x00\x00\x00\x00\x00\x11\x11\x00", ex.object) + self.assertEquals(b"\x00\x00\x00\x00\x00\x11\x11\x00", ex.object) self.assertEquals(4, ex.start) self.assertEquals(8, ex.end) else: @@ -669,7 +669,7 @@ codecs.register_error("UnicodeInternalTest", codecs.ignore_errors) decoder = codecs.getdecoder("unicode_internal") ab = "ab".encode("unicode_internal") - ignored = decoder("%s\x22\x22\x22\x22%s" % (ab[:4], ab[4:]), + ignored = decoder(bytes("%s\x22\x22\x22\x22%s" % (ab[:4], ab[4:])), "UnicodeInternalTest") self.assertEquals(("ab", 12), ignored) From python-3000-checkins at python.org Thu Jun 7 14:40:10 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Thu, 7 Jun 2007 14:40:10 +0200 (CEST) Subject: [Python-3000-checkins] r55800 - python/branches/py3k-struni/Lib/test/test_deque.py Message-ID: <20070607124010.BCACF1E4006@bag.python.org> Author: walter.doerwald Date: Thu Jun 7 14:40:09 2007 New Revision: 55800 Modified: python/branches/py3k-struni/Lib/test/test_deque.py Log: Fix test_deque.py: Read and write file in text mode, so that read() returns a unicode object, which can be compared directly to the repr() result. Modified: python/branches/py3k-struni/Lib/test/test_deque.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_deque.py (original) +++ python/branches/py3k-struni/Lib/test/test_deque.py Thu Jun 7 14:40:09 2007 @@ -244,10 +244,10 @@ d = deque(range(200)) d.append(d) try: - fo = open(test_support.TESTFN, "wb") + fo = open(test_support.TESTFN, "w") fo.write(str(d)) fo.close() - fo = open(test_support.TESTFN, "rb") + fo = open(test_support.TESTFN, "r") self.assertEqual(fo.read(), repr(d)) finally: fo.close() From python-3000-checkins at python.org Thu Jun 7 15:11:05 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Thu, 7 Jun 2007 15:11:05 +0200 (CEST) Subject: [Python-3000-checkins] r55801 - python/branches/py3k-struni/Lib/copy.py Message-ID: <20070607131105.A39AA1E4006@bag.python.org> Author: walter.doerwald Date: Thu Jun 7 15:11:04 2007 New Revision: 55801 Modified: python/branches/py3k-struni/Lib/copy.py Log: Register a dispatcher for str8. (This makes test_copy.py pass again.) Make registeration of str dispatcher unconditional. Modified: python/branches/py3k-struni/Lib/copy.py ============================================================================== --- python/branches/py3k-struni/Lib/copy.py (original) +++ python/branches/py3k-struni/Lib/copy.py Thu Jun 7 15:11:04 2007 @@ -184,12 +184,9 @@ d[complex] = _deepcopy_atomic except NameError: pass +d[str8] = _deepcopy_atomic d[str] = _deepcopy_atomic try: - d[str] = _deepcopy_atomic -except NameError: - pass -try: d[types.CodeType] = _deepcopy_atomic except AttributeError: pass From python-3000-checkins at python.org Thu Jun 7 15:52:43 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Thu, 7 Jun 2007 15:52:43 +0200 (CEST) Subject: [Python-3000-checkins] r55807 - python/branches/py3k-struni/Lib/test/string_tests.py python/branches/py3k-struni/Lib/test/test_str.py Message-ID: <20070607135243.4F4EB1E4007@bag.python.org> Author: walter.doerwald Date: Thu Jun 7 15:52:37 2007 New Revision: 55807 Modified: python/branches/py3k-struni/Lib/test/string_tests.py python/branches/py3k-struni/Lib/test/test_str.py Log: Fix test_str.py so that it tests the str8 class. Fix string_tests.py::MixinStrUnicodeTest.test_bug1001011(): Test str and str8. Modified: python/branches/py3k-struni/Lib/test/string_tests.py ============================================================================== --- python/branches/py3k-struni/Lib/test/string_tests.py (original) +++ python/branches/py3k-struni/Lib/test/string_tests.py Thu Jun 7 15:52:37 2007 @@ -1154,7 +1154,7 @@ s2 = "".join([s1]) self.assert_(s1 is s2) - elif t is str: + elif t is str8: s1 = subclass("abcd") s2 = "".join([s1]) self.assert_(s1 is not s2) Modified: python/branches/py3k-struni/Lib/test/test_str.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_str.py (original) +++ python/branches/py3k-struni/Lib/test/test_str.py Thu Jun 7 15:52:37 2007 @@ -9,7 +9,7 @@ string_tests.MixinStrUnicodeTest, ): - type2test = str + type2test = str8 # We don't need to propagate to str def fixtype(self, obj): From python-3000-checkins at python.org Thu Jun 7 19:54:40 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 7 Jun 2007 19:54:40 +0200 (CEST) Subject: [Python-3000-checkins] r55808 - python/branches/py3k-struni/Objects/stringobject.c Message-ID: <20070607175440.75DE61E4003@bag.python.org> Author: guido.van.rossum Date: Thu Jun 7 19:54:36 2007 New Revision: 55808 Modified: python/branches/py3k-struni/Objects/stringobject.c Log: Don't lie in error messages from str8. In some cases we use the more neutral term string; in others we are explicit. Modified: python/branches/py3k-struni/Objects/stringobject.c ============================================================================== --- python/branches/py3k-struni/Objects/stringobject.c (original) +++ python/branches/py3k-struni/Objects/stringobject.c Thu Jun 7 19:54:36 2007 @@ -718,7 +718,7 @@ else { PyErr_Format(PyExc_TypeError, - "expected str object, " + "expected string, " "%.200s found", obj->ob_type->tp_name); return -1; } @@ -929,7 +929,7 @@ if (PyBytes_Check(bb)) return PyBytes_Concat((PyObject *)a, bb); PyErr_Format(PyExc_TypeError, - "cannot concatenate 'str' and '%.200s' objects", + "cannot concatenate 'str8' and '%.200s' objects", bb->ob_type->tp_name); return NULL; } @@ -2016,7 +2016,7 @@ return res; } PyErr_Format(PyExc_TypeError, - "%s arg must be None or str", + "%s arg must be None or string", STRIPNAME(striptype)); return NULL; } @@ -2026,7 +2026,7 @@ PyDoc_STRVAR(strip__doc__, -"S.strip([chars]) -> str\n\ +"S.strip([chars]) -> string\n\ \n\ Return a copy of the string S with leading and trailing\n\ whitespace removed.\n\ @@ -2044,7 +2044,7 @@ PyDoc_STRVAR(lstrip__doc__, -"S.lstrip([chars]) -> str\n\ +"S.lstrip([chars]) -> string\n\ \n\ Return a copy of the string S with leading whitespace removed.\n\ If chars is given and not None, remove characters in chars instead.\n\ @@ -2061,7 +2061,7 @@ PyDoc_STRVAR(rstrip__doc__, -"S.rstrip([chars]) -> str\n\ +"S.rstrip([chars]) -> string\n\ \n\ Return a copy of the string S with trailing whitespace removed.\n\ If chars is given and not None, remove characters in chars instead.\n\ @@ -3840,7 +3840,7 @@ if (type != &PyString_Type) return str_subtype_new(type, args, kwds); - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:str", kwlist, &x)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:str8", kwlist, &x)) return NULL; if (x == NULL) return PyString_FromString(""); @@ -3889,7 +3889,7 @@ } PyDoc_STRVAR(basestring_doc, -"Type basestring cannot be instantiated; it is the base for str and unicode."); +"Type basestring cannot be instantiated; it is the base for str8 and str."); static PyNumberMethods string_as_number = { 0, /*nb_add*/ @@ -4629,7 +4629,7 @@ goto error; if (!PyString_Check(temp)) { PyErr_SetString(PyExc_TypeError, - "%s argument has non-string str()"); + "%s argument has non-string str()/repr()"); Py_DECREF(temp); goto error; } From python-3000-checkins at python.org Thu Jun 7 20:11:38 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 7 Jun 2007 20:11:38 +0200 (CEST) Subject: [Python-3000-checkins] r55809 - python/branches/p3yk/Lib/distutils/unixccompiler.py Message-ID: <20070607181138.3E87C1E400E@bag.python.org> Author: guido.van.rossum Date: Thu Jun 7 20:11:29 2007 New Revision: 55809 Modified: python/branches/p3yk/Lib/distutils/unixccompiler.py Log: Fix syntax error introduced by Neal in last checkin. Modified: python/branches/p3yk/Lib/distutils/unixccompiler.py ============================================================================== --- python/branches/p3yk/Lib/distutils/unixccompiler.py (original) +++ python/branches/p3yk/Lib/distutils/unixccompiler.py Thu Jun 7 20:11:29 2007 @@ -211,7 +211,7 @@ lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs, libraries) - if not isinstance(output_dir, (str, type(None)): + if not isinstance(output_dir, (str, type(None))): raise TypeError, "'output_dir' must be a string or None" if output_dir is not None: output_filename = os.path.join(output_dir, output_filename) From python-3000-checkins at python.org Thu Jun 7 20:42:00 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Thu, 7 Jun 2007 20:42:00 +0200 (CEST) Subject: [Python-3000-checkins] r55810 - python/branches/py3k-struni/Python/sysmodule.c Message-ID: <20070607184200.A67C31E4013@bag.python.org> Author: walter.doerwald Date: Thu Jun 7 20:41:59 2007 New Revision: 55810 Modified: python/branches/py3k-struni/Python/sysmodule.c Log: Change most sys attributes that were str8 objects into str objects (executable, prefix and exec_prefix are still str8). Modified: python/branches/py3k-struni/Python/sysmodule.c ============================================================================== --- python/branches/py3k-struni/Python/sysmodule.c (original) +++ python/branches/py3k-struni/Python/sysmodule.c Thu Jun 7 20:41:59 2007 @@ -1049,13 +1049,13 @@ PyDict_SetItemString(sysdict, "__excepthook__", PyDict_GetItemString(sysdict, "excepthook")); PyDict_SetItemString(sysdict, "version", - v = PyString_FromString(Py_GetVersion())); + v = PyUnicode_FromString(Py_GetVersion())); Py_XDECREF(v); PyDict_SetItemString(sysdict, "hexversion", v = PyInt_FromLong(PY_VERSION_HEX)); Py_XDECREF(v); svnversion_init(); - v = Py_BuildValue("(ssz)", "CPython", branch, svn_revision); + v = Py_BuildValue("(UUU)", "CPython", branch, svn_revision); PyDict_SetItemString(sysdict, "subversion", v); Py_XDECREF(v); /* @@ -1079,16 +1079,16 @@ Py_XDECREF(v) SET_SYS_FROM_STRING("version_info", - Py_BuildValue("iiisi", PY_MAJOR_VERSION, + Py_BuildValue("iiiUi", PY_MAJOR_VERSION, PY_MINOR_VERSION, PY_MICRO_VERSION, s, PY_RELEASE_SERIAL)); SET_SYS_FROM_STRING("api_version", PyInt_FromLong(PYTHON_API_VERSION)); SET_SYS_FROM_STRING("copyright", - PyString_FromString(Py_GetCopyright())); + PyUnicode_FromString(Py_GetCopyright())); SET_SYS_FROM_STRING("platform", - PyString_FromString(Py_GetPlatform())); + PyUnicode_FromString(Py_GetPlatform())); SET_SYS_FROM_STRING("executable", PyString_FromString(Py_GetProgramFullPath())); SET_SYS_FROM_STRING("prefix", @@ -1113,13 +1113,13 @@ else value = "little"; SET_SYS_FROM_STRING("byteorder", - PyString_FromString(value)); + PyUnicode_FromString(value)); } #ifdef MS_COREDLL SET_SYS_FROM_STRING("dllhandle", PyLong_FromVoidPtr(PyWin_DLLhModule)); SET_SYS_FROM_STRING("winver", - PyString_FromString(PyWin_DLLVersionString)); + PyUnicode_FromString(PyWin_DLLVersionString)); #endif #undef SET_SYS_FROM_STRING if (warnoptions == NULL) { From python-3000-checkins at python.org Thu Jun 7 21:26:28 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Thu, 7 Jun 2007 21:26:28 +0200 (CEST) Subject: [Python-3000-checkins] r55811 - python/branches/py3k-struni/Lib/platform.py Message-ID: <20070607192628.9487F1E400F@bag.python.org> Author: walter.doerwald Date: Thu Jun 7 21:26:24 2007 New Revision: 55811 Modified: python/branches/py3k-struni/Lib/platform.py Log: Fix libc_ver(): libc_ver() was reading sys.executable in binary mode and comparing the content to strings, which failed. Now the bytes get decoded into unicode using latin-1 (the comparison compares ASCII strings only anyway, and we don't want the decoding to fail). Modified: python/branches/py3k-struni/Lib/platform.py ============================================================================== --- python/branches/py3k-struni/Lib/platform.py (original) +++ python/branches/py3k-struni/Lib/platform.py Thu Jun 7 21:26:24 2007 @@ -145,12 +145,12 @@ # able to open symlinks for reading executable = os.path.realpath(executable) f = open(executable,'rb') - binary = f.read(chunksize) + binary = f.read(chunksize).decode('latin-1') pos = 0 while 1: m = _libc_search.search(binary,pos) if not m: - binary = f.read(chunksize) + binary = f.read(chunksize).decode('latin-1') if not binary: break pos = 0 From python-3000-checkins at python.org Thu Jun 7 23:43:47 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 7 Jun 2007 23:43:47 +0200 (CEST) Subject: [Python-3000-checkins] r55813 - python/branches/py3k-struni/Lib/encodings/__init__.py Message-ID: <20070607214347.B3A6B1E4003@bag.python.org> Author: guido.van.rossum Date: Thu Jun 7 23:43:46 2007 New Revision: 55813 Modified: python/branches/py3k-struni/Lib/encodings/__init__.py Log: Change normalize_encodings() to avoid using .translate() or depending on the string type. It will always return a Unicode string. The algoritm's specification is unchanged. Modified: python/branches/py3k-struni/Lib/encodings/__init__.py ============================================================================== --- python/branches/py3k-struni/Lib/encodings/__init__.py (original) +++ python/branches/py3k-struni/Lib/encodings/__init__.py Thu Jun 7 23:43:46 2007 @@ -34,12 +34,6 @@ _cache = {} _unknown = '--unknown--' _import_tail = ['*'] -_norm_encoding_map = (' . ' - '0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ ' - ' abcdefghijklmnopqrstuvwxyz ' - ' ' - ' ' - ' ') _aliases = aliases.aliases class CodecRegistryError(LookupError, SystemError): @@ -58,14 +52,17 @@ non-ASCII characters, these must be Latin-1 compatible. """ - # Make sure we have an 8-bit string, because .translate() works - # differently for Unicode strings. - if isinstance(encoding, str): - # Note that .encode('latin-1') does *not* use the codec - # registry, so this call doesn't recurse. (See unicodeobject.c - # PyUnicode_AsEncodedString() for details) - encoding = encoding.encode('latin-1') - return '_'.join(encoding.translate(_norm_encoding_map).split()) + chars = [] + punct = False + for c in encoding: + if c.isalnum() or c == '.': + if punct and chars: + chars.append('_') + chars.append(c) + punct = False + else: + punct = True + return ''.join(chars) def search_function(encoding): From python-3000-checkins at python.org Thu Jun 7 23:56:49 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 7 Jun 2007 23:56:49 +0200 (CEST) Subject: [Python-3000-checkins] r55815 - in python/branches/py3k-struni/Lib: subprocess.py test/test_subprocess.py Message-ID: <20070607215649.2C83D1E4003@bag.python.org> Author: guido.van.rossum Date: Thu Jun 7 23:56:45 2007 New Revision: 55815 Modified: python/branches/py3k-struni/Lib/subprocess.py python/branches/py3k-struni/Lib/test/test_subprocess.py Log: The bufsize argument to Popen() should accept None meaning the default (0). Modified: python/branches/py3k-struni/Lib/subprocess.py ============================================================================== --- python/branches/py3k-struni/Lib/subprocess.py (original) +++ python/branches/py3k-struni/Lib/subprocess.py Thu Jun 7 23:56:45 2007 @@ -465,6 +465,8 @@ _cleanup() self._child_created = False + if bufsize is None: + bufsize = 0 # Restore default if not isinstance(bufsize, int): raise TypeError("bufsize must be an integer") Modified: python/branches/py3k-struni/Lib/test/test_subprocess.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_subprocess.py (original) +++ python/branches/py3k-struni/Lib/test/test_subprocess.py Thu Jun 7 23:56:45 2007 @@ -455,6 +455,14 @@ else: self.fail("Expected TypeError") + def test_bufsize_is_none(self): + # bufsize=None should be the same as bufsize=0. + p = subprocess.Popen([sys.executable, "-c", "pass"], None) + self.assertEqual(p.wait(), 0) + # Again with keyword arg + p = subprocess.Popen([sys.executable, "-c", "pass"], bufsize=None) + self.assertEqual(p.wait(), 0) + # # POSIX tests # From python-3000-checkins at python.org Fri Jun 8 00:37:49 2007 From: python-3000-checkins at python.org (alexandre.vassalotti) Date: Fri, 8 Jun 2007 00:37:49 +0200 (CEST) Subject: [Python-3000-checkins] r55817 - python/branches/py3k-struni/Lib/cmd.py Message-ID: <20070607223749.88F001E4012@bag.python.org> Author: alexandre.vassalotti Date: Fri Jun 8 00:37:45 2007 New Revision: 55817 Modified: python/branches/py3k-struni/Lib/cmd.py Log: Fix pdb help command. Modified: python/branches/py3k-struni/Lib/cmd.py ============================================================================== --- python/branches/py3k-struni/Lib/cmd.py (original) +++ python/branches/py3k-struni/Lib/cmd.py Fri Jun 8 00:37:45 2007 @@ -334,7 +334,7 @@ cmds_undoc.append(cmd) self.stdout.write("%s\n"%str(self.doc_leader)) self.print_topics(self.doc_header, cmds_doc, 15,80) - self.print_topics(self.misc_header, help.keys(),15,80) + self.print_topics(self.misc_header, list(help.keys()),15,80) self.print_topics(self.undoc_header, cmds_undoc, 15,80) def print_topics(self, header, cmds, cmdlen, maxcol): @@ -354,8 +354,9 @@ if not list: self.stdout.write("\n") return + nonstrings = [i for i in range(len(list)) - if not isinstance(list[i], str)] + if not isinstance(list[i], basestring)] if nonstrings: raise TypeError, ("list[i] not a string for i in %s" % ", ".join(map(str, nonstrings))) From python-3000-checkins at python.org Fri Jun 8 01:16:37 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Fri, 8 Jun 2007 01:16:37 +0200 (CEST) Subject: [Python-3000-checkins] r55818 - in python/branches/py3k-struni: Lib/bsddb/dbtables.py Lib/cgitb.py Lib/copy.py Lib/dis.py Lib/distutils/cmd.py Lib/distutils/dist.py Lib/distutils/extension.py Lib/distutils/text_file.py Lib/distutils/unixccompiler.py Lib/idlelib/CallTips.py Lib/idlelib/ObjectBrowser.py Lib/idlelib/rpc.py Lib/inspect.py Lib/lib-tk/ScrolledText.py Lib/lib-tk/Tkinter.py Lib/logging/__init__.py Lib/logging/config.py Lib/logging/handlers.py Lib/new.py Lib/optparse.py Lib/pickle.py Lib/pickletools.py Lib/plat-mac/aepack.py Lib/plat-mac/aetypes.py Lib/plat-mac/gensuitemodule.py Lib/sre_parse.py Lib/test/test_descr.py Lib/test/test_isinstance.py Lib/test/test_logging.py Lib/test/test_optparse.py Lib/test/test_pyclbr.py Lib/types.py Lib/unittest.py Lib/urllib2.py Lib/warnings.py Lib/wsgiref/headers.py Lib/wsgiref/validate.py Lib/xml/sax/saxutils.py Lib/xmlrpclib.py Tools/versioncheck/pyversioncheck.py Message-ID: <20070607231637.068A31E400B@bag.python.org> Author: guido.van.rossum Date: Fri Jun 8 01:15:56 2007 New Revision: 55818 Modified: python/branches/py3k-struni/ (props changed) python/branches/py3k-struni/Lib/bsddb/dbtables.py python/branches/py3k-struni/Lib/cgitb.py python/branches/py3k-struni/Lib/copy.py python/branches/py3k-struni/Lib/dis.py python/branches/py3k-struni/Lib/distutils/cmd.py python/branches/py3k-struni/Lib/distutils/dist.py python/branches/py3k-struni/Lib/distutils/extension.py python/branches/py3k-struni/Lib/distutils/text_file.py python/branches/py3k-struni/Lib/distutils/unixccompiler.py python/branches/py3k-struni/Lib/idlelib/CallTips.py python/branches/py3k-struni/Lib/idlelib/ObjectBrowser.py python/branches/py3k-struni/Lib/idlelib/rpc.py python/branches/py3k-struni/Lib/inspect.py python/branches/py3k-struni/Lib/lib-tk/ScrolledText.py python/branches/py3k-struni/Lib/lib-tk/Tkinter.py python/branches/py3k-struni/Lib/logging/__init__.py python/branches/py3k-struni/Lib/logging/config.py python/branches/py3k-struni/Lib/logging/handlers.py python/branches/py3k-struni/Lib/new.py python/branches/py3k-struni/Lib/optparse.py python/branches/py3k-struni/Lib/pickle.py python/branches/py3k-struni/Lib/pickletools.py python/branches/py3k-struni/Lib/plat-mac/aepack.py python/branches/py3k-struni/Lib/plat-mac/aetypes.py python/branches/py3k-struni/Lib/plat-mac/gensuitemodule.py python/branches/py3k-struni/Lib/sre_parse.py python/branches/py3k-struni/Lib/test/test_descr.py python/branches/py3k-struni/Lib/test/test_isinstance.py python/branches/py3k-struni/Lib/test/test_logging.py python/branches/py3k-struni/Lib/test/test_optparse.py python/branches/py3k-struni/Lib/test/test_pyclbr.py python/branches/py3k-struni/Lib/types.py python/branches/py3k-struni/Lib/unittest.py python/branches/py3k-struni/Lib/urllib2.py python/branches/py3k-struni/Lib/warnings.py python/branches/py3k-struni/Lib/wsgiref/headers.py python/branches/py3k-struni/Lib/wsgiref/validate.py python/branches/py3k-struni/Lib/xml/sax/saxutils.py python/branches/py3k-struni/Lib/xmlrpclib.py python/branches/py3k-struni/Tools/versioncheck/pyversioncheck.py Log: Merged revisions 55795-55816 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/p3yk ........ r55797 | neal.norwitz | 2007-06-07 00:00:57 -0700 (Thu, 07 Jun 2007) | 3 lines Get rid of some remnants of classic classes. types.ClassType == type. Also get rid of almost all uses of the types module and use the builtin name. ........ r55798 | neal.norwitz | 2007-06-07 00:12:36 -0700 (Thu, 07 Jun 2007) | 1 line Remove a use of types, verify commit hook works ........ r55809 | guido.van.rossum | 2007-06-07 11:11:29 -0700 (Thu, 07 Jun 2007) | 2 lines Fix syntax error introduced by Neal in last checkin. ........ Modified: python/branches/py3k-struni/Lib/bsddb/dbtables.py ============================================================================== --- python/branches/py3k-struni/Lib/bsddb/dbtables.py (original) +++ python/branches/py3k-struni/Lib/bsddb/dbtables.py Fri Jun 8 01:15:56 2007 @@ -22,7 +22,6 @@ import copy import xdrlib import random -from types import ListType, StringType import cPickle as pickle try: @@ -229,7 +228,7 @@ raises TableDBError if it already exists or for other DB errors. """ - assert isinstance(columns, ListType) + assert isinstance(columns, list) txn = None try: # checking sanity of the table and column names here on @@ -270,7 +269,7 @@ """Return a list of columns in the given table. [] if the table doesn't exist. """ - assert isinstance(table, StringType) + assert isinstance(table, str) if contains_metastrings(table): raise ValueError, "bad table name: contains reserved metastrings" @@ -300,7 +299,7 @@ additional columns present in the given list as well as all of its current columns. """ - assert isinstance(columns, ListType) + assert isinstance(columns, list) try: self.CreateTable(table, columns) except TableAlreadyExists: Modified: python/branches/py3k-struni/Lib/cgitb.py ============================================================================== --- python/branches/py3k-struni/Lib/cgitb.py (original) +++ python/branches/py3k-struni/Lib/cgitb.py Fri Jun 8 01:15:56 2007 @@ -96,10 +96,10 @@ def html(einfo, context=5): """Return a nice HTML document describing a given traceback.""" - import os, types, time, traceback, linecache, inspect, pydoc + import os, time, traceback, linecache, inspect, pydoc etype, evalue, etb = einfo - if type(etype) is types.ClassType: + if isinstance(etype, type): etype = etype.__name__ pyver = 'Python ' + sys.version.split()[0] + ': ' + sys.executable date = time.ctime(time.time()) @@ -188,10 +188,10 @@ def text(einfo, context=5): """Return a plain text document describing a given traceback.""" - import os, types, time, traceback, linecache, inspect, pydoc + import os, time, traceback, linecache, inspect, pydoc etype, evalue, etb = einfo - if type(etype) is types.ClassType: + if isinstance(etype, type): etype = etype.__name__ pyver = 'Python ' + sys.version.split()[0] + ': ' + sys.executable date = time.ctime(time.time()) Modified: python/branches/py3k-struni/Lib/copy.py ============================================================================== --- python/branches/py3k-struni/Lib/copy.py (original) +++ python/branches/py3k-struni/Lib/copy.py Fri Jun 8 01:15:56 2007 @@ -100,12 +100,15 @@ def _copy_immutable(x): return x for t in (type(None), int, float, bool, str, tuple, - frozenset, type, range, types.ClassType, + frozenset, type, range, types.BuiltinFunctionType, types.FunctionType): d[t] = _copy_immutable -for name in ("ComplexType", "UnicodeType", "CodeType"): - t = getattr(types, name, None) +t = getattr(types, "CodeType", None) +if t is not None: + d[t] = _copy_immutable +for name in ("complex", "unicode"): + t = globals()['__builtins__'].get(name) if t is not None: d[t] = _copy_immutable @@ -192,7 +195,6 @@ pass d[type] = _deepcopy_atomic d[range] = _deepcopy_atomic -d[types.ClassType] = _deepcopy_atomic d[types.BuiltinFunctionType] = _deepcopy_atomic d[types.FunctionType] = _deepcopy_atomic Modified: python/branches/py3k-struni/Lib/dis.py ============================================================================== --- python/branches/py3k-struni/Lib/dis.py (original) +++ python/branches/py3k-struni/Lib/dis.py Fri Jun 8 01:15:56 2007 @@ -26,7 +26,7 @@ items = sorted(x.__dict__.items()) for name, x1 in items: if isinstance(x1, (types.MethodType, types.FunctionType, - types.CodeType, types.ClassType, type)): + types.CodeType, type)): print("Disassembly of %s:" % name) try: dis(x1) Modified: python/branches/py3k-struni/Lib/distutils/cmd.py ============================================================================== --- python/branches/py3k-struni/Lib/distutils/cmd.py (original) +++ python/branches/py3k-struni/Lib/distutils/cmd.py Fri Jun 8 01:15:56 2007 @@ -9,7 +9,6 @@ __revision__ = "$Id$" import sys, os, re -from types import * from distutils.errors import * from distutils import util, dir_util, file_util, archive_util, dep_util from distutils import log @@ -245,7 +244,7 @@ elif isinstance(val, basestring): setattr(self, option, re.split(r',\s*|\s+', val)) else: - if type(val) is ListType: + if isinstance(val, list): ok = all(isinstance(v, basestring) for v in val) else: ok = 0 @@ -422,7 +421,7 @@ # Allow 'infiles' to be a single string if isinstance(infiles, basestring): infiles = (infiles,) - elif type(infiles) not in (ListType, TupleType): + elif not isinstance(infiles, (list, tuple)): raise TypeError, \ "'infiles' must be a string, or a list or tuple of strings" Modified: python/branches/py3k-struni/Lib/distutils/dist.py ============================================================================== --- python/branches/py3k-struni/Lib/distutils/dist.py (original) +++ python/branches/py3k-struni/Lib/distutils/dist.py Fri Jun 8 01:15:56 2007 @@ -9,7 +9,6 @@ __revision__ = "$Id$" import sys, os, re -from types import * from copy import copy try: @@ -527,7 +526,7 @@ # Also make sure that the command object provides a list of its # known options. if not (hasattr(cmd_class, 'user_options') and - type(cmd_class.user_options) is ListType): + isinstance(cmd_class.user_options, list)): raise DistutilsClassError, \ ("command class %s must provide " + "'user_options' attribute (a list of tuples)") % \ @@ -543,7 +542,7 @@ # Check for help_options in command class. They have a different # format (tuple of four) so we need to preprocess them here. if (hasattr(cmd_class, 'help_options') and - type(cmd_class.help_options) is ListType): + isinstance(cmd_class.help_options, list)): help_options = fix_help_options(cmd_class.help_options) else: help_options = [] @@ -561,7 +560,7 @@ return if (hasattr(cmd_class, 'help_options') and - type(cmd_class.help_options) is ListType): + isinstance(cmd_class.help_options, list)): help_option_found=0 for (help_option, short, desc, func) in cmd_class.help_options: if hasattr(opts, parser.get_attr_name(help_option)): @@ -646,12 +645,12 @@ print() for command in self.commands: - if type(command) is ClassType and issubclass(command, Command): + if isinstance(command, type) and issubclass(command, Command): klass = command else: klass = self.get_command_class(command) if (hasattr(klass, 'help_options') and - type(klass.help_options) is ListType): + isinstance(klass.help_options, list)): parser.set_option_table(klass.user_options + fix_help_options(klass.help_options)) else: Modified: python/branches/py3k-struni/Lib/distutils/extension.py ============================================================================== --- python/branches/py3k-struni/Lib/distutils/extension.py (original) +++ python/branches/py3k-struni/Lib/distutils/extension.py Fri Jun 8 01:15:56 2007 @@ -6,7 +6,6 @@ __revision__ = "$Id$" import os, sys -from types import * try: import warnings @@ -104,7 +103,7 @@ **kw # To catch unknown keywords ): assert isinstance(name, basestring), "'name' must be a string" - assert (type(sources) is ListType and + assert (isinstance(sources, list) and all(isinstance(v, basestring) for v in sources)), \ "'sources' must be a list of strings" Modified: python/branches/py3k-struni/Lib/distutils/text_file.py ============================================================================== --- python/branches/py3k-struni/Lib/distutils/text_file.py (original) +++ python/branches/py3k-struni/Lib/distutils/text_file.py Fri Jun 8 01:15:56 2007 @@ -6,7 +6,6 @@ __revision__ = "$Id$" -from types import * import sys, os, io @@ -137,7 +136,7 @@ if line is None: line = self.current_line outmsg.append(self.filename + ", ") - if type (line) in (ListType, TupleType): + if isinstance (line, (list, tuple)): outmsg.append("lines %d-%d: " % tuple (line)) else: outmsg.append("line %d: " % line) @@ -239,7 +238,7 @@ line = buildup_line + line # careful: pay attention to line number when incrementing it - if type (self.current_line) is ListType: + if isinstance (self.current_line, list): self.current_line[1] = self.current_line[1] + 1 else: self.current_line = [self.current_line, @@ -250,7 +249,7 @@ return None # still have to be careful about incrementing the line number! - if type (self.current_line) is ListType: + if isinstance (self.current_line, list): self.current_line = self.current_line[1] + 1 else: self.current_line = self.current_line + 1 Modified: python/branches/py3k-struni/Lib/distutils/unixccompiler.py ============================================================================== --- python/branches/py3k-struni/Lib/distutils/unixccompiler.py (original) +++ python/branches/py3k-struni/Lib/distutils/unixccompiler.py Fri Jun 8 01:15:56 2007 @@ -16,7 +16,6 @@ __revision__ = "$Id$" import os, sys -from types import NoneType from copy import copy from distutils import sysconfig @@ -212,7 +211,7 @@ lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs, libraries) - if not isinstance(output_dir, (basestring, NoneType)): + if not isinstance(output_dir, (basestring, type(None))): raise TypeError, "'output_dir' must be a string or None" if output_dir is not None: output_filename = os.path.join(output_dir, output_filename) Modified: python/branches/py3k-struni/Lib/idlelib/CallTips.py ============================================================================== --- python/branches/py3k-struni/Lib/idlelib/CallTips.py (original) +++ python/branches/py3k-struni/Lib/idlelib/CallTips.py Fri Jun 8 01:15:56 2007 @@ -131,14 +131,14 @@ arg_text = "" if ob is not None: arg_offset = 0 - if type(ob) in (types.ClassType, types.TypeType): + if isinstance(ob, type): # Look for the highest __init__ in the class chain. fob = _find_constructor(ob) if fob is None: fob = lambda: None else: arg_offset = 1 - elif type(ob)==types.MethodType: + elif isinstace(ob, types.MethodType): # bit of a hack for methods - turn it into a function # but we drop the "self" param. fob = ob.im_func @@ -146,7 +146,7 @@ else: fob = ob # Try to build one for Python defined functions - if type(fob) in [types.FunctionType, types.LambdaType]: + if isinstance(fob, (types.FunctionType, types.LambdaType)): argcount = fob.__code__.co_argcount real_args = fob.__code__.co_varnames[arg_offset:argcount] defaults = fob.__defaults__ or [] Modified: python/branches/py3k-struni/Lib/idlelib/ObjectBrowser.py ============================================================================== --- python/branches/py3k-struni/Lib/idlelib/ObjectBrowser.py (original) +++ python/branches/py3k-struni/Lib/idlelib/ObjectBrowser.py Fri Jun 8 01:15:56 2007 @@ -101,17 +101,14 @@ pass return keys -from types import * - dispatch = { - IntType: AtomicObjectTreeItem, - LongType: AtomicObjectTreeItem, - FloatType: AtomicObjectTreeItem, - StringType: AtomicObjectTreeItem, - TupleType: SequenceTreeItem, - ListType: SequenceTreeItem, - DictType: DictTreeItem, - ClassType: ClassTreeItem, + int: AtomicObjectTreeItem, + float: AtomicObjectTreeItem, + str: AtomicObjectTreeItem, + tuple: SequenceTreeItem, + list: SequenceTreeItem, + dict: DictTreeItem, + type: ClassTreeItem, } def make_objecttreeitem(labeltext, object, setfunction=None): Modified: python/branches/py3k-struni/Lib/idlelib/rpc.py ============================================================================== --- python/branches/py3k-struni/Lib/idlelib/rpc.py (original) +++ python/branches/py3k-struni/Lib/idlelib/rpc.py Fri Jun 8 01:15:56 2007 @@ -287,7 +287,7 @@ def _proxify(self, obj): if isinstance(obj, RemoteProxy): return RPCProxy(self, obj.oid) - if isinstance(obj, types.ListType): + if isinstance(obj, list): return map(self._proxify, obj) # XXX Check for other types -- not currently needed return obj @@ -574,7 +574,7 @@ attr = getattr(obj, name) if hasattr(attr, '__call__'): methods[name] = 1 - if type(obj) == types.ClassType: + if isinstance(obj, type): for super in obj.__bases__: _getmethods(super, methods) Modified: python/branches/py3k-struni/Lib/inspect.py ============================================================================== --- python/branches/py3k-struni/Lib/inspect.py (original) +++ python/branches/py3k-struni/Lib/inspect.py Fri Jun 8 01:15:56 2007 @@ -47,7 +47,7 @@ Class objects provide these attributes: __doc__ documentation string __module__ name of module in which this class was defined""" - return isinstance(object, types.ClassType) or hasattr(object, '__bases__') + return isinstance(object, type) or hasattr(object, '__bases__') def ismethod(object): """Return true if the object is an instance method. Modified: python/branches/py3k-struni/Lib/lib-tk/ScrolledText.py ============================================================================== --- python/branches/py3k-struni/Lib/lib-tk/ScrolledText.py (original) +++ python/branches/py3k-struni/Lib/lib-tk/ScrolledText.py Fri Jun 8 01:15:56 2007 @@ -21,7 +21,7 @@ cnf = _cnfmerge((cnf, kw)) fcnf = {} for k in cnf.keys(): - if type(k) == ClassType or k == 'name': + if isinstace(k, type) or k == 'name': fcnf[k] = cnf[k] del cnf[k] self.frame = Frame(master, **fcnf) Modified: python/branches/py3k-struni/Lib/lib-tk/Tkinter.py ============================================================================== --- python/branches/py3k-struni/Lib/lib-tk/Tkinter.py (original) +++ python/branches/py3k-struni/Lib/lib-tk/Tkinter.py Fri Jun 8 01:15:56 2007 @@ -38,7 +38,6 @@ import _tkinter # If this fails your Python may not be configured for Tk tkinter = _tkinter # b/w compat for export TclError = _tkinter.TclError -from types import * from Tkconstants import * try: import MacOS; _MacOS = MacOS; del MacOS @@ -61,11 +60,11 @@ except AttributeError: _tkinter.deletefilehandler = None -def _flatten(tuple): +def _flatten(seq): """Internal function.""" res = () - for item in tuple: - if type(item) in (TupleType, ListType): + for item in seq: + if isinstance(item, (tuple, list)): res = res + _flatten(item) elif item is not None: res = res + (item,) @@ -76,9 +75,9 @@ def _cnfmerge(cnfs): """Internal function.""" - if type(cnfs) is DictionaryType: + if isinstance(cnfs, dict): return cnfs - elif type(cnfs) in (NoneType, StringType): + elif isinstance(cnfs, (type(None), str)): return cnfs else: cnf = {} @@ -867,7 +866,7 @@ data = self.tk.split( self.tk.call('winfo', 'visualsavailable', self._w, includeids and 'includeids' or None)) - if type(data) is StringType: + if isinstance(data, str): data = [self.tk.split(data)] return map(self.__winfo_parseitem, data) def __winfo_parseitem(self, t): @@ -934,7 +933,7 @@ self.tk.call('bindtags', self._w, tagList) def _bind(self, what, sequence, func, add, needcleanup=1): """Internal function.""" - if type(func) is StringType: + if isinstance(func, str): self.tk.call(what + (sequence, func)) elif func: funcid = self._register(func, self._substitute, @@ -1181,7 +1180,7 @@ self.tk.call(_flatten((self._w, cmd)))): cnf[x[0][1:]] = (x[0][1:],) + x[1:] return cnf - if type(cnf) is StringType: + if isinstance(cnf, str): x = self.tk.split( self.tk.call(_flatten((self._w, cmd, '-'+cnf)))) return (x[0][1:],) + x[1:] @@ -1262,7 +1261,7 @@ bbox = grid_bbox def _grid_configure(self, command, index, cnf, kw): """Internal function.""" - if type(cnf) is StringType and not kw: + if isinstance(cnf, str) and not kw: if cnf[-1:] == '_': cnf = cnf[:-1] if cnf[:1] != '-': @@ -1923,7 +1922,7 @@ BaseWidget._setup(self, master, cnf) classes = [] for k in cnf.keys(): - if type(k) is ClassType: + if isinstance(k, type): classes.append((k, cnf[k])) del cnf[k] self.tk.call( @@ -2136,7 +2135,7 @@ """Internal function.""" args = _flatten(args) cnf = args[-1] - if type(cnf) in (DictionaryType, TupleType): + if isinstance(cnf, (dict, tuple)): args = args[:-1] else: cnf = {} @@ -3695,7 +3694,7 @@ 'paneconfigure', tagOrId)): cnf[x[0][1:]] = (x[0][1:],) + x[1:] return cnf - if type(cnf) == StringType and not kw: + if isinstance(cnf, str) and not kw: x = self.tk.split(self.tk.call( self._w, 'paneconfigure', tagOrId, '-'+cnf)) return (x[0][1:],) + x[1:] Modified: python/branches/py3k-struni/Lib/logging/__init__.py ============================================================================== --- python/branches/py3k-struni/Lib/logging/__init__.py (original) +++ python/branches/py3k-struni/Lib/logging/__init__.py Fri Jun 8 01:15:56 2007 @@ -26,7 +26,7 @@ To use, simply 'import logging' and log away! """ -import sys, os, types, time, cStringIO, traceback +import sys, os, time, cStringIO, traceback try: import codecs @@ -48,6 +48,8 @@ # Miscellaneous module data #--------------------------------------------------------------------------- +_unicode = 'unicode' in dir(__builtins__) + # # _srcfile is used when walking the stack to check when we've got the first # caller stack frame. @@ -234,7 +236,7 @@ # 'Value is %d' instead of 'Value is 0'. # For the use case of passing a dictionary, this should not be a # problem. - if args and (len(args) == 1) and args[0] and (type(args[0]) == types.DictType): + if args and (len(args) == 1) and args[0] and isinstance(args[0], dict): args = args[0] self.args = args self.levelname = getLevelName(level) @@ -275,11 +277,11 @@ Return the message for this LogRecord after merging any user-supplied arguments with the message. """ - if not hasattr(types, "UnicodeType"): #if no unicode support... + if not _unicode: #if no unicode support... msg = str(self.msg) else: msg = self.msg - if type(msg) not in (types.UnicodeType, types.StringType): + if not isinstance(msg, basestring): try: msg = str(self.msg) except UnicodeError: @@ -743,7 +745,7 @@ try: msg = self.format(record) fs = "%s\n" - if not hasattr(types, "UnicodeType"): #if no unicode support... + if not _unicode: #if no unicode support... self.stream.write(fs % msg) else: try: @@ -1053,7 +1055,7 @@ logger.log(level, "We have a %s", "mysterious problem", exc_info=1) """ - if type(level) != types.IntType: + if not isinstance(level, int): if raiseExceptions: raise TypeError, "level must be an integer" else: @@ -1103,7 +1105,7 @@ else: fn, lno, func = "(unknown file)", 0, "(unknown function)" if exc_info: - if type(exc_info) != types.TupleType: + if not isinstance(exc_info, tuple): exc_info = sys.exc_info() record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra) self.handle(record) Modified: python/branches/py3k-struni/Lib/logging/config.py ============================================================================== --- python/branches/py3k-struni/Lib/logging/config.py (original) +++ python/branches/py3k-struni/Lib/logging/config.py Fri Jun 8 01:15:56 2007 @@ -27,7 +27,7 @@ To use, simply 'import logging' and log away! """ -import sys, logging, logging.handlers, socket, struct, os, traceback, types +import sys, logging, logging.handlers, socket, struct, os, traceback try: import thread @@ -289,7 +289,7 @@ traceback.print_exc() os.remove(file) except socket.error as e: - if type(e.args) != types.TupleType: + if not isinstancetype(e.args, tuple): raise else: errcode = e.args[0] Modified: python/branches/py3k-struni/Lib/logging/handlers.py ============================================================================== --- python/branches/py3k-struni/Lib/logging/handlers.py (original) +++ python/branches/py3k-struni/Lib/logging/handlers.py Fri Jun 8 01:15:56 2007 @@ -27,7 +27,7 @@ To use, simply 'import logging' and log away! """ -import sys, logging, socket, types, os, struct, time, glob +import sys, logging, socket, os, struct, time, glob try: import cPickle as pickle except ImportError: @@ -637,7 +637,7 @@ self.address = address self.facility = facility - if type(address) == types.StringType: + if isinstance(address, str): self.unixsocket = 1 self._connect_unixsocket(address) else: @@ -669,9 +669,9 @@ priority_names mapping dictionaries are used to convert them to integers. """ - if type(facility) == types.StringType: + if isinstance(facility, str): facility = self.facility_names[facility] - if type(priority) == types.StringType: + if isinstance(priority, str): priority = self.priority_names[priority] return (facility << 3) | priority @@ -738,16 +738,16 @@ for the credentials argument. """ logging.Handler.__init__(self) - if type(mailhost) == types.TupleType: + if isinstance(mailhost, tuple): self.mailhost, self.mailport = mailhost else: self.mailhost, self.mailport = mailhost, None - if type(credentials) == types.TupleType: + if isinstance(credentials, tuple): self.username, self.password = credentials else: self.username = None self.fromaddr = fromaddr - if type(toaddrs) == types.StringType: + if isinstance(toaddrs, str): toaddrs = [toaddrs] self.toaddrs = toaddrs self.subject = subject Modified: python/branches/py3k-struni/Lib/new.py ============================================================================== --- python/branches/py3k-struni/Lib/new.py (original) +++ python/branches/py3k-struni/Lib/new.py Fri Jun 8 01:15:56 2007 @@ -4,7 +4,7 @@ Objects of most types can now be created by calling the type object. """ -from types import ClassType as classobj +classobj = type from types import FunctionType as function from types import MethodType as instancemethod from types import ModuleType as module Modified: python/branches/py3k-struni/Lib/optparse.py ============================================================================== --- python/branches/py3k-struni/Lib/optparse.py (original) +++ python/branches/py3k-struni/Lib/optparse.py Fri Jun 8 01:15:56 2007 @@ -67,7 +67,6 @@ """ import sys, os -import types import textwrap def _repr(self): @@ -641,7 +640,7 @@ # Python 2.1 and earlier, and is short-circuited by the # first check on modern Pythons.) import __builtin__ - if ( type(self.type) is types.TypeType or + if ( isinstance(self.type, type) or (hasattr(self.type, "__name__") and getattr(__builtin__, self.type.__name__, None) is self.type) ): self.type = self.type.__name__ @@ -660,7 +659,7 @@ if self.choices is None: raise OptionError( "must supply a list of choices for type 'choice'", self) - elif type(self.choices) not in (types.TupleType, types.ListType): + elif not isinstance(self.choices, (tuple, list)): raise OptionError( "choices must be a list of strings ('%s' supplied)" % str(type(self.choices)).split("'")[1], self) @@ -704,12 +703,12 @@ raise OptionError( "callback not callable: %r" % self.callback, self) if (self.callback_args is not None and - type(self.callback_args) is not types.TupleType): + not isinstance(self.callback_args, tuple)): raise OptionError( "callback_args, if supplied, must be a tuple: not %r" % self.callback_args, self) if (self.callback_kwargs is not None and - type(self.callback_kwargs) is not types.DictType): + not isinstance(self.callback_kwargs, dict)): raise OptionError( "callback_kwargs, if supplied, must be a dict: not %r" % self.callback_kwargs, self) @@ -834,7 +833,7 @@ def __eq__(self, other): if isinstance(other, Values): return self.__dict__ == other.__dict__ - elif isinstance(other, types.DictType): + elif isinstance(other, dict): return self.__dict__ == other else: return NotImplemented Modified: python/branches/py3k-struni/Lib/pickle.py ============================================================================== --- python/branches/py3k-struni/Lib/pickle.py (original) +++ python/branches/py3k-struni/Lib/pickle.py Fri Jun 8 01:15:56 2007 @@ -26,7 +26,7 @@ __version__ = "$Revision$" # Code version -from types import * +from types import FunctionType, BuiltinFunctionType from copy_reg import dispatch_table from copy_reg import _extension_registry, _inverted_registry, _extension_cache import marshal @@ -283,7 +283,7 @@ # Check for a class with a custom metaclass; treat as regular class try: - issc = issubclass(t, TypeType) + issc = issubclass(t, type) except TypeError: # t is not a class (old Boost; see SF #502085) issc = 0 if issc: @@ -313,7 +313,7 @@ return # Assert that reduce() returned a tuple - if type(rv) is not TupleType: + if not isinstance(rv, tuple): raise PicklingError("%s must return string or tuple" % reduce) # Assert that it returned an appropriately sized tuple @@ -342,7 +342,7 @@ # This API is called by some subclasses # Assert that args is a tuple or None - if not isinstance(args, TupleType): + if not isinstance(args, tuple): raise PicklingError("args from reduce() should be a tuple") # Assert that func is callable @@ -420,7 +420,7 @@ def save_none(self, obj): self.write(NONE) - dispatch[NoneType] = save_none + dispatch[type(None)] = save_none def save_bool(self, obj): if self.proto >= 2: @@ -452,7 +452,7 @@ # Text pickle, or int too big to fit in signed 4-byte format. self.write(INT + bytes(repr(obj)) + b'\n') # XXX save_int is merged into save_long - # dispatch[IntType] = save_int + # dispatch[int] = save_int def save_long(self, obj, pack=struct.pack): if self.bin: @@ -483,14 +483,14 @@ self.write(LONG4 + pack("d', obj)) else: self.write(FLOAT + bytes(repr(obj)) + b'\n') - dispatch[FloatType] = save_float + dispatch[float] = save_float def save_string(self, obj, pack=struct.pack): if self.bin: @@ -568,7 +568,7 @@ self.write(TUPLE) self.memoize(obj) - dispatch[TupleType] = save_tuple + dispatch[tuple] = save_tuple # save_empty_tuple() isn't used by anything in Python 2.3. However, I # found a Pickler subclass in Zope3 that calls it, so it's not harmless @@ -587,7 +587,7 @@ self.memoize(obj) self._batch_appends(iter(obj)) - dispatch[ListType] = save_list + dispatch[list] = save_list # Keep in synch with cPickle's BATCHSIZE. Nothing will break if it gets # out of synch, though. @@ -636,8 +636,8 @@ self.memoize(obj) self._batch_setitems(iter(obj.items())) - dispatch[DictionaryType] = save_dict - if not PyStringMap is None: + dispatch[dict] = save_dict + if PyStringMap is not None: dispatch[PyStringMap] = save_dict def _batch_setitems(self, items): @@ -715,10 +715,9 @@ write(GLOBAL + bytes(module) + b'\n' + bytes(name) + b'\n') self.memoize(obj) - dispatch[ClassType] = save_global dispatch[FunctionType] = save_global dispatch[BuiltinFunctionType] = save_global - dispatch[TypeType] = save_global + dispatch[type] = save_global # Pickling helpers @@ -1007,7 +1006,7 @@ del self.stack[k:] instantiated = 0 if (not args and - type(klass) is ClassType and + isinstance(klass, type) and not hasattr(klass, "__getinitargs__")): value = _EmptyClass() value.__class__ = klass Modified: python/branches/py3k-struni/Lib/pickletools.py ============================================================================== --- python/branches/py3k-struni/Lib/pickletools.py (original) +++ python/branches/py3k-struni/Lib/pickletools.py Fri Jun 8 01:15:56 2007 @@ -1531,7 +1531,7 @@ opcode is followed by code to create setstate's argument, and then a BUILD opcode to apply __setstate__ to that argument. - If type(callable) is not ClassType, REDUCE complains unless the + If not isinstance(callable, type), REDUCE complains unless the callable has been registered with the copy_reg module's safe_constructors dict, or the callable has a magic '__safe_for_unpickling__' attribute with a true value. I'm not sure @@ -1587,9 +1587,6 @@ + The argtuple is empty (markobject was at the top of the stack at the start). - + It's an old-style class object (the type of the class object is - ClassType). - + The class object does not have a __getinitargs__ attribute. then we want to create an old-style class instance without invoking Modified: python/branches/py3k-struni/Lib/plat-mac/aepack.py ============================================================================== --- python/branches/py3k-struni/Lib/plat-mac/aepack.py (original) +++ python/branches/py3k-struni/Lib/plat-mac/aepack.py Fri Jun 8 01:15:56 2007 @@ -13,8 +13,6 @@ # import struct -import types -from types import * from Carbon import AE from Carbon.AppleEvents import * import MacOS @@ -74,7 +72,7 @@ """Pack a python object into an AE descriptor""" if forcetype: - if type(x) is StringType: + if isinstance(x, str): return AE.AECreateDesc(forcetype, x) else: return pack(x).AECoerceDesc(forcetype) @@ -90,29 +88,29 @@ return AE.AECreateDesc('fsrf', x.data) if isinstance(x, AliasType): return AE.AECreateDesc('alis', x.data) - if isinstance(x, IntType): + if isinstance(x, int): return AE.AECreateDesc('long', struct.pack('l', x)) - if isinstance(x, FloatType): + if isinstance(x, float): return AE.AECreateDesc('doub', struct.pack('d', x)) - if isinstance(x, StringType): + if isinstance(x, str): return AE.AECreateDesc('TEXT', x) - if isinstance(x, UnicodeType): + if isinstance(x, unicode): data = x.encode('utf16') if data[:2] == '\xfe\xff': data = data[2:] return AE.AECreateDesc('utxt', data) - if isinstance(x, ListType): + if isinstance(x, list): list = AE.AECreateList('', 0) for item in x: list.AEPutDesc(0, pack(item)) return list - if isinstance(x, DictionaryType): + if isinstance(x, dict): record = AE.AECreateList('', 1) for key, value in x.items(): packkey(record, key, value) #record.AEPutParamDesc(key, pack(value)) return record - if type(x) == types.ClassType and issubclass(x, ObjectSpecifier): + if isinstance(x, type) and issubclass(x, ObjectSpecifier): # Note: we are getting a class object here, not an instance return AE.AECreateDesc('type', x.want) if hasattr(x, '__aepack__'): @@ -340,7 +338,7 @@ # to __class__ is safe. Moreover, shouldn't there be a better # initializer for the classes in the suites? def mkobjectfrommodule(dict, modulename): - if type(dict['want']) == types.ClassType and issubclass(dict['want'], ObjectSpecifier): + if isinstance(dict['want'], type) and issubclass(dict['want'], ObjectSpecifier): # The type has already been converted to Python. Convert back:-( classtype = dict['want'] dict['want'] = aetypes.mktype(classtype.want) Modified: python/branches/py3k-struni/Lib/plat-mac/aetypes.py ============================================================================== --- python/branches/py3k-struni/Lib/plat-mac/aetypes.py (original) +++ python/branches/py3k-struni/Lib/plat-mac/aetypes.py Fri Jun 8 01:15:56 2007 @@ -2,7 +2,6 @@ from Carbon.AppleEvents import * import struct -from types import * # # convoluted, since there are cyclic dependencies between this file and @@ -14,7 +13,7 @@ def nice(s): """'nice' representation of an object""" - if type(s) is StringType: return repr(s) + if isinstance(s, str): return repr(s) else: return str(s) class Unknown: @@ -222,7 +221,7 @@ return "Logical(%r, %r)" % (self.logc, self.term) def __str__(self): - if type(self.term) == ListType and len(self.term) == 2: + if isinstance(self.term, list) and len(self.term) == 2: return "%s %s %s" % (nice(self.term[0]), self.logc.strip(), nice(self.term[1])) @@ -481,13 +480,13 @@ def __init__(self, want, seld, fr = None): t = type(seld) - if t == StringType: + if isinstance(t, str): form = 'name' elif IsRange(seld): form = 'rang' elif IsComparison(seld) or IsLogical(seld): form = 'test' - elif t == TupleType: + elif isinstance(t, tuple): # Breakout: specify both form and seld in a tuple # (if you want ID or rele or somesuch) form, seld = seld @@ -513,7 +512,7 @@ def __str__(self): seld = self.seld - if type(seld) == StringType: + if isinstance(seld, str): ss = repr(seld) elif IsRange(seld): start, stop = seld.start, seld.stop Modified: python/branches/py3k-struni/Lib/plat-mac/gensuitemodule.py ============================================================================== --- python/branches/py3k-struni/Lib/plat-mac/gensuitemodule.py (original) +++ python/branches/py3k-struni/Lib/plat-mac/gensuitemodule.py Fri Jun 8 01:15:56 2007 @@ -279,9 +279,9 @@ def simplify(item): """Recursively replace singleton tuples by their constituent item""" - if type(item) is types.ListType: + if isinstance(item, list): return map(simplify, item) - elif type(item) == types.TupleType and len(item) == 2: + elif isinstance(item, tuple) and len(item) == 2: return simplify(item[1]) else: return item @@ -352,7 +352,7 @@ def generic(what, f, *args): if type(what) == types.FunctionType: return what(f, *args) - if type(what) == types.ListType: + if isinstance(what, list): record = [] for thing in what: item = generic(thing[:1], f, *thing[1:]) Modified: python/branches/py3k-struni/Lib/sre_parse.py ============================================================================== --- python/branches/py3k-struni/Lib/sre_parse.py (original) +++ python/branches/py3k-struni/Lib/sre_parse.py Fri Jun 8 01:15:56 2007 @@ -101,7 +101,7 @@ self.width = None def dump(self, level=0): nl = 1 - seqtypes = type(()), type([]) + seqtypes = (tuple, list) for op, av in self.data: print(level*" " + op, end=' '); nl = 0 if op == "in": @@ -117,7 +117,7 @@ print(level*" " + "or") a.dump(level+1); nl = 1 i = i + 1 - elif type(av) in seqtypes: + elif isinstance(av, seqtypes): for a in av: if isinstance(a, SubPattern): if not nl: print() @@ -709,7 +709,7 @@ else: pappend((LITERAL, literal)) sep = source[:0] - if type(sep) is type(""): + if isinstance(sep, str): makechar = chr else: makechar = chr Modified: python/branches/py3k-struni/Lib/test/test_descr.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_descr.py (original) +++ python/branches/py3k-struni/Lib/test/test_descr.py Fri Jun 8 01:15:56 2007 @@ -4103,7 +4103,8 @@ N1 = sys.maxint + 1 # might trigger OverflowErrors instead of TypeErrors N2 = sys.maxint # if sizeof(int) < sizeof(long), might trigger # ValueErrors instead of TypeErrors - for metaclass in [type, types.ClassType]: + if 1: + metaclass = type for name, expr, iexpr in [ ('__add__', 'x + y', 'x += y'), ('__sub__', 'x - y', 'x -= y'), Modified: python/branches/py3k-struni/Lib/test/test_isinstance.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_isinstance.py (original) +++ python/branches/py3k-struni/Lib/test/test_isinstance.py Fri Jun 8 01:15:56 2007 @@ -15,7 +15,7 @@ # (leading to an "undetected error" in the debug build). Set up is, # isinstance(inst, cls) where: # - # - cls isn't a ClassType, a TypeType, or a TupleType + # - cls isn't a a type, or a tuple # - cls has a __bases__ attribute # - inst has a __class__ attribute # - inst.__class__ as no __bases__ attribute Modified: python/branches/py3k-struni/Lib/test/test_logging.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_logging.py (original) +++ python/branches/py3k-struni/Lib/test/test_logging.py Fri Jun 8 01:15:56 2007 @@ -25,7 +25,7 @@ """ import select -import os, sys, struct, types, pickle, cStringIO +import os, sys, struct, pickle, cStringIO import socket, tempfile, threading, time import logging, logging.handlers, logging.config from test.test_support import run_with_locale Modified: python/branches/py3k-struni/Lib/test/test_optparse.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_optparse.py (original) +++ python/branches/py3k-struni/Lib/test/test_optparse.py Fri Jun 8 01:15:56 2007 @@ -12,7 +12,6 @@ import os import re import copy -import types import unittest from StringIO import StringIO @@ -171,7 +170,7 @@ except InterceptedError as err: self.assert_( - type(output) is types.StringType, + isinstance(output, str), "expected output to be an ordinary string, not %r" % type(output)) @@ -432,18 +431,12 @@ self.parser.add_option("-s", type="str") self.assertEquals(self.parser.get_option("-s").type, "string") - def test_new_type_object(self): + def test_type_object(self): self.parser.add_option("-s", type=str) self.assertEquals(self.parser.get_option("-s").type, "string") self.parser.add_option("-x", type=int) self.assertEquals(self.parser.get_option("-x").type, "int") - def test_old_type_object(self): - self.parser.add_option("-s", type=types.StringType) - self.assertEquals(self.parser.get_option("-s").type, "string") - self.parser.add_option("-x", type=types.IntType) - self.assertEquals(self.parser.get_option("-x").type, "int") - # Custom type for testing processing of default values. _time_units = { 's' : 1, 'm' : 60, 'h' : 60*60, 'd' : 60*60*24 } @@ -1470,7 +1463,7 @@ os.environ['COLUMNS'] = orig_columns def assertHelpEquals(self, expected_output): - if type(expected_output) is types.UnicodeType: + if isinstance(expected_output, unicode): encoding = self.parser._get_encoding(sys.stdout) expected_output = expected_output.encode(encoding, "replace") Modified: python/branches/py3k-struni/Lib/test/test_pyclbr.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_pyclbr.py (original) +++ python/branches/py3k-struni/Lib/test/test_pyclbr.py Fri Jun 8 01:15:56 2007 @@ -4,7 +4,7 @@ ''' from test.test_support import run_unittest import unittest, sys -from types import ClassType, FunctionType, MethodType, BuiltinFunctionType +from types import FunctionType, MethodType, BuiltinFunctionType import pyclbr from unittest import TestCase @@ -95,7 +95,7 @@ continue # skip functions that came from somewhere else self.assertEquals(py_item.__module__, value.module) else: - self.failUnless(isinstance(py_item, (ClassType, type))) + self.failUnless(isinstance(py_item, type)) if py_item.__module__ != moduleName: continue # skip classes that came from somewhere else @@ -133,14 +133,14 @@ # Now check for missing stuff. def defined_in(item, module): - if isinstance(item, ClassType): + if isinstance(item, type): return item.__module__ == module.__name__ if isinstance(item, FunctionType): return item.__globals__ is module.__dict__ return False for name in dir(module): item = getattr(module, name) - if isinstance(item, (ClassType, FunctionType)): + if isinstance(item, (type, FunctionType)): if defined_in(item, module): self.assertHaskey(dict, name, ignore) Modified: python/branches/py3k-struni/Lib/types.py ============================================================================== --- python/branches/py3k-struni/Lib/types.py (original) +++ python/branches/py3k-struni/Lib/types.py Fri Jun 8 01:15:56 2007 @@ -39,7 +39,7 @@ class _C: def _m(self): pass -ClassType = type(_C) +ClassType = type UnboundMethodType = type(_C._m) # Same as MethodType MethodType = type(_C()._m) Modified: python/branches/py3k-struni/Lib/unittest.py ============================================================================== --- python/branches/py3k-struni/Lib/unittest.py (original) +++ python/branches/py3k-struni/Lib/unittest.py Fri Jun 8 01:15:56 2007 @@ -412,8 +412,7 @@ # sanity checks if not hasattr(test, '__call__'): raise TypeError("the test to add must be callable") - if (isinstance(test, (type, types.ClassType)) and - issubclass(test, (TestCase, TestSuite))): + if isinstance(test, type) and issubclass(test, (TestCase, TestSuite)): raise TypeError("TestCases and TestSuites must be instantiated " "before passing them to addTest()") self._tests.append(test) @@ -525,8 +524,7 @@ tests = [] for name in dir(module): obj = getattr(module, name) - if (isinstance(obj, (type, types.ClassType)) and - issubclass(obj, TestCase)): + if isinstance(obj, type) and issubclass(obj, TestCase): tests.append(self.loadTestsFromTestCase(obj)) return self.suiteClass(tests) @@ -556,11 +554,10 @@ if type(obj) == types.ModuleType: return self.loadTestsFromModule(obj) - elif (isinstance(obj, (type, types.ClassType)) and - issubclass(obj, TestCase)): + elif isinstance(obj, type) and issubclass(obj, TestCase): return self.loadTestsFromTestCase(obj) - elif (type(obj) == types.UnboundMethodType and - isinstance(parent, (type, types.ClassType)) and + elif (isinstance(obj, types.UnboundMethodType) and + isinstance(parent, type) and issubclass(parent, TestCase)): return TestSuite([parent(obj.__name__)]) elif isinstance(obj, TestSuite): @@ -816,7 +813,7 @@ self.module) def runTests(self): - if isinstance(self.testRunner, (type, types.ClassType)): + if isinstance(self.testRunner, type): try: testRunner = self.testRunner(verbosity=self.verbosity) except TypeError: Modified: python/branches/py3k-struni/Lib/urllib2.py ============================================================================== --- python/branches/py3k-struni/Lib/urllib2.py (original) +++ python/branches/py3k-struni/Lib/urllib2.py Fri Jun 8 01:15:56 2007 @@ -428,9 +428,8 @@ If any of the handlers passed as arguments are subclasses of the default handlers, the default handlers will not be used. """ - import types def isclass(obj): - return isinstance(obj, types.ClassType) or hasattr(obj, "__bases__") + return isinstance(obj, type) or hasattr(obj, "__bases__") opener = OpenerDirector() default_classes = [ProxyHandler, UnknownHandler, HTTPHandler, Modified: python/branches/py3k-struni/Lib/warnings.py ============================================================================== --- python/branches/py3k-struni/Lib/warnings.py (original) +++ python/branches/py3k-struni/Lib/warnings.py Fri Jun 8 01:15:56 2007 @@ -3,7 +3,7 @@ # Note: function level imports should *not* be used # in this module as it may cause import lock deadlock. # See bug 683658. -import sys, types +import sys import linecache __all__ = ["warn", "showwarning", "formatwarning", "filterwarnings", @@ -151,8 +151,7 @@ assert action in ("error", "ignore", "always", "default", "module", "once"), "invalid action: %r" % (action,) assert isinstance(message, basestring), "message must be a string" - assert isinstance(category, (type, types.ClassType)), \ - "category must be a class" + assert isinstance(category, type), "category must be a class" assert issubclass(category, Warning), "category must be a Warning subclass" assert isinstance(module, basestring), "module must be a string" assert isinstance(lineno, int) and lineno >= 0, \ Modified: python/branches/py3k-struni/Lib/wsgiref/headers.py ============================================================================== --- python/branches/py3k-struni/Lib/wsgiref/headers.py (original) +++ python/branches/py3k-struni/Lib/wsgiref/headers.py Fri Jun 8 01:15:56 2007 @@ -5,8 +5,6 @@ written by Barry Warsaw. """ -from types import ListType, TupleType - # Regular expression that matches `special' characters in parameters, the # existance of which force quoting of the parameter value. import re @@ -44,7 +42,7 @@ """Manage a collection of HTTP response headers""" def __init__(self,headers): - if type(headers) is not ListType: + if not isinstance(headers, list): raise TypeError("Headers must be a list of name/value tuples") self._headers = headers Modified: python/branches/py3k-struni/Lib/wsgiref/validate.py ============================================================================== --- python/branches/py3k-struni/Lib/wsgiref/validate.py (original) +++ python/branches/py3k-struni/Lib/wsgiref/validate.py Fri Jun 8 01:15:56 2007 @@ -113,7 +113,6 @@ import re import sys -from types import DictType, StringType, TupleType, ListType import warnings header_re = re.compile(r'^[a-zA-Z][a-zA-Z0-9\-_]*$') @@ -191,20 +190,20 @@ def read(self, *args): assert_(len(args) <= 1) v = self.input.read(*args) - assert_(type(v) is type("")) + assert_(isinstance(v, str)) return v def readline(self): v = self.input.readline() - assert_(type(v) is type("")) + assert_(isinstance(v, str)) return v def readlines(self, *args): assert_(len(args) <= 1) lines = self.input.readlines(*args) - assert_(type(lines) is type([])) + assert_(isinstance(lines, list)) for line in lines: - assert_(type(line) is type("")) + assert_(isinstance(line, str)) return lines def __iter__(self): @@ -223,7 +222,7 @@ self.errors = wsgi_errors def write(self, s): - assert_(type(s) is type("")) + assert_(isinstance(s, str)) self.errors.write(s) def flush(self): @@ -242,7 +241,7 @@ self.writer = wsgi_writer def __call__(self, s): - assert_(type(s) is type("")) + assert_(isinstance(s, str)) self.writer(s) class PartialIteratorWrapper: @@ -288,7 +287,7 @@ "Iterator garbage collected without being closed") def check_environ(environ): - assert_(type(environ) is DictType, + assert_(isinstance(environ, dict), "Environment is not of the right type: %r (environment: %r)" % (type(environ), environ)) @@ -315,11 +314,11 @@ if '.' in key: # Extension, we don't care about its type continue - assert_(type(environ[key]) is StringType, + assert_(isinstance(environ[key], str), "Environmental variable %s is not a string: %r (value: %r)" % (key, type(environ[key]), environ[key])) - assert_(type(environ['wsgi.version']) is TupleType, + assert_(isinstance(environ['wsgi.version'], tuple), "wsgi.version should be a tuple (%r)" % (environ['wsgi.version'],)) assert_(environ['wsgi.url_scheme'] in ('http', 'https'), "wsgi.url_scheme unknown: %r" % environ['wsgi.url_scheme']) @@ -365,7 +364,7 @@ % (wsgi_errors, attr)) def check_status(status): - assert_(type(status) is StringType, + assert_(isinstance(status, str), "Status must be a string (not %r)" % status) # Implicitly check that we can turn it into an integer: status_code = status.split(None, 1)[0] @@ -380,12 +379,12 @@ % status, WSGIWarning) def check_headers(headers): - assert_(type(headers) is ListType, + assert_(isinstance(headers, list), "Headers (%r) must be of type list: %r" % (headers, type(headers))) header_names = {} for item in headers: - assert_(type(item) is TupleType, + assert_(isinstance(item, tuple), "Individual headers (%r) must be of type tuple: %r" % (item, type(item))) assert_(len(item) == 2) @@ -419,7 +418,7 @@ assert_(0, "No Content-Type header found in headers (%s)" % headers) def check_exc_info(exc_info): - assert_(exc_info is None or type(exc_info) is type(()), + assert_(exc_info is None or isinstance(exc_info, tuple), "exc_info (%r) is not a tuple: %r" % (exc_info, type(exc_info))) # More exc_info checks? Modified: python/branches/py3k-struni/Lib/xml/sax/saxutils.py ============================================================================== --- python/branches/py3k-struni/Lib/xml/sax/saxutils.py (original) +++ python/branches/py3k-struni/Lib/xml/sax/saxutils.py Fri Jun 8 01:15:56 2007 @@ -3,18 +3,10 @@ convenience of application and driver writers. """ -import os, urlparse, urllib, types +import os, urlparse, urllib from . import handler from . import xmlreader -try: - _StringTypes = [types.StringType, types.UnicodeType] -except AttributeError: - try: - _StringTypes = [types.StringType] - except AttributeError: - _StringTypes = [str] - # See whether the xmlcharrefreplace error handler is # supported try: @@ -280,7 +272,7 @@ """This function takes an InputSource and an optional base URL and returns a fully resolved InputSource object ready for reading.""" - if type(source) in _StringTypes: + if isinstance(source, basestring): source = xmlreader.InputSource(source) elif hasattr(source, "read"): f = source Modified: python/branches/py3k-struni/Lib/xmlrpclib.py ============================================================================== --- python/branches/py3k-struni/Lib/xmlrpclib.py (original) +++ python/branches/py3k-struni/Lib/xmlrpclib.py Fri Jun 8 01:15:56 2007 @@ -138,8 +138,6 @@ import re, time, operator -from types import * - # -------------------------------------------------------------------- # Internal stuff @@ -306,7 +304,7 @@ today = datetime.datetime.now().strftime("%Y%m%d") self.value = value.strftime(today+"T%H:%M:%S") return - if not isinstance(value, (TupleType, time.struct_time)): + if not isinstance(value, (tuple, time.struct_time)): if value == 0: value = time.time() value = time.localtime(value) @@ -580,7 +578,7 @@ if not self.allow_none: raise TypeError, "cannot marshal None unless allow_none is enabled" write("") - dispatch[NoneType] = dump_nil + dispatch[type(None)] = dump_nil def dump_int(self, value, write): # in case ints are > 32 bits @@ -589,7 +587,7 @@ write("") write(str(value)) write("\n") - dispatch[IntType] = dump_int + #dispatch[int] = dump_int if _bool_is_builtin: def dump_bool(self, value, write): @@ -604,13 +602,13 @@ write("") write(str(int(value))) write("\n") - dispatch[LongType] = dump_long + dispatch[int] = dump_long def dump_double(self, value, write): write("") write(repr(value)) write("\n") - dispatch[FloatType] = dump_double + dispatch[float] = dump_double def dump_string(self, value, write, escape=escape): write("") @@ -636,8 +634,8 @@ dump(v, write) write("\n") del self.memo[i] - dispatch[TupleType] = dump_array - dispatch[ListType] = dump_array + dispatch[tuple] = dump_array + dispatch[list] = dump_array def dump_struct(self, value, write, escape=escape): i = id(value) @@ -657,7 +655,7 @@ write("\n") write("\n") del self.memo[i] - dispatch[DictType] = dump_struct + dispatch[dict] = dump_struct if datetime: def dump_datetime(self, value, write): @@ -1005,12 +1003,10 @@ where necessary. """ - assert isinstance(params, TupleType) or isinstance(params, Fault),\ - "argument must be tuple or Fault instance" - + assert isinstance(params, (tuple, Fault)), "argument must be tuple or Fault instance" if isinstance(params, Fault): methodresponse = 1 - elif methodresponse and isinstance(params, TupleType): + elif methodresponse and isinstance(params, tuple): assert len(params) == 1, "response tuple must be a singleton" if not encoding: @@ -1166,7 +1162,7 @@ def get_host_info(self, host): x509 = {} - if isinstance(host, TupleType): + if isinstance(host, tuple): host, x509 = host import urllib @@ -1216,7 +1212,7 @@ host, extra_headers, x509 = self.get_host_info(host) connection.putheader("Host", host) if extra_headers: - if isinstance(extra_headers, DictType): + if isinstance(extra_headers, dict): extra_headers = extra_headers.items() for key, value in extra_headers: connection.putheader(key, value) Modified: python/branches/py3k-struni/Tools/versioncheck/pyversioncheck.py ============================================================================== --- python/branches/py3k-struni/Tools/versioncheck/pyversioncheck.py (original) +++ python/branches/py3k-struni/Tools/versioncheck/pyversioncheck.py Fri Jun 8 01:15:56 2007 @@ -1,5 +1,4 @@ """pyversioncheck - Module to help with checking versions""" -import types import rfc822 import urllib import sys @@ -35,7 +34,7 @@ def checkonly(package, url, version, verbose=0): if verbose >= VERBOSE_EACHFILE: print '%s:'%package - if type(url) == types.StringType: + if isinstance(url, str): ok, newversion, fp = _check1version(package, url, version, verbose) else: for u in url: From python-3000-checkins at python.org Fri Jun 8 01:45:43 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Fri, 8 Jun 2007 01:45:43 +0200 (CEST) Subject: [Python-3000-checkins] r55820 - in python/branches/py3k-struni/Lib: io.py test/test_io.py Message-ID: <20070607234543.F24071E4003@bag.python.org> Author: guido.van.rossum Date: Fri Jun 8 01:45:37 2007 New Revision: 55820 Modified: python/branches/py3k-struni/Lib/io.py python/branches/py3k-struni/Lib/test/test_io.py Log: Accellerate binary readline() a bit. Modified: python/branches/py3k-struni/Lib/io.py ============================================================================== --- python/branches/py3k-struni/Lib/io.py (original) +++ python/branches/py3k-struni/Lib/io.py Fri Jun 8 01:45:37 2007 @@ -298,17 +298,23 @@ ### Readline ### - def readline(self, sizehint: int = -1) -> bytes: - """For backwards compatibility, a (slow) readline().""" - if sizehint is None: - sizehint = -1 - res = b"" - while sizehint < 0 or len(res) < sizehint: - b = self.read(1) + def readline(self, limit: int = -1) -> bytes: + """For backwards compatibility, a (slowish) readline().""" + if limit is None: + limit = -1 + res = bytes() + while limit < 0 or len(res) < limit: + readahead = self.peek(1, unsafe=True) + if not readahead: + break + n = (readahead.find(b"\n") + 1) or len(readahead) + if limit >= 0: + n = min(n, limit) + b = self.read(n) if not b: break res += b - if b == b"\n": + if res.endswith(b"\n"): break return res Modified: python/branches/py3k-struni/Lib/test/test_io.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_io.py (original) +++ python/branches/py3k-struni/Lib/test/test_io.py Fri Jun 8 01:45:37 2007 @@ -168,6 +168,18 @@ self.read_ops(f, True) f.close() + def test_readline(self): + f = io.open(test_support.TESTFN, "wb") + f.write(b"abc\ndef\nxyzzy\nfoo") + f.close() + f = io.open(test_support.TESTFN, "rb") + self.assertEqual(f.readline(), b"abc\n") + self.assertEqual(f.readline(10), b"def\n") + self.assertEqual(f.readline(2), b"xy") + self.assertEqual(f.readline(4), b"zzy\n") + self.assertEqual(f.readline(), b"foo") + f.close() + def test_raw_bytes_io(self): f = io.BytesIO() self.write_ops(f) From python-3000-checkins at python.org Fri Jun 8 01:58:56 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Fri, 8 Jun 2007 01:58:56 +0200 (CEST) Subject: [Python-3000-checkins] r55823 - python/branches/py3k-struni/Lib/mailbox.py Message-ID: <20070607235856.4A6B21E4003@bag.python.org> Author: guido.van.rossum Date: Fri Jun 8 01:58:54 2007 New Revision: 55823 Modified: python/branches/py3k-struni/Lib/mailbox.py Log: Just enoug fixes so that test_mailbox fails instead of loops forever. Modified: python/branches/py3k-struni/Lib/mailbox.py ============================================================================== --- python/branches/py3k-struni/Lib/mailbox.py (original) +++ python/branches/py3k-struni/Lib/mailbox.py Fri Jun 8 01:58:54 2007 @@ -207,7 +207,7 @@ elif hasattr(message, 'read'): while True: line = message.readline() - if line == '': + if not line: break if mangle_from_ and line.startswith('From '): line = '>From ' + line[5:] @@ -591,7 +591,7 @@ while True: buffer = self._file.read(min(4096, stop - self._file.tell())) - if buffer == '': + if not buffer: break new_file.write(buffer) new_toc[key] = (new_start, new_file.tell()) @@ -741,7 +741,7 @@ if len(stops) < len(starts): stops.append(line_pos - len(os.linesep)) starts.append(line_pos) - elif line == '': + elif not line: stops.append(line_pos) break self._toc = dict(enumerate(zip(starts, stops))) @@ -783,10 +783,10 @@ if line == '\001\001\001\001' + os.linesep: stops.append(line_pos - len(os.linesep)) break - elif line == '': + elif not line: stops.append(line_pos) break - elif line == '': + elif not line: break self._toc = dict(enumerate(zip(starts, stops))) self._next_key = len(self._toc) @@ -1140,13 +1140,13 @@ original_headers = StringIO.StringIO() while True: line = self._file.readline() - if line == '*** EOOH ***' + os.linesep or line == '': + if line == '*** EOOH ***' + os.linesep or not line: break original_headers.write(line.replace(os.linesep, '\n')) visible_headers = StringIO.StringIO() while True: line = self._file.readline() - if line == os.linesep or line == '': + if line == os.linesep or not line: break visible_headers.write(line.replace(os.linesep, '\n')) body = self._file.read(stop - self._file.tell()).replace(os.linesep, @@ -1165,12 +1165,12 @@ original_headers = StringIO.StringIO() while True: line = self._file.readline() - if line == '*** EOOH ***' + os.linesep or line == '': + if line == '*** EOOH ***' + os.linesep or not line: break original_headers.write(line.replace(os.linesep, '\n')) while True: line = self._file.readline() - if line == os.linesep or line == '': + if line == os.linesep or not line: break return original_headers.getvalue() + \ self._file.read(stop - self._file.tell()).replace(os.linesep, @@ -1206,12 +1206,12 @@ starts.append(next_pos) labels = [label.strip() for label in self._file.readline()[1:].split(',') - if label.strip() != ''] + if label.strip()] label_lists.append(labels) elif line == '\037' or line == '\037' + os.linesep: if len(stops) < len(starts): stops.append(line_pos - len(os.linesep)) - elif line == '': + elif not line: stops.append(line_pos - len(os.linesep)) break self._toc = dict(enumerate(zip(starts, stops))) @@ -1262,7 +1262,7 @@ while True: line = orig_buffer.readline() self._file.write(line.replace('\n', os.linesep)) - if line == '\n' or line == '': + if line == '\n' or not line: break self._file.write('*** EOOH ***' + os.linesep) if isinstance(message, BabylMessage): @@ -1272,18 +1272,18 @@ while True: line = vis_buffer.readline() self._file.write(line.replace('\n', os.linesep)) - if line == '\n' or line == '': + if line == '\n' or not line: break else: orig_buffer.seek(0) while True: line = orig_buffer.readline() self._file.write(line.replace('\n', os.linesep)) - if line == '\n' or line == '': + if line == '\n' or not line: break while True: buffer = orig_buffer.read(4096) # Buffer size is arbitrary. - if buffer == '': + if not buffer: break self._file.write(buffer.replace('\n', os.linesep)) elif isinstance(message, str): @@ -1305,7 +1305,7 @@ while True: line = message.readline() self._file.write(line.replace('\n', os.linesep)) - if line == '\n' or line == '': + if line == '\n' or not line: self._file.write('*** EOOH ***' + os.linesep) if first_pass: first_pass = False @@ -1314,7 +1314,7 @@ break while True: buffer = message.read(4096) # Buffer size is arbitrary. - if buffer == '': + if not buffer: break self._file.write(buffer.replace('\n', os.linesep)) else: @@ -1393,7 +1393,7 @@ def remove_flag(self, flag): """Unset the given string flag(s) without changing others.""" - if self.get_flags() != '': + if self.get_flags(): self.set_flags(''.join(set(self.get_flags()) - set(flag))) def get_date(self): @@ -1776,7 +1776,11 @@ def __iter__(self): """Iterate over lines.""" - return iter(self.readline, "") + while True: + line = self.readline() + if not line: + raise StopIteration + yield line def tell(self): """Return the position.""" From python-3000-checkins at python.org Fri Jun 8 02:08:01 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Fri, 8 Jun 2007 02:08:01 +0200 (CEST) Subject: [Python-3000-checkins] r55824 - in python/branches/py3k-struni: Lib/io.py runtests.sh Message-ID: <20070608000801.0C67D1E4003@bag.python.org> Author: guido.van.rossum Date: Fri Jun 8 02:07:57 2007 New Revision: 55824 Modified: python/branches/py3k-struni/Lib/io.py python/branches/py3k-struni/runtests.sh Log: Make test_socket work. Don't exclude test_socket from the tests to run. Modified: python/branches/py3k-struni/Lib/io.py ============================================================================== --- python/branches/py3k-struni/Lib/io.py (original) +++ python/branches/py3k-struni/Lib/io.py Fri Jun 8 02:07:57 2007 @@ -300,17 +300,23 @@ def readline(self, limit: int = -1) -> bytes: """For backwards compatibility, a (slowish) readline().""" + if hasattr(self, "peek"): + def nreadahead(): + readahead = self.peek(1, unsafe=True) + if not readahead: + return 1 + n = (readahead.find(b"\n") + 1) or len(readahead) + if limit >= 0: + n = min(n, limit) + return n + else: + def nreadahead(): + return 1 if limit is None: limit = -1 res = bytes() while limit < 0 or len(res) < limit: - readahead = self.peek(1, unsafe=True) - if not readahead: - break - n = (readahead.find(b"\n") + 1) or len(readahead) - if limit >= 0: - n = min(n, limit) - b = self.read(n) + b = self.read(nreadahead()) if not b: break res += b Modified: python/branches/py3k-struni/runtests.sh ============================================================================== --- python/branches/py3k-struni/runtests.sh (original) +++ python/branches/py3k-struni/runtests.sh Fri Jun 8 02:07:57 2007 @@ -27,7 +27,7 @@ # Compute the list of tests to run. case $# in 0) - TESTS=`(cd Lib/test; ls test_*.py | sed 's/\.py//' | grep -v test_socket)` + TESTS=`(cd Lib/test; ls test_*.py | sed 's/\.py//')` ;; *) TESTS="$@" From python-3000-checkins at python.org Fri Jun 8 12:38:38 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Fri, 8 Jun 2007 12:38:38 +0200 (CEST) Subject: [Python-3000-checkins] r55825 - python/branches/py3k-struni/Lib/test/test_exceptions.py Message-ID: <20070608103838.DAFBE1E4006@bag.python.org> Author: walter.doerwald Date: Fri Jun 8 12:38:38 2007 New Revision: 55825 Modified: python/branches/py3k-struni/Lib/test/test_exceptions.py Log: Fix chr() test (1000000 was accepted on a UCS4 build). Modified: python/branches/py3k-struni/Lib/test/test_exceptions.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_exceptions.py (original) +++ python/branches/py3k-struni/Lib/test/test_exceptions.py Fri Jun 8 12:38:38 2007 @@ -99,7 +99,7 @@ except TypeError: pass self.raise_catch(ValueError, "ValueError") - self.assertRaises(ValueError, chr, 1000000) + self.assertRaises(ValueError, chr, sys.maxunicode+1) self.raise_catch(ZeroDivisionError, "ZeroDivisionError") try: x = 1/0 From python-3000-checkins at python.org Fri Jun 8 16:31:04 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Fri, 8 Jun 2007 16:31:04 +0200 (CEST) Subject: [Python-3000-checkins] r55826 - python/branches/py3k-struni/Lib/test/pickletester.py python/branches/py3k-struni/Lib/test/string_tests.py python/branches/py3k-struni/Lib/test/test_binascii.py python/branches/py3k-struni/Lib/test/test_support.py python/branches/py3k-struni/Lib/test/test_textwrap.py python/branches/py3k-struni/Lib/test/test_types.py python/branches/py3k-struni/Lib/test/test_xmlrpc.py Message-ID: <20070608143104.551FB1E4011@bag.python.org> Author: walter.doerwald Date: Fri Jun 8 16:30:53 2007 New Revision: 55826 Modified: python/branches/py3k-struni/Lib/test/pickletester.py python/branches/py3k-struni/Lib/test/string_tests.py python/branches/py3k-struni/Lib/test/test_binascii.py python/branches/py3k-struni/Lib/test/test_support.py python/branches/py3k-struni/Lib/test/test_textwrap.py python/branches/py3k-struni/Lib/test/test_types.py python/branches/py3k-struni/Lib/test/test_xmlrpc.py Log: Rename checks for test_support.have_unicode (we always have unicode support now) and either drop the tests or merge them into the existing tests. Modified: python/branches/py3k-struni/Lib/test/pickletester.py ============================================================================== --- python/branches/py3k-struni/Lib/test/pickletester.py (original) +++ python/branches/py3k-struni/Lib/test/pickletester.py Fri Jun 8 16:30:53 2007 @@ -7,8 +7,7 @@ import pickletools import copy_reg -from test.test_support import TestFailed, have_unicode, TESTFN, \ - run_with_locale +from test.test_support import TestFailed, TESTFN, run_with_locale # Tests that try a number of pickle protocols should have a # for proto in protocols: @@ -482,15 +481,13 @@ buf = b"S" + bytes(s) + b"\012p0\012." self.assertRaises(ValueError, self.loads, buf) - if have_unicode: - def test_unicode(self): - endcases = [str(''), str('<\\u>'), str('<\\\u1234>'), - str('<\n>'), str('<\\>')] - for proto in protocols: - for u in endcases: - p = self.dumps(u, proto) - u2 = self.loads(p) - self.assertEqual(u2, u) + def test_unicode(self): + endcases = ['', '<\\u>', '<\\\u1234>', '<\n>', '<\\>'] + for proto in protocols: + for u in endcases: + p = self.dumps(u, proto) + u2 = self.loads(p) + self.assertEqual(u2, u) def test_ints(self): import sys Modified: python/branches/py3k-struni/Lib/test/string_tests.py ============================================================================== --- python/branches/py3k-struni/Lib/test/string_tests.py (original) +++ python/branches/py3k-struni/Lib/test/string_tests.py Fri Jun 8 16:30:53 2007 @@ -1100,27 +1100,26 @@ # Additional tests that only work with # 8bit compatible object, i.e. str and UserString - if test_support.have_unicode: - def test_encoding_decoding(self): - codecs = [('rot13', b'uryyb jbeyq'), - ('base64', b'aGVsbG8gd29ybGQ=\n'), - ('hex', b'68656c6c6f20776f726c64'), - ('uu', b'begin 666 \n+:&5L;&\\@=V]R;&0 \n \nend\n')] - for encoding, data in codecs: - self.checkequal(data, 'hello world', 'encode', encoding) - self.checkequal('hello world', data, 'decode', encoding) - # zlib is optional, so we make the test optional too... - try: - import zlib - except ImportError: - pass - else: - data = b'x\x9c\xcbH\xcd\xc9\xc9W(\xcf/\xcaI\x01\x00\x1a\x0b\x04]' - self.checkequal(data, 'hello world', 'encode', 'zlib') - self.checkequal('hello world', data, 'decode', 'zlib') + def test_encoding_decoding(self): + codecs = [('rot13', b'uryyb jbeyq'), + ('base64', b'aGVsbG8gd29ybGQ=\n'), + ('hex', b'68656c6c6f20776f726c64'), + ('uu', b'begin 666 \n+:&5L;&\\@=V]R;&0 \n \nend\n')] + for encoding, data in codecs: + self.checkequal(data, 'hello world', 'encode', encoding) + self.checkequal('hello world', data, 'decode', encoding) + # zlib is optional, so we make the test optional too... + try: + import zlib + except ImportError: + pass + else: + data = b'x\x9c\xcbH\xcd\xc9\xc9W(\xcf/\xcaI\x01\x00\x1a\x0b\x04]' + self.checkequal(data, 'hello world', 'encode', 'zlib') + self.checkequal('hello world', data, 'decode', 'zlib') - self.checkraises(TypeError, 'xyz', 'decode', 42) - self.checkraises(TypeError, 'xyz', 'encode', 42) + self.checkraises(TypeError, 'xyz', 'decode', 42) + self.checkraises(TypeError, 'xyz', 'encode', 42) class MixinStrUnicodeTest: Modified: python/branches/py3k-struni/Lib/test/test_binascii.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_binascii.py (original) +++ python/branches/py3k-struni/Lib/test/test_binascii.py Fri Jun 8 16:30:53 2007 @@ -121,9 +121,7 @@ self.assertRaises(binascii.Error, binascii.a2b_hex, t[:-1]) self.assertRaises(binascii.Error, binascii.a2b_hex, t[:-1] + b'q') - # Verify the treatment of Unicode strings - if test_support.have_unicode: - self.assertEqual(binascii.hexlify('a'), b'61') + self.assertEqual(binascii.hexlify('a'), b'61') def test_qp(self): # A test for SF bug 534347 (segfaults without the proper fix) Modified: python/branches/py3k-struni/Lib/test/test_support.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_support.py (original) +++ python/branches/py3k-struni/Lib/test/test_support.py Fri Jun 8 16:30:53 2007 @@ -146,42 +146,35 @@ TESTFN = 'testfile' else: TESTFN = '@test' - # Unicode name only used if TEST_FN_ENCODING exists for the platform. - if have_unicode: - # Assuming sys.getfilesystemencoding()!=sys.getdefaultencoding() - # TESTFN_UNICODE is a filename that can be encoded using the - # file system encoding, but *not* with the default (ascii) encoding - if isinstance('', str): - # python -U - # XXX perhaps unicode() should accept Unicode strings? - TESTFN_UNICODE = "@test-\xe0\xf2" - else: - # 2 latin characters. - TESTFN_UNICODE = str("@test-\xe0\xf2", "latin-1") - TESTFN_ENCODING = sys.getfilesystemencoding() - # TESTFN_UNICODE_UNENCODEABLE is a filename that should *not* be - # able to be encoded by *either* the default or filesystem encoding. - # This test really only makes sense on Windows NT platforms - # which have special Unicode support in posixmodule. - if (not hasattr(sys, "getwindowsversion") or - sys.getwindowsversion()[3] < 2): # 0=win32s or 1=9x/ME - TESTFN_UNICODE_UNENCODEABLE = None + + # Assuming sys.getfilesystemencoding()!=sys.getdefaultencoding() + # TESTFN_UNICODE is a filename that can be encoded using the + # file system encoding, but *not* with the default (ascii) encoding + TESTFN_UNICODE = "@test-\xe0\xf2" + TESTFN_ENCODING = sys.getfilesystemencoding() + # TESTFN_UNICODE_UNENCODEABLE is a filename that should *not* be + # able to be encoded by *either* the default or filesystem encoding. + # This test really only makes sense on Windows NT platforms + # which have special Unicode support in posixmodule. + if (not hasattr(sys, "getwindowsversion") or + sys.getwindowsversion()[3] < 2): # 0=win32s or 1=9x/ME + TESTFN_UNICODE_UNENCODEABLE = None + else: + # Japanese characters (I think - from bug 846133) + TESTFN_UNICODE_UNENCODEABLE = "@test-\u5171\u6709\u3055\u308c\u308b" + try: + # XXX - Note - should be using TESTFN_ENCODING here - but for + # Windows, "mbcs" currently always operates as if in + # errors=ignore' mode - hence we get '?' characters rather than + # the exception. 'Latin1' operates as we expect - ie, fails. + # See [ 850997 ] mbcs encoding ignores errors + TESTFN_UNICODE_UNENCODEABLE.encode("Latin1") + except UnicodeEncodeError: + pass else: - # Japanese characters (I think - from bug 846133) - TESTFN_UNICODE_UNENCODEABLE = eval('u"@test-\u5171\u6709\u3055\u308c\u308b"') - try: - # XXX - Note - should be using TESTFN_ENCODING here - but for - # Windows, "mbcs" currently always operates as if in - # errors=ignore' mode - hence we get '?' characters rather than - # the exception. 'Latin1' operates as we expect - ie, fails. - # See [ 850997 ] mbcs encoding ignores errors - TESTFN_UNICODE_UNENCODEABLE.encode("Latin1") - except UnicodeEncodeError: - pass - else: - print('WARNING: The filename %r CAN be encoded by the filesystem. ' \ - 'Unicode filename tests may not be effective' \ - % TESTFN_UNICODE_UNENCODEABLE) + print('WARNING: The filename %r CAN be encoded by the filesystem. ' \ + 'Unicode filename tests may not be effective' \ + % TESTFN_UNICODE_UNENCODEABLE) # Make sure we can write to TESTFN, try in /tmp if we can't fp = None Modified: python/branches/py3k-struni/Lib/test/test_textwrap.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_textwrap.py (original) +++ python/branches/py3k-struni/Lib/test/test_textwrap.py Fri Jun 8 16:30:53 2007 @@ -336,19 +336,6 @@ "with ", "much white", "space."], drop_whitespace=False) - if test_support.have_unicode: - def test_unicode(self): - # *Very* simple test of wrapping Unicode strings. I'm sure - # there's more to it than this, but let's at least make - # sure textwrap doesn't crash on Unicode input! - text = "Hello there, how are you today?" - self.check_wrap(text, 50, ["Hello there, how are you today?"]) - self.check_wrap(text, 20, ["Hello there, how are", "you today?"]) - olines = self.wrapper.wrap(text) - assert isinstance(olines, list) and isinstance(olines[0], str) - otext = self.wrapper.fill(text) - assert isinstance(otext, str) - def test_split(self): # Ensure that the standard _split() method works as advertised # in the comments Modified: python/branches/py3k-struni/Lib/test/test_types.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_types.py (original) +++ python/branches/py3k-struni/Lib/test/test_types.py Fri Jun 8 16:30:53 2007 @@ -1,6 +1,6 @@ # Python test set -- part 6, built-in types -from test.test_support import run_unittest, have_unicode +from test.test_support import run_unittest import unittest import sys @@ -199,19 +199,6 @@ self.assertEqual(a[100:-100:-1], a[::-1]) self.assertEqual(a[-100:100:2], '02468') - if have_unicode: - a = str(b'0123456789', 'ascii') - self.assertEqual(a[::], a) - self.assertEqual(a[::2], str(b'02468', 'ascii')) - self.assertEqual(a[1::2], str(b'13579', 'ascii')) - self.assertEqual(a[::-1], str(b'9876543210', 'ascii')) - self.assertEqual(a[::-2], str(b'97531', 'ascii')) - self.assertEqual(a[3::-2], str(b'31', 'ascii')) - self.assertEqual(a[-100:100:], a) - self.assertEqual(a[100:-100:-1], a[::-1]) - self.assertEqual(a[-100:100:2], str(b'02468', 'ascii')) - - def test_type_function(self): self.assertRaises(TypeError, type, 1, 2) self.assertRaises(TypeError, type, 1, 2, 3, 4) Modified: python/branches/py3k-struni/Lib/test/test_xmlrpc.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_xmlrpc.py (original) +++ python/branches/py3k-struni/Lib/test/test_xmlrpc.py Fri Jun 8 16:30:53 2007 @@ -4,13 +4,6 @@ import xmlrpclib from test import test_support -try: - str -except NameError: - have_unicode = False -else: - have_unicode = True - alist = [{'astring': 'foo at bar.baz.spam', 'afloat': 7283.43, 'anint': 2**20, @@ -147,15 +140,11 @@ del sys.setdefaultencoding items = list(d.items()) - if have_unicode: - self.assertEquals(s, "abc \x95") - self.assert_(isinstance(s, str)) - self.assertEquals(items, [("def \x96", "ghi \x97")]) - self.assert_(isinstance(items[0][0], str)) - self.assert_(isinstance(items[0][1], str)) - else: - self.assertEquals(s, "abc \xc2\x95") - self.assertEquals(items, [("def \xc2\x96", "ghi \xc2\x97")]) + self.assertEquals(s, "abc \x95") + self.assert_(isinstance(s, str)) + self.assertEquals(items, [("def \x96", "ghi \x97")]) + self.assert_(isinstance(items[0][0], str)) + self.assert_(isinstance(items[0][1], str)) def test_main(): test_support.run_unittest(XMLRPCTestCase) From python-3000-checkins at python.org Fri Jun 8 17:33:50 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Fri, 8 Jun 2007 17:33:50 +0200 (CEST) Subject: [Python-3000-checkins] r55827 - python/branches/py3k-struni/Lib/Cookie.py Message-ID: <20070608153350.B4DB61E4006@bag.python.org> Author: walter.doerwald Date: Fri Jun 8 17:33:46 2007 New Revision: 55827 Modified: python/branches/py3k-struni/Lib/Cookie.py Log: Fix Cookie.py: Fix example in the docstring (encoded SerialCookies contain unicode now). Fix _quote() and Morsel.set() which were using str8.translate(). As cPickle.dumps() returns bytes now value_encode() and value_decode() methods must encode/decode (however output() might better return a bytes object). Modified: python/branches/py3k-struni/Lib/Cookie.py ============================================================================== --- python/branches/py3k-struni/Lib/Cookie.py (original) +++ python/branches/py3k-struni/Lib/Cookie.py Fri Jun 8 17:33:46 2007 @@ -163,7 +163,7 @@ >>> C["string"].value 'seven' >>> C.output().replace('p0', 'p1') # Hack for cPickle/pickle differences - 'Set-Cookie: number="I7\\012."\r\nSet-Cookie: string="S\'seven\'\\012p1\\012."' + 'Set-Cookie: number="I7\\012."\r\nSet-Cookie: string="Vseven\\012p1\\012."' Be warned, however, if SerialCookie cannot de-serialize a value (because it isn't a valid pickle'd object), IT WILL RAISE AN EXCEPTION. @@ -305,16 +305,14 @@ '\375' : '\\375', '\376' : '\\376', '\377' : '\\377' } -_idmap = ''.join(chr(x) for x in range(256)) - -def _quote(str, LegalChars=_LegalChars, idmap=_idmap): +def _quote(str, LegalChars=_LegalChars): # # If the string does not need to be double-quoted, # then just return the string. Otherwise, surround # the string in doublequotes and precede quote (with a \) # special characters. # - if "" == str.translate(idmap, LegalChars): + if len(filter(LegalChars.__contains__, str)) == len(str): return str else: return '"' + _nulljoin( map(_Translator.get, str, str) ) + '"' @@ -439,12 +437,12 @@ return K.lower() in self._reserved # end isReservedKey - def set(self, key, val, coded_val, LegalChars=_LegalChars, idmap=_idmap): + def set(self, key, val, coded_val, LegalChars=_LegalChars): # First we verify that the key isn't a reserved word # Second we make sure it only contains legal characters if key.lower() in self._reserved: raise CookieError("Attempt to set a reserved key: %s" % key) - if "" != key.translate(idmap, LegalChars): + if len(filter(LegalChars.__contains__, key)) != len(key): raise CookieError("Illegal key value: %s" % key) # It's a good key, so save it. @@ -680,9 +678,9 @@ # end __init__ def value_decode(self, val): # This could raise an exception! - return loads( _unquote(val) ), val + return loads( _unquote(val).encode('latin-1') ), val def value_encode(self, val): - return val, _quote( dumps(val) ) + return val, _quote( dumps(val).decode('latin-1') ) # end SerialCookie class SmartCookie(BaseCookie): @@ -706,14 +704,14 @@ def value_decode(self, val): strval = _unquote(val) try: - return loads(strval), val + return loads(strval.encode('latin-1')), val except: return strval, val def value_encode(self, val): - if type(val) == type(""): + if isinstance(val, str): return val, _quote(val) else: - return val, _quote( dumps(val) ) + return val, _quote( dumps(val).decode('latin-1') ) # end SmartCookie From python-3000-checkins at python.org Sat Jun 9 01:04:48 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Sat, 9 Jun 2007 01:04:48 +0200 (CEST) Subject: [Python-3000-checkins] r55837 - in python/branches/p3yk/Lib: abc.py test/test_abc.py Message-ID: <20070608230448.8DD7B1E4004@bag.python.org> Author: guido.van.rossum Date: Sat Jun 9 01:04:42 2007 New Revision: 55837 Added: python/branches/p3yk/Lib/abc.py (contents, props changed) python/branches/p3yk/Lib/test/test_abc.py (contents, props changed) Log: PEP 3119 -- the abc module. Added: python/branches/p3yk/Lib/abc.py ============================================================================== --- (empty file) +++ python/branches/p3yk/Lib/abc.py Sat Jun 9 01:04:42 2007 @@ -0,0 +1,163 @@ +# Copyright 2007 Google, Inc. All Rights Reserved. +# Licensed to PSF under a Contributor Agreement. + +"""Abstract Base Classes (ABCs) according to PEP 3119.""" + +import sys +import inspect +import itertools + + +### ABC SUPPORT FRAMEWORK ### + + +def abstractmethod(funcobj): + """A decorator indicating abstract methods. + + Requires that the metaclass is ABCMeta or derived from it. A + class that has a metaclass derived from ABCMeta cannot be + instantiated unless all of its abstract methods are overridden. + The abstract methods can be called using any of the the normal + 'super' call mechanisms. + + Usage: + + class C(metaclass=ABCMeta): + @abstractmethod + def my_abstract_method(self, ...): + ... + """ + funcobj.__isabstractmethod__ = True + return funcobj + + +class _Abstract(object): + + """Helper class inserted into the bases by ABCMeta (using _fix_bases()). + + You should never need to explicitly subclass this class. + """ + + def __new__(cls, *args, **kwds): + am = cls.__dict__.get("__abstractmethods__") + if am: + raise TypeError("can't instantiate abstract class %s " + "with abstract methods %s" % + (cls.__name__, ", ".join(sorted(am)))) + return super(_Abstract, cls).__new__(cls, *args, **kwds) + + +def _fix_bases(bases): + """Helper method that inserts _Abstract in the bases if needed.""" + for base in bases: + if issubclass(base, _Abstract): + # _Abstract is already a base (maybe indirectly) + return bases + if object in bases: + # Replace object with _Abstract + return tuple([_Abstract if base is object else base + for base in bases]) + # Append _Abstract to the end + return bases + (_Abstract,) + + +class ABCMeta(type): + + """Metaclass for defining Abstract Base Classes (ABCs). + + Use this metaclass to create an ABC. An ABC can be subclassed + directly, and then acts as a mix-in class. You can also register + unrelated concrete classes (even built-in classes) and unrelated + ABCs as 'virtual subclasses' -- these and their descendants will + be considered subclasses of the registering ABC by the built-in + issubclass() function, but the registering ABC won't show up in + their MRO (Method Resolution Order) nor will method + implementations defined by the registering ABC be callable (not + even via super()). + + """ + + # A global counter that is incremented each time a class is + # registered as a virtual subclass of anything. It forces the + # negative cache to be cleared before its next use. + __invalidation_counter = 0 + + def __new__(mcls, name, bases, namespace): + bases = _fix_bases(bases) + cls = super(ABCMeta, mcls).__new__(mcls, name, bases, namespace) + # Compute set of abstract method names + abstracts = {name + for name, value in namespace.items() + if getattr(value, "__isabstractmethod__", False)} + for base in bases: + for name in getattr(base, "__abstractmethods__", set()): + value = getattr(cls, name, None) + if getattr(value, "__isabstractmethod__", False): + abstracts.add(name) + cls.__abstractmethods__ = abstracts + # Set up inheritance registry + cls.__registry = set() + cls.__cache = set() + cls.__negative_cache = set() + cls.__negative_cache_version = ABCMeta.__invalidation_counter + return cls + + def register(cls, subclass): + """Register a virtual subclass of an ABC.""" + if not isinstance(cls, type): + raise TypeError("Can only register classes") + if issubclass(subclass, cls): + return # Already a subclass + # Subtle: test for cycles *after* testing for "already a subclass"; + # this means we allow X.register(X) and interpret it as a no-op. + if issubclass(cls, subclass): + # This would create a cycle, which is bad for the algorithm below + raise RuntimeError("Refusing to create an inheritance cycle") + cls.__registry.add(subclass) + ABCMeta.__invalidation_counter += 1 # Invalidate negative cache + + def _dump_registry(cls, file=None): + """Debug helper to print the ABC registry.""" + if file is None: + file = sys.stdout + print("Class: %s.%s" % (cls.__module__, cls.__name__), file=file) + print("Inv.counter: %s" % ABCMeta.__invalidation_counter, file=file) + for name in sorted(cls.__dict__.keys()): + if name.startswith("__abc_"): + value = getattr(cls, name) + print("%s: %r" % (name, value), file=file) + + def __instancecheck__(cls, instance): + """Override for isinstance(instance, cls).""" + return any(cls.__subclasscheck__(c) + for c in {instance.__class__, type(instance)}) + + def __subclasscheck__(cls, subclass): + """Override for issubclass(subclass, cls).""" + # Check cache + if subclass in cls.__cache: + return True + # Check negative cache; may have to invalidate + if cls.__negative_cache_version < ABCMeta.__invalidation_counter: + # Invalidate the negative cache + cls.__negative_cache_version = ABCMeta.__invalidation_counter + cls.__negative_cache = set() + elif subclass in cls.__negative_cache: + return False + # Check if it's a direct subclass + if cls in subclass.__mro__: + cls.__cache.add(subclass) + return True + # Check if it's a subclass of a registered class (recursive) + for rcls in cls.__registry: + if issubclass(subclass, rcls): + cls.__registry.add(subclass) + return True + # Check if it's a subclass of a subclass (recursive) + for scls in cls.__subclasses__(): + if issubclass(subclass, scls): + cls.__registry.add(subclass) + return True + # No dice; update negative cache + cls.__negative_cache.add(subclass) + return False Added: python/branches/p3yk/Lib/test/test_abc.py ============================================================================== --- (empty file) +++ python/branches/p3yk/Lib/test/test_abc.py Sat Jun 9 01:04:42 2007 @@ -0,0 +1,123 @@ +# Copyright 2007 Google, Inc. All Rights Reserved. +# Licensed to PSF under a Contributor Agreement. + +"""Unit tests for abc.py.""" + +import sys +import unittest +from test import test_support + +import abc + + +class TestABC(unittest.TestCase): + + def test_abstractmethod_basics(self): + @abc.abstractmethod + def foo(self): pass + self.assertEqual(foo.__isabstractmethod__, True) + def bar(self): pass + self.assertEqual(hasattr(bar, "__isabstractmethod__"), False) + + def test_abstractmethod_integration(self): + class C(metaclass=abc.ABCMeta): + @abc.abstractmethod + def foo(self): pass # abstract + def bar(self): pass # concrete + self.assertEqual(C.__abstractmethods__, {"foo"}) + self.assertRaises(TypeError, C) # because foo is abstract + class D(C): + def bar(self): pass # concrete override of concrete + self.assertEqual(D.__abstractmethods__, {"foo"}) + self.assertRaises(TypeError, D) # because foo is still abstract + class E(D): + def foo(self): pass + self.assertEqual(E.__abstractmethods__, set()) + E() # now foo is concrete, too + class F(E): + @abc.abstractmethod + def bar(self): pass # abstract override of concrete + self.assertEqual(F.__abstractmethods__, {"bar"}) + self.assertRaises(TypeError, F) # because bar is abstract now + + def test_registration_basics(self): + class A(metaclass=abc.ABCMeta): + pass + class B: + pass + b = B() + self.assertEqual(issubclass(B, A), False) + self.assertEqual(isinstance(b, A), False) + A.register(B) + self.assertEqual(issubclass(B, A), True) + self.assertEqual(isinstance(b, A), True) + class C(B): + pass + c = C() + self.assertEqual(issubclass(C, A), True) + self.assertEqual(isinstance(c, A), True) + + def test_registration_builtins(self): + class A(metaclass=abc.ABCMeta): + pass + A.register(int) + self.assertEqual(isinstance(42, A), True) + self.assertEqual(issubclass(int, A), True) + class B(A): + pass + B.register(basestring) + self.assertEqual(isinstance("", A), True) + self.assertEqual(issubclass(str, A), True) + + def test_registration_edge_cases(self): + class A(metaclass=abc.ABCMeta): + pass + A.register(A) # should pass silently + class A1(A): + pass + self.assertRaises(RuntimeError, A1.register, A) # cycles not allowed + class B: + pass + A1.register(B) # ok + A1.register(B) # should pass silently + class C(A): + pass + A.register(C) # should pass silently + self.assertRaises(RuntimeError, C.register, A) # cycles not allowed + C.register(B) # ok + + def test_registration_transitiveness(self): + class A(metaclass=abc.ABCMeta): + pass + self.failUnless(issubclass(A, A)) + class B(metaclass=abc.ABCMeta): + pass + self.failIf(issubclass(A, B)) + self.failIf(issubclass(B, A)) + class C(metaclass=abc.ABCMeta): + pass + A.register(B) + class B1(B): + pass + self.failUnless(issubclass(B1, A)) + class C1(C): + pass + B1.register(C1) + self.failIf(issubclass(C, B)) + self.failIf(issubclass(C, B1)) + self.failUnless(issubclass(C1, A)) + self.failUnless(issubclass(C1, B)) + self.failUnless(issubclass(C1, B1)) + C1.register(int) + class MyInt(int): + pass + self.failUnless(issubclass(MyInt, A)) + self.failUnless(isinstance(42, A)) + + +def test_main(): + test_support.run_unittest(TestABC) + + +if __name__ == "__main__": + unittest.main() From python-3000-checkins at python.org Sat Jun 9 02:38:59 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Sat, 9 Jun 2007 02:38:59 +0200 (CEST) Subject: [Python-3000-checkins] r55838 - in python/branches/p3yk/Lib: collections.py test/test_collections.py Message-ID: <20070609003859.DAF321E4004@bag.python.org> Author: guido.van.rossum Date: Sat Jun 9 02:38:55 2007 New Revision: 55838 Modified: python/branches/p3yk/Lib/collections.py python/branches/p3yk/Lib/test/test_collections.py Log: Implement part of PEP 3119 -- One Trick Ponies. Modified: python/branches/p3yk/Lib/collections.py ============================================================================== --- python/branches/p3yk/Lib/collections.py (original) +++ python/branches/p3yk/Lib/collections.py Sat Jun 9 02:38:55 2007 @@ -1,8 +1,11 @@ -__all__ = ['deque', 'defaultdict', 'NamedTuple'] +__all__ = ['deque', 'defaultdict', 'NamedTuple', + 'Hashable', 'Iterable', 'Iterator', 'Sized', 'Container', + ] from _collections import deque, defaultdict from operator import itemgetter as _itemgetter import sys as _sys +from abc import abstractmethod as _abstractmethod, ABCMeta as _ABCMeta def NamedTuple(typename, s): """Returns a new subclass of tuple with named fields. @@ -46,7 +49,79 @@ return result +class _OneTrickPony(metaclass=_ABCMeta): + @classmethod + def __instancecheck__(cls, x): + return issubclass(x.__class__, cls) + + @classmethod + def register(cls, C): + raise TypeError("class %s doesn't allow registration of subclasses" % + cls.__name__) + + +class Hashable(_OneTrickPony): + + @_abstractmethod + def __hash__(self): + return 0 + + @classmethod + def __subclasscheck__(cls, C): + for B in C.__mro__: + if "__hash__" in B.__dict__: + return B.__dict__["__hash__"] is not None + return False + + +class Iterable(_OneTrickPony): + + @_abstractmethod + def __iter__(self): + while False: + yield None + + @classmethod + def __subclasscheck__(cls, C): + return any("__iter__" in B.__dict__ or "__getitem__" in B.__dict__ + for B in C.__mro__) + + +class Iterator(_OneTrickPony): + + @_abstractmethod + def __next__(self): + raise StopIteration + + def __iter__(self): + return self + + @classmethod + def __subclasscheck__(cls, C): + return any("__next__" in B.__dict__ for B in C.__mro__) + + +class Sized(_OneTrickPony): + + @_abstractmethod + def __len__(self): + return 0 + + @classmethod + def __subclasscheck__(cls, C): + return any("__len__" in B.__dict__ for B in C.__mro__) + + +class Container(_OneTrickPony): + + @_abstractmethod + def __contains__(self, x): + return False + + @classmethod + def __subclasscheck__(cls, C): + return any("__contains__" in B.__dict__ for B in C.__mro__) if __name__ == '__main__': Modified: python/branches/p3yk/Lib/test/test_collections.py ============================================================================== --- python/branches/p3yk/Lib/test/test_collections.py (original) +++ python/branches/p3yk/Lib/test/test_collections.py Sat Jun 9 02:38:55 2007 @@ -1,6 +1,10 @@ +"""Unit tests for collections.py.""" + import unittest from test import test_support from collections import NamedTuple +from collections import Hashable, Iterable, Iterator, Sized, Container + class TestNamedTuple(unittest.TestCase): @@ -51,9 +55,89 @@ self.assertRaises(AttributeError, eval, 'p.z', locals()) +class TestABCs(unittest.TestCase): + + def test_Hashable(self): + # Check some non-hashables + non_samples = [bytes(), list(), set(), dict()] + for x in non_samples: + self.failIf(isinstance(x, Hashable), repr(x)) + self.failIf(issubclass(type(x), Hashable), repr(type(x))) + # Check some hashables + samples = [None, + int(), float(), complex(), + str(), unicode(), + tuple(), frozenset(), + int, list, object, type, + ] + for x in samples: + self.failUnless(isinstance(x, Hashable), repr(x)) + self.failUnless(issubclass(type(x), Hashable), repr(type(x))) + self.assertRaises(TypeError, Hashable) + # Check direct subclassing + class H(Hashable): + def __hash__(self): + return super(H, self).__hash__() + self.assertEqual(hash(H()), 0) + # Check registration is disabled + class C: + def __hash__(self): + return 0 + self.assertRaises(TypeError, Hashable.register, C) + + def test_Iterable(self): + non_samples = [None, 42, 3.14, 1j] + for x in non_samples: + self.failIf(isinstance(x, Iterable), repr(x)) + self.failIf(issubclass(type(x), Iterable), repr(type(x))) + samples = [bytes(), str(), unicode(), + tuple(), list(), set(), frozenset(), dict(), + ] + for x in samples: + self.failUnless(isinstance(x, Iterable), repr(x)) + self.failUnless(issubclass(type(x), Iterable), repr(type(x))) + + def test_Iterator(self): + non_samples = [None, 42, 3.14, 1j, b"", "", u"", (), [], {}, set()] + for x in non_samples: + self.failIf(isinstance(x, Iterator), repr(x)) + self.failIf(issubclass(type(x), Iterator), repr(type(x))) + samples = [iter(bytes()), iter(str()), iter(unicode()), + iter(tuple()), iter(list()), iter(dict()), + iter(set()), iter(frozenset()), + ] + for x in samples: + self.failUnless(isinstance(x, Iterator), repr(x)) + self.failUnless(issubclass(type(x), Iterator), repr(type(x))) + + def test_Sized(self): + non_samples = [None, 42, 3.14, 1j] + for x in non_samples: + self.failIf(isinstance(x, Sized), repr(x)) + self.failIf(issubclass(type(x), Sized), repr(type(x))) + samples = [bytes(), str(), unicode(), + tuple(), list(), set(), frozenset(), dict(), + ] + for x in samples: + self.failUnless(isinstance(x, Sized), repr(x)) + self.failUnless(issubclass(type(x), Sized), repr(type(x))) + + def test_Container(self): + non_samples = [None, 42, 3.14, 1j] + for x in non_samples: + self.failIf(isinstance(x, Container), repr(x)) + self.failIf(issubclass(type(x), Container), repr(type(x))) + samples = [bytes(), str(), unicode(), + tuple(), list(), set(), frozenset(), dict(), + ] + for x in samples: + self.failUnless(isinstance(x, Container), repr(x)) + self.failUnless(issubclass(type(x), Container), repr(type(x))) + + def test_main(verbose=None): import collections as CollectionsModule - test_classes = [TestNamedTuple] + test_classes = [TestNamedTuple, TestABCs] test_support.run_unittest(*test_classes) test_support.run_doctest(CollectionsModule, verbose) From python-3000-checkins at python.org Sat Jun 9 17:28:07 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Sat, 9 Jun 2007 17:28:07 +0200 (CEST) Subject: [Python-3000-checkins] r55847 - in python/branches/p3yk/Lib: abc.py collections.py test/test_collections.py Message-ID: <20070609152807.8134D1E4006@bag.python.org> Author: guido.van.rossum Date: Sat Jun 9 17:28:06 2007 New Revision: 55847 Modified: python/branches/p3yk/Lib/abc.py python/branches/p3yk/Lib/collections.py python/branches/p3yk/Lib/test/test_collections.py Log: Different way to do one trick ponies, allowing registration (per PEP strawman). Modified: python/branches/p3yk/Lib/abc.py ============================================================================== --- python/branches/p3yk/Lib/abc.py (original) +++ python/branches/p3yk/Lib/abc.py Sat Jun 9 17:28:06 2007 @@ -46,6 +46,17 @@ (cls.__name__, ", ".join(sorted(am)))) return super(_Abstract, cls).__new__(cls, *args, **kwds) + @classmethod + def __subclasshook__(cls, subclass): + """Abstract classes can override this to customize issubclass(). + + This is invoked early on by __subclasscheck__() below. It + should return True, False or NotImplemented. If it returns + NotImplemented, the normal algorithm is used. Otherwise, it + overrides the normal algorithm (and the outcome is cached). + """ + return NotImplemented + def _fix_bases(bases): """Helper method that inserts _Abstract in the bases if needed.""" @@ -144,6 +155,15 @@ cls.__negative_cache = set() elif subclass in cls.__negative_cache: return False + # Check the subclass hook + ok = cls.__subclasshook__(subclass) + if ok is not NotImplemented: + assert isinstance(ok, bool) + if ok: + cls.__cache.add(subclass) + else: + cls.__negative_cache.add(subclass) + return ok # Check if it's a direct subclass if cls in subclass.__mro__: cls.__cache.add(subclass) Modified: python/branches/p3yk/Lib/collections.py ============================================================================== --- python/branches/p3yk/Lib/collections.py (original) +++ python/branches/p3yk/Lib/collections.py Sat Jun 9 17:28:06 2007 @@ -51,15 +51,11 @@ class _OneTrickPony(metaclass=_ABCMeta): - @classmethod - def __instancecheck__(cls, x): - return issubclass(x.__class__, cls) - - @classmethod - def register(cls, C): - raise TypeError("class %s doesn't allow registration of subclasses" % - cls.__name__) + """Helper class for Hashable and friends.""" + @_abstractmethod + def __subclasshook__(self, subclass): + return NotImplemented class Hashable(_OneTrickPony): @@ -68,11 +64,13 @@ return 0 @classmethod - def __subclasscheck__(cls, C): + def __subclasshook__(cls, C): for B in C.__mro__: if "__hash__" in B.__dict__: - return B.__dict__["__hash__"] is not None - return False + if B.__dict__["__hash__"]: + return True + break + return NotImplemented class Iterable(_OneTrickPony): @@ -83,9 +81,11 @@ yield None @classmethod - def __subclasscheck__(cls, C): - return any("__iter__" in B.__dict__ or "__getitem__" in B.__dict__ - for B in C.__mro__) + def __subclasshook__(cls, C): + if any("__iter__" in B.__dict__ or "__getitem__" in B.__dict__ + for B in C.__mro__): + return True + return NotImplemented class Iterator(_OneTrickPony): @@ -98,8 +98,10 @@ return self @classmethod - def __subclasscheck__(cls, C): - return any("__next__" in B.__dict__ for B in C.__mro__) + def __subclasshook__(cls, C): + if any("__next__" in B.__dict__ for B in C.__mro__): + return True + return NotImplemented class Sized(_OneTrickPony): @@ -109,8 +111,10 @@ return 0 @classmethod - def __subclasscheck__(cls, C): - return any("__len__" in B.__dict__ for B in C.__mro__) + def __subclasshook__(cls, C): + if any("__len__" in B.__dict__ for B in C.__mro__): + return True + return NotImplemented class Container(_OneTrickPony): @@ -120,7 +124,7 @@ return False @classmethod - def __subclasscheck__(cls, C): + def __subclasshook__(cls, C): return any("__contains__" in B.__dict__ for B in C.__mro__) Modified: python/branches/p3yk/Lib/test/test_collections.py ============================================================================== --- python/branches/p3yk/Lib/test/test_collections.py (original) +++ python/branches/p3yk/Lib/test/test_collections.py Sat Jun 9 17:28:06 2007 @@ -79,11 +79,12 @@ def __hash__(self): return super(H, self).__hash__() self.assertEqual(hash(H()), 0) - # Check registration is disabled + # Check registration class C: - def __hash__(self): - return 0 - self.assertRaises(TypeError, Hashable.register, C) + __hash__ = None + self.failIf(issubclass(C, Hashable)) + Hashable.register(C) + self.failUnless(issubclass(C, Hashable)) def test_Iterable(self): non_samples = [None, 42, 3.14, 1j] From python-3000-checkins at python.org Sat Jun 9 18:13:30 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Sat, 9 Jun 2007 18:13:30 +0200 (CEST) Subject: [Python-3000-checkins] r55848 - python/branches/py3k-struni/Lib/test/test_format.py Message-ID: <20070609161330.4B7491E4004@bag.python.org> Author: walter.doerwald Date: Sat Jun 9 18:13:23 2007 New Revision: 55848 Modified: python/branches/py3k-struni/Lib/test/test_format.py Log: Adapt to new exception message. Simplify formatting (use "%r" % x instead of "%s" % repr(x)). Modified: python/branches/py3k-struni/Lib/test/test_format.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_format.py (original) +++ python/branches/py3k-struni/Lib/test/test_format.py Sat Jun 9 18:13:23 2007 @@ -13,10 +13,10 @@ def testformat(formatstr, args, output=None): if verbose: if output: - print("%s %% %s =? %s ..." %\ - (repr(formatstr), repr(args), repr(output)), end=' ') + print("%r %% %r =? %r ..." %\ + (formatstr, args, output), end=' ') else: - print("%s %% %s works? ..." % (repr(formatstr), repr(args)), end=' ') + print("%r %% %r works? ..." % (formatstr, args), end=' ') try: result = formatstr % args except OverflowError: @@ -28,8 +28,8 @@ if output and result != output: if verbose: print('no') - print("%s %% %s == %s != %s" %\ - (repr(formatstr), repr(args), repr(result), repr(output))) + print("%r %% %r == %r != %r" %\ + (formatstr, args, result, output)) else: if verbose: print('yes') @@ -222,7 +222,7 @@ return self + 1 test_exc('%o', Foobar(), TypeError, - "expected str object, int found") + "expected string, int found") if maxsize == 2**31-1: # crashes 2.2.1 and earlier: From python-3000-checkins at python.org Sun Jun 10 03:06:43 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Sun, 10 Jun 2007 03:06:43 +0200 (CEST) Subject: [Python-3000-checkins] r55849 - in python/branches/p3yk/Lib: collections.py test/test_collections.py Message-ID: <20070610010643.3F2961E4006@bag.python.org> Author: guido.van.rossum Date: Sun Jun 10 03:06:38 2007 New Revision: 55849 Modified: python/branches/p3yk/Lib/collections.py python/branches/p3yk/Lib/test/test_collections.py Log: Make sure that the magic looking for __hash__ (etc.) doesn't apply to real subclasses of Hashable. Modified: python/branches/p3yk/Lib/collections.py ============================================================================== --- python/branches/p3yk/Lib/collections.py (original) +++ python/branches/p3yk/Lib/collections.py Sun Jun 10 03:06:38 2007 @@ -1,5 +1,7 @@ __all__ = ['deque', 'defaultdict', 'NamedTuple', 'Hashable', 'Iterable', 'Iterator', 'Sized', 'Container', + 'Sequence', 'Set', 'Mapping', + 'MutableSequence', 'MutableSet', 'MutableMapping', ] from _collections import deque, defaultdict @@ -7,6 +9,7 @@ import sys as _sys from abc import abstractmethod as _abstractmethod, ABCMeta as _ABCMeta + def NamedTuple(typename, s): """Returns a new subclass of tuple with named fields. @@ -57,6 +60,7 @@ def __subclasshook__(self, subclass): return NotImplemented + class Hashable(_OneTrickPony): @_abstractmethod @@ -65,11 +69,12 @@ @classmethod def __subclasshook__(cls, C): - for B in C.__mro__: - if "__hash__" in B.__dict__: - if B.__dict__["__hash__"]: - return True - break + if cls is Hashable: + for B in C.__mro__: + if "__hash__" in B.__dict__: + if B.__dict__["__hash__"]: + return True + break return NotImplemented @@ -82,9 +87,10 @@ @classmethod def __subclasshook__(cls, C): - if any("__iter__" in B.__dict__ or "__getitem__" in B.__dict__ - for B in C.__mro__): - return True + if cls is Iterable: + if any("__iter__" in B.__dict__ or "__getitem__" in B.__dict__ + for B in C.__mro__): + return True return NotImplemented @@ -99,8 +105,9 @@ @classmethod def __subclasshook__(cls, C): - if any("__next__" in B.__dict__ for B in C.__mro__): - return True + if cls is Iterator: + if any("__next__" in B.__dict__ for B in C.__mro__): + return True return NotImplemented @@ -112,8 +119,9 @@ @classmethod def __subclasshook__(cls, C): - if any("__len__" in B.__dict__ for B in C.__mro__): - return True + if cls is Sized: + if any("__len__" in B.__dict__ for B in C.__mro__): + return True return NotImplemented @@ -125,7 +133,10 @@ @classmethod def __subclasshook__(cls, C): - return any("__contains__" in B.__dict__ for B in C.__mro__) + if cls is Container: + if any("__contains__" in B.__dict__ for B in C.__mro__): + return True + return NotImplemented if __name__ == '__main__': Modified: python/branches/p3yk/Lib/test/test_collections.py ============================================================================== --- python/branches/p3yk/Lib/test/test_collections.py (original) +++ python/branches/p3yk/Lib/test/test_collections.py Sun Jun 10 03:06:38 2007 @@ -79,6 +79,7 @@ def __hash__(self): return super(H, self).__hash__() self.assertEqual(hash(H()), 0) + self.failIf(issubclass(int, H)) # Check registration class C: __hash__ = None @@ -87,16 +88,30 @@ self.failUnless(issubclass(C, Hashable)) def test_Iterable(self): + # Check some non-iterables non_samples = [None, 42, 3.14, 1j] for x in non_samples: self.failIf(isinstance(x, Iterable), repr(x)) self.failIf(issubclass(type(x), Iterable), repr(type(x))) + # Check some iterables samples = [bytes(), str(), unicode(), tuple(), list(), set(), frozenset(), dict(), ] for x in samples: self.failUnless(isinstance(x, Iterable), repr(x)) self.failUnless(issubclass(type(x), Iterable), repr(type(x))) + # Check direct subclassing + class I(Iterable): + def __iter__(self): + return super(I, self).__iter__() + self.assertEqual(list(I()), []) + self.failIf(issubclass(str, I)) + # Check registration + class C: + pass + self.failIf(issubclass(C, Iterable)) + Iterable.register(C) + self.failUnless(issubclass(C, Iterable)) def test_Iterator(self): non_samples = [None, 42, 3.14, 1j, b"", "", u"", (), [], {}, set()] @@ -142,5 +157,6 @@ test_support.run_unittest(*test_classes) test_support.run_doctest(CollectionsModule, verbose) + if __name__ == "__main__": test_main(verbose=True) From nnorwitz at gmail.com Sun Jun 10 03:11:09 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sat, 9 Jun 2007 21:11:09 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures refleak (1) Message-ID: <20070610011109.GA18818@python.psfb.org> test_collections leaked [23, 23, 24] references, sum=70 From python-3000-checkins at python.org Sun Jun 10 11:51:36 2007 From: python-3000-checkins at python.org (martin.v.loewis) Date: Sun, 10 Jun 2007 11:51:36 +0200 (CEST) Subject: [Python-3000-checkins] r55850 - in python/branches/py3k-struni: Include/ceval.h Include/pystate.h Include/stringobject.h Include/unicodeobject.h Lib/test/test_frozen.py Lib/test/test_new.py Lib/test/test_sys.py Modules/_codecsmodule.c Modules/_hotshot.c Modules/cPickle.c Modules/gcmodule.c Modules/unicodedata.c Objects/abstract.c Objects/bytesobject.c Objects/classobject.c Objects/codeobject.c Objects/complexobject.c Objects/descrobject.c Objects/dictobject.c Objects/frameobject.c Objects/funcobject.c Objects/methodobject.c Objects/moduleobject.c Objects/object.c Objects/stringobject.c Objects/typeobject.c Objects/unicodeobject.c Parser/tokenizer.c Python/Python-ast.c Python/ast.c Python/bltinmodule.c Python/ceval.c Python/compile.c Python/future.c Python/import.c Python/modsupport.c Python/pystate.c Python/pythonrun.c Python/symtable.c Python/sysmodule.c Message-ID: <20070610095136.E98851E4008@bag.python.org> Author: martin.v.loewis Date: Sun Jun 10 11:51:05 2007 New Revision: 55850 Modified: python/branches/py3k-struni/Include/ceval.h python/branches/py3k-struni/Include/pystate.h python/branches/py3k-struni/Include/stringobject.h python/branches/py3k-struni/Include/unicodeobject.h python/branches/py3k-struni/Lib/test/test_frozen.py python/branches/py3k-struni/Lib/test/test_new.py python/branches/py3k-struni/Lib/test/test_sys.py python/branches/py3k-struni/Modules/_codecsmodule.c python/branches/py3k-struni/Modules/_hotshot.c python/branches/py3k-struni/Modules/cPickle.c python/branches/py3k-struni/Modules/gcmodule.c python/branches/py3k-struni/Modules/unicodedata.c python/branches/py3k-struni/Objects/abstract.c python/branches/py3k-struni/Objects/bytesobject.c python/branches/py3k-struni/Objects/classobject.c python/branches/py3k-struni/Objects/codeobject.c python/branches/py3k-struni/Objects/complexobject.c python/branches/py3k-struni/Objects/descrobject.c python/branches/py3k-struni/Objects/dictobject.c python/branches/py3k-struni/Objects/frameobject.c python/branches/py3k-struni/Objects/funcobject.c python/branches/py3k-struni/Objects/methodobject.c python/branches/py3k-struni/Objects/moduleobject.c python/branches/py3k-struni/Objects/object.c python/branches/py3k-struni/Objects/stringobject.c python/branches/py3k-struni/Objects/typeobject.c python/branches/py3k-struni/Objects/unicodeobject.c python/branches/py3k-struni/Parser/tokenizer.c python/branches/py3k-struni/Python/Python-ast.c python/branches/py3k-struni/Python/ast.c python/branches/py3k-struni/Python/bltinmodule.c python/branches/py3k-struni/Python/ceval.c python/branches/py3k-struni/Python/compile.c python/branches/py3k-struni/Python/future.c python/branches/py3k-struni/Python/import.c python/branches/py3k-struni/Python/modsupport.c python/branches/py3k-struni/Python/pystate.c python/branches/py3k-struni/Python/pythonrun.c python/branches/py3k-struni/Python/symtable.c python/branches/py3k-struni/Python/sysmodule.c Log: Make identifiers str (not str8) objects throughout. This affects the parser, various object implementations, and all places that put identifiers into C string literals. In testing, a number of crashes occurred as code would fail when the recursion limit was reached (such as the Unicode interning dictionary having key/value pairs where key is not value). To solve these, I added an overflowed flag, which allows for 50 more recursions after the limit was reached and the exception was raised, and a recursion_critical flag, which indicates that recursion absolutely must be allowed, i.e. that a certain call must not cause a stack overflow exception. There are still some places where both str and str8 are accepted as identifiers; these should eventually be removed. Modified: python/branches/py3k-struni/Include/ceval.h ============================================================================== --- python/branches/py3k-struni/Include/ceval.h (original) +++ python/branches/py3k-struni/Include/ceval.h Sun Jun 10 11:51:05 2007 @@ -50,7 +50,10 @@ (_Py_MakeRecCheck(PyThreadState_GET()->recursion_depth) && \ _Py_CheckRecursiveCall(where)) #define Py_LeaveRecursiveCall() \ - (--PyThreadState_GET()->recursion_depth) + do{ if((--PyThreadState_GET()->recursion_depth) < \ + _Py_CheckRecursionLimit - 50); \ + PyThreadState_GET()->overflowed = 0; \ + } while(0) PyAPI_FUNC(int) _Py_CheckRecursiveCall(char *where); PyAPI_DATA(int) _Py_CheckRecursionLimit; #ifdef USE_STACKCHECK @@ -59,6 +62,14 @@ # define _Py_MakeRecCheck(x) (++(x) > _Py_CheckRecursionLimit) #endif +#define Py_ALLOW_RECURSION \ + do { unsigned char _old = PyThreadState_GET()->recursion_critical;\ + PyThreadState_GET()->recursion_critical = 1; + +#define Py_END_ALLOW_RECURSION \ + PyThreadState_GET()->recursion_critical = _old; \ + } while(0); + PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *); PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *); Modified: python/branches/py3k-struni/Include/pystate.h ============================================================================== --- python/branches/py3k-struni/Include/pystate.h (original) +++ python/branches/py3k-struni/Include/pystate.h Sun Jun 10 11:51:05 2007 @@ -61,6 +61,10 @@ struct _frame *frame; int recursion_depth; + char overflowed; /* The stack has overflowed. Allow 50 more calls + to handle the runtime error. */ + char recursion_critical; /* The current calls must not cause + a stack overflow. */ /* 'tracing' keeps track of the execution depth when tracing/profiling. This is to prevent the actual trace/profile code from being recorded in the trace/profile. */ Modified: python/branches/py3k-struni/Include/stringobject.h ============================================================================== --- python/branches/py3k-struni/Include/stringobject.h (original) +++ python/branches/py3k-struni/Include/stringobject.h Sun Jun 10 11:51:05 2007 @@ -84,8 +84,8 @@ #define PyString_CHECK_INTERNED(op) (((PyStringObject *)(op))->ob_sstate) /* Macro, trading safety for speed */ -#define PyString_AS_STRING(op) (((PyStringObject *)(op))->ob_sval) -#define PyString_GET_SIZE(op) (((PyStringObject *)(op))->ob_size) +#define PyString_AS_STRING(op) (assert(PyString_Check(op)),(((PyStringObject *)(op))->ob_sval)) +#define PyString_GET_SIZE(op) (assert(PyString_Check(op)),(((PyStringObject *)(op))->ob_size)) /* _PyString_Join(sep, x) is like sep.join(x). sep must be PyStringObject*, x must be an iterable object. */ Modified: python/branches/py3k-struni/Include/unicodeobject.h ============================================================================== --- python/branches/py3k-struni/Include/unicodeobject.h (original) +++ python/branches/py3k-struni/Include/unicodeobject.h Sun Jun 10 11:51:05 2007 @@ -410,13 +410,13 @@ /* Fast access macros */ #define PyUnicode_GET_SIZE(op) \ - (((PyUnicodeObject *)(op))->length) + (assert(PyUnicode_Check(op)),(((PyUnicodeObject *)(op))->length)) #define PyUnicode_GET_DATA_SIZE(op) \ - (((PyUnicodeObject *)(op))->length * sizeof(Py_UNICODE)) + (assert(PyUnicode_Check(op)),(((PyUnicodeObject *)(op))->length * sizeof(Py_UNICODE))) #define PyUnicode_AS_UNICODE(op) \ - (((PyUnicodeObject *)(op))->str) + (assert(PyUnicode_Check(op)),(((PyUnicodeObject *)(op))->str)) #define PyUnicode_AS_DATA(op) \ - ((const char *)((PyUnicodeObject *)(op))->str) + (assert(PyUnicode_Check(op)),((const char *)((PyUnicodeObject *)(op))->str)) /* --- Constants ---------------------------------------------------------- */ @@ -627,6 +627,13 @@ PyAPI_FUNC(PyObject *) _PyUnicode_AsDefaultEncodedString( PyObject *, const char *); +/* Return a char* holding the default encoded value of the + Unicode object. +*/ + +PyAPI_FUNC(char *) PyUnicode_AsString(PyObject*); + + /* Returns the currently active default encoding. The default encoding is currently implemented as run-time settable @@ -1193,6 +1200,11 @@ PyObject *right /* Right string */ ); +PyAPI_FUNC(int) PyUnicode_CompareWithASCIIString( + PyObject *left, + const char *right + ); + /* Rich compare two strings and return one of the following: - NULL in case an exception was raised @@ -1310,6 +1322,22 @@ Py_UNICODE ch /* Unicode character */ ); +PyAPI_FUNC(size_t) Py_UNICODE_strlen(const Py_UNICODE *u); + +PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strcpy( + Py_UNICODE *s1, const Py_UNICODE *s2); + +PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strncpy( + Py_UNICODE *s1, const Py_UNICODE *s2, size_t n); + +PyAPI_FUNC(int) Py_UNICODE_strcmp( + const Py_UNICODE *s1, const Py_UNICODE *s2); + +PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strchr( + const Py_UNICODE *s, Py_UNICODE c + ); + + #ifdef __cplusplus } #endif Modified: python/branches/py3k-struni/Lib/test/test_frozen.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_frozen.py (original) +++ python/branches/py3k-struni/Lib/test/test_frozen.py Sun Jun 10 11:51:05 2007 @@ -10,6 +10,8 @@ from test.test_support import TestFailed import sys, os +raise TestFailed, "test currently causes assertion in debug mode" + try: import __hello__ except ImportError as x: Modified: python/branches/py3k-struni/Lib/test/test_new.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_new.py (original) +++ python/branches/py3k-struni/Lib/test/test_new.py Sun Jun 10 11:51:05 2007 @@ -143,7 +143,7 @@ firstlineno, lnotab) # new.code used to be a way to mutate a tuple... - class S(str8): + class S(str): pass t = (S("ab"),) d = new.code(argcount, kwonlyargcount, nlocals, stacksize, Modified: python/branches/py3k-struni/Lib/test/test_sys.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_sys.py (original) +++ python/branches/py3k-struni/Lib/test/test_sys.py Sun Jun 10 11:51:05 2007 @@ -321,12 +321,6 @@ self.assertRaises(TypeError, sys.intern, S("abc")) - # It's still safe to pass these strings to routines that - # call intern internally, e.g. PyObject_SetAttr(). - s = S("abc") - setattr(s, s, s) - self.assertEqual(getattr(s, s), s) - s = "never interned as unicode before" self.assert_(sys.intern(s) is s) s2 = s.swapcase().swapcase() @@ -338,6 +332,12 @@ self.assertRaises(TypeError, sys.intern, U("abc")) + # It's still safe to pass these strings to routines that + # call intern internally, e.g. PyObject_SetAttr(). + s = U("abc") + setattr(s, s, s) + self.assertEqual(getattr(s, s), s) + def test_main(): test.test_support.run_unittest(SysModuleTest) Modified: python/branches/py3k-struni/Modules/_codecsmodule.c ============================================================================== --- python/branches/py3k-struni/Modules/_codecsmodule.c (original) +++ python/branches/py3k-struni/Modules/_codecsmodule.c Sun Jun 10 11:51:05 2007 @@ -172,7 +172,7 @@ &PyString_Type, &str, &errors)) return NULL; - size = PyUnicode_GET_SIZE(str); + size = PyString_GET_SIZE(str); newsize = 4*size; if (newsize > PY_SSIZE_T_MAX || newsize / 4 != size) { PyErr_SetString(PyExc_OverflowError, Modified: python/branches/py3k-struni/Modules/_hotshot.c ============================================================================== --- python/branches/py3k-struni/Modules/_hotshot.c (original) +++ python/branches/py3k-struni/Modules/_hotshot.c Sun Jun 10 11:51:05 2007 @@ -810,7 +810,7 @@ PyObject *name = PyDict_GetItem(dict, obj); if (name == NULL) { if (pack_define_func(self, fileno, fcode->co_firstlineno, - PyString_AS_STRING(fcode->co_name)) < 0) { + PyUnicode_AsString(fcode->co_name)) < 0) { Py_DECREF(obj); return -1; } Modified: python/branches/py3k-struni/Modules/cPickle.c ============================================================================== --- python/branches/py3k-struni/Modules/cPickle.c (original) +++ python/branches/py3k-struni/Modules/cPickle.c Sun Jun 10 11:51:05 2007 @@ -1829,8 +1829,8 @@ (name_size = PyString_Size(global_name)) < 0) goto finally; - module_str = PyString_AS_STRING((PyStringObject *)module); - name_str = PyString_AS_STRING((PyStringObject *)global_name); + module_str = PyUnicode_AsString(module); + name_str = PyUnicode_AsString(global_name); /* XXX This can be doing a relative import. Clearly it shouldn't, but I don't know how to stop it. :-( */ @@ -1842,7 +1842,7 @@ "OS", args, module); goto finally; } - klass = PyObject_GetAttrString(mod, name_str); + klass = PyObject_GetAttr(mod, global_name); if (klass == NULL) { cPickle_ErrFormat(PicklingError, "Can't pickle %s: attribute lookup %s.%s " @@ -2223,7 +2223,7 @@ res = save_string(self, args, 0); goto finally; } - if ((type == &PyUnicode_Type) && (PyString_GET_SIZE(args) < 2)) { + if ((type == &PyUnicode_Type) && (PyUnicode_GET_SIZE(args) < 2)) { res = save_unicode(self, args, 0); goto finally; } @@ -3584,7 +3584,7 @@ Py_DECREF(module_name); return bad_readline(); } - if ((class_name = PyString_FromStringAndSize(s, len - 1))) { + if ((class_name = PyUnicode_FromStringAndSize(s, len - 1))) { class = find_class(module_name, class_name, self->find_class); Py_DECREF(class_name); @@ -5379,7 +5379,7 @@ { PyObject *copy_reg, *t, *r; -#define INIT_STR(S) if (!( S ## _str=PyString_InternFromString(#S))) return -1; +#define INIT_STR(S) if (!( S ## _str=PyUnicode_InternFromString(#S))) return -1; if (PyType_Ready(&Unpicklertype) < 0) return -1; Modified: python/branches/py3k-struni/Modules/gcmodule.c ============================================================================== --- python/branches/py3k-struni/Modules/gcmodule.c (original) +++ python/branches/py3k-struni/Modules/gcmodule.c Sun Jun 10 11:51:05 2007 @@ -713,7 +713,7 @@ double t1 = 0.0; if (delstr == NULL) { - delstr = PyString_InternFromString("__del__"); + delstr = PyUnicode_InternFromString("__del__"); if (delstr == NULL) Py_FatalError("gc couldn't allocate \"__del__\""); } Modified: python/branches/py3k-struni/Modules/unicodedata.c ============================================================================== --- python/branches/py3k-struni/Modules/unicodedata.c (original) +++ python/branches/py3k-struni/Modules/unicodedata.c Sun Jun 10 11:51:05 2007 @@ -515,7 +515,7 @@ /* Hangul Decomposition adds three characters in a single step, so we need atleast that much room. */ if (space < 3) { - Py_ssize_t newsize = PyString_GET_SIZE(result) + 10; + Py_ssize_t newsize = PyUnicode_GET_SIZE(result) + 10; space += 10; if (PyUnicode_Resize(&result, newsize) == -1) return NULL; Modified: python/branches/py3k-struni/Objects/abstract.c ============================================================================== --- python/branches/py3k-struni/Objects/abstract.c (original) +++ python/branches/py3k-struni/Objects/abstract.c Sun Jun 10 11:51:05 2007 @@ -207,7 +207,7 @@ null_error(); return -1; } - okey = PyString_FromString(key); + okey = PyUnicode_FromString(key); if (okey == NULL) return -1; ret = PyObject_DelItem(o, okey); @@ -1598,7 +1598,7 @@ if (key == NULL) return null_error(); - okey = PyString_FromString(key); + okey = PyUnicode_FromString(key); if (okey == NULL) return NULL; r = PyObject_GetItem(o, okey); @@ -1617,7 +1617,7 @@ return -1; } - okey = PyString_FromString(key); + okey = PyUnicode_FromString(key); if (okey == NULL) return -1; r = PyObject_SetItem(o, okey, value); @@ -1989,11 +1989,13 @@ PyObject *bases; if (__bases__ == NULL) { - __bases__ = PyString_FromString("__bases__"); + __bases__ = PyUnicode_FromString("__bases__"); if (__bases__ == NULL) return NULL; } + Py_ALLOW_RECURSION bases = PyObject_GetAttr(cls, __bases__); + Py_END_ALLOW_RECURSION if (bases == NULL) { if (PyErr_ExceptionMatches(PyExc_AttributeError)) PyErr_Clear(); @@ -2067,7 +2069,7 @@ int retval = 0; if (__class__ == NULL) { - __class__ = PyString_FromString("__class__"); + __class__ = PyUnicode_FromString("__class__"); if (__class__ == NULL) return -1; } Modified: python/branches/py3k-struni/Objects/bytesobject.c ============================================================================== --- python/branches/py3k-struni/Objects/bytesobject.c (original) +++ python/branches/py3k-struni/Objects/bytesobject.c Sun Jun 10 11:51:05 2007 @@ -1078,7 +1078,7 @@ else if (PyObject_AsCharBuffer(sub_obj, &sub, &sub_len)) return NULL; - _adjust_indices(&start, &end, PyString_GET_SIZE(self)); + _adjust_indices(&start, &end, PyBytes_GET_SIZE(self)); return PyInt_FromSsize_t( stringlib_count(str + start, end - start, sub, sub_len) Modified: python/branches/py3k-struni/Objects/classobject.c ============================================================================== --- python/branches/py3k-struni/Objects/classobject.c (original) +++ python/branches/py3k-struni/Objects/classobject.c Sun Jun 10 11:51:05 2007 @@ -100,7 +100,7 @@ { static PyObject *docstr; if (docstr == NULL) { - docstr= PyString_InternFromString("__doc__"); + docstr= PyUnicode_InternFromString("__doc__"); if (docstr == NULL) return NULL; } @@ -235,12 +235,12 @@ return NULL; PyErr_Clear(); } - else if (!PyString_Check(funcname)) { + else if (!PyUnicode_Check(funcname)) { Py_DECREF(funcname); funcname = NULL; } else - sfuncname = PyString_AS_STRING(funcname); + sfuncname = PyUnicode_AsString(funcname); if (klass == NULL) klassname = NULL; else { @@ -250,12 +250,12 @@ return NULL; PyErr_Clear(); } - else if (!PyString_Check(klassname)) { + else if (!PyUnicode_Check(klassname)) { Py_DECREF(klassname); klassname = NULL; } else - sklassname = PyString_AS_STRING(klassname); + sklassname = PyUnicode_AsString(klassname); } if (self == NULL) result = PyUnicode_FromFormat("", Modified: python/branches/py3k-struni/Objects/codeobject.c ============================================================================== --- python/branches/py3k-struni/Objects/codeobject.c (original) +++ python/branches/py3k-struni/Objects/codeobject.c Sun Jun 10 11:51:05 2007 @@ -32,10 +32,10 @@ for (i = PyTuple_GET_SIZE(tuple); --i >= 0; ) { PyObject *v = PyTuple_GET_ITEM(tuple, i); - if (v == NULL || !PyString_CheckExact(v)) { + if (v == NULL || !PyUnicode_CheckExact(v)) { Py_FatalError("non-string found in code slot"); } - PyString_InternInPlace(&PyTuple_GET_ITEM(tuple, i)); + PyUnicode_InternInPlace(&PyTuple_GET_ITEM(tuple, i)); } } @@ -58,7 +58,7 @@ varnames == NULL || !PyTuple_Check(varnames) || freevars == NULL || !PyTuple_Check(freevars) || cellvars == NULL || !PyTuple_Check(cellvars) || - name == NULL || !PyString_Check(name) || + name == NULL || (!PyString_Check(name) && !PyUnicode_Check(name)) || filename == NULL || !PyString_Check(filename) || lnotab == NULL || !PyString_Check(lnotab) || !PyObject_CheckReadBuffer(code)) { @@ -148,10 +148,10 @@ for (i = 0; i < len; i++) { item = PyTuple_GET_ITEM(tup, i); - if (PyString_CheckExact(item)) { + if (PyUnicode_CheckExact(item)) { Py_INCREF(item); } - else if (!PyString_Check(item)) { + else if (!PyUnicode_Check(item)) { PyErr_Format( PyExc_TypeError, "name tuples must contain only " @@ -161,9 +161,9 @@ return NULL; } else { - item = PyString_FromStringAndSize( - PyString_AS_STRING(item), - PyString_GET_SIZE(item)); + item = PyUnicode_FromUnicode( + PyUnicode_AS_UNICODE(item), + PyUnicode_GET_SIZE(item)); if (item == NULL) { Py_DECREF(newtuple); return NULL; Modified: python/branches/py3k-struni/Objects/complexobject.c ============================================================================== --- python/branches/py3k-struni/Objects/complexobject.c (original) +++ python/branches/py3k-struni/Objects/complexobject.c Sun Jun 10 11:51:05 2007 @@ -269,7 +269,7 @@ { PyObject *complexfunc; if (!complex_str) { - if (!(complex_str = PyString_FromString("__complex__"))) + if (!(complex_str = PyUnicode_FromString("__complex__"))) return cv; } complexfunc = _PyType_Lookup(op->ob_type, complex_str); @@ -900,7 +900,7 @@ /* XXX Hack to support classes with __complex__ method */ if (complexstr == NULL) { - complexstr = PyString_InternFromString("__complex__"); + complexstr = PyUnicode_InternFromString("__complex__"); if (complexstr == NULL) return NULL; } Modified: python/branches/py3k-struni/Objects/descrobject.c ============================================================================== --- python/branches/py3k-struni/Objects/descrobject.c (original) +++ python/branches/py3k-struni/Objects/descrobject.c Sun Jun 10 11:51:05 2007 @@ -15,7 +15,10 @@ static char * descr_name(PyDescrObject *descr) { - if (descr->d_name != NULL && PyString_Check(descr->d_name)) + if (descr->d_name != NULL && PyUnicode_Check(descr->d_name)) + return PyUnicode_AsString(descr->d_name); + else if (descr->d_name != NULL && PyString_Check(descr->d_name)) + /* XXX this should not happen */ return PyString_AS_STRING(descr->d_name); else return "?"; @@ -581,7 +584,7 @@ if (descr != NULL) { Py_XINCREF(type); descr->d_type = type; - descr->d_name = PyString_InternFromString(name); + descr->d_name = PyUnicode_InternFromString(name); if (descr->d_name == NULL) { Py_DECREF(descr); descr = NULL; Modified: python/branches/py3k-struni/Objects/dictobject.c ============================================================================== --- python/branches/py3k-struni/Objects/dictobject.c (original) +++ python/branches/py3k-struni/Objects/dictobject.c Sun Jun 10 11:51:05 2007 @@ -1040,7 +1040,7 @@ static PyObject *missing_str = NULL; if (missing_str == NULL) missing_str = - PyString_InternFromString("__missing__"); + PyUnicode_InternFromString("__missing__"); missing = _PyType_Lookup(mp->ob_type, missing_str); if (missing != NULL) return PyObject_CallFunctionObjArgs(missing, @@ -2073,7 +2073,7 @@ PyDict_GetItemString(PyObject *v, const char *key) { PyObject *kv, *rv; - kv = PyString_FromString(key); + kv = PyUnicode_FromString(key); if (kv == NULL) return NULL; rv = PyDict_GetItem(v, kv); @@ -2086,10 +2086,10 @@ { PyObject *kv; int err; - kv = PyString_FromString(key); + kv = PyUnicode_FromString(key); if (kv == NULL) return -1; - PyString_InternInPlace(&kv); /* XXX Should we really? */ + PyUnicode_InternInPlace(&kv); /* XXX Should we really? */ err = PyDict_SetItem(v, kv, item); Py_DECREF(kv); return err; @@ -2100,7 +2100,7 @@ { PyObject *kv; int err; - kv = PyString_FromString(key); + kv = PyUnicode_FromString(key); if (kv == NULL) return -1; err = PyDict_DelItem(v, kv); Modified: python/branches/py3k-struni/Objects/frameobject.c ============================================================================== --- python/branches/py3k-struni/Objects/frameobject.c (original) +++ python/branches/py3k-struni/Objects/frameobject.c Sun Jun 10 11:51:05 2007 @@ -542,7 +542,7 @@ int _PyFrame_Init() { - builtin_object = PyString_InternFromString("__builtins__"); + builtin_object = PyUnicode_InternFromString("__builtins__"); return (builtin_object != NULL); } @@ -722,7 +722,7 @@ for (j = nmap; --j >= 0; ) { PyObject *key = PyTuple_GET_ITEM(map, j); PyObject *value = values[j]; - assert(PyString_Check(key)); + assert(PyString_Check(key)/*XXX this should go*/ || PyUnicode_Check(key)); if (deref) { assert(PyCell_Check(value)); value = PyCell_GET(value); @@ -770,7 +770,7 @@ for (j = nmap; --j >= 0; ) { PyObject *key = PyTuple_GET_ITEM(map, j); PyObject *value = PyObject_GetItem(dict, key); - assert(PyString_Check(key)); + assert(PyUnicode_Check(key)); /* We only care about NULLs if clear is true. */ if (value == NULL) { PyErr_Clear(); Modified: python/branches/py3k-struni/Objects/funcobject.c ============================================================================== --- python/branches/py3k-struni/Objects/funcobject.c (original) +++ python/branches/py3k-struni/Objects/funcobject.c Sun Jun 10 11:51:05 2007 @@ -322,7 +322,7 @@ /* Not legal to del f.func_name or to set it to anything * other than a string object. */ - if (value == NULL || !PyString_Check(value)) { + if (value == NULL || (!PyString_Check(value) && !PyUnicode_Check(value))) { PyErr_SetString(PyExc_TypeError, "__name__ must be set to a string object"); return -1; @@ -516,7 +516,7 @@ if (nfree != nclosure) return PyErr_Format(PyExc_ValueError, "%s requires closure of length %zd, not %zd", - PyString_AS_STRING(code->co_name), + PyUnicode_AsString(code->co_name), nfree, nclosure); if (nclosure) { Py_ssize_t i; Modified: python/branches/py3k-struni/Objects/methodobject.c ============================================================================== --- python/branches/py3k-struni/Objects/methodobject.c (original) +++ python/branches/py3k-struni/Objects/methodobject.c Sun Jun 10 11:51:05 2007 @@ -143,7 +143,7 @@ static PyObject * meth_get__name__(PyCFunctionObject *m, void *closure) { - return PyString_FromString(m->m_ml->ml_name); + return PyUnicode_FromString(m->m_ml->ml_name); } static int @@ -297,7 +297,7 @@ i = 0; for (c = chain; c != NULL; c = c->link) { for (ml = c->methods; ml->ml_name != NULL; ml++) { - PyList_SetItem(v, i, PyString_FromString(ml->ml_name)); + PyList_SetItem(v, i, PyUnicode_FromString(ml->ml_name)); i++; } } Modified: python/branches/py3k-struni/Objects/moduleobject.c ============================================================================== --- python/branches/py3k-struni/Objects/moduleobject.c (original) +++ python/branches/py3k-struni/Objects/moduleobject.c Sun Jun 10 11:51:05 2007 @@ -22,7 +22,7 @@ m = PyObject_GC_New(PyModuleObject, &PyModule_Type); if (m == NULL) return NULL; - nameobj = PyString_FromString(name); + nameobj = PyUnicode_FromString(name); m->md_dict = PyDict_New(); if (m->md_dict == NULL || nameobj == NULL) goto fail; Modified: python/branches/py3k-struni/Objects/object.c ============================================================================== --- python/branches/py3k-struni/Objects/object.c (original) +++ python/branches/py3k-struni/Objects/object.c Sun Jun 10 11:51:05 2007 @@ -465,7 +465,7 @@ check this before trying the __unicode__ method. */ if (unicodestr == NULL) { - unicodestr= PyString_InternFromString("__unicode__"); + unicodestr= PyUnicode_InternFromString("__unicode__"); if (unicodestr == NULL) return NULL; } @@ -852,7 +852,7 @@ if (v->ob_type->tp_getattr != NULL) return (*v->ob_type->tp_getattr)(v, (char*)name); - w = PyString_InternFromString(name); + w = PyUnicode_InternFromString(name); if (w == NULL) return NULL; res = PyObject_GetAttr(v, w); @@ -880,7 +880,7 @@ if (v->ob_type->tp_setattr != NULL) return (*v->ob_type->tp_setattr)(v, (char*)name, w); - s = PyString_InternFromString(name); + s = PyUnicode_InternFromString(name); if (s == NULL) return -1; res = PyObject_SetAttr(v, s, w); @@ -893,30 +893,19 @@ { PyTypeObject *tp = v->ob_type; - if (!PyString_Check(name)) { - /* The Unicode to string conversion is done here because the - existing tp_getattro slots expect a string object as name - and we wouldn't want to break those. */ - if (PyUnicode_Check(name)) { - name = _PyUnicode_AsDefaultEncodedString(name, NULL); - if (name == NULL) - return NULL; - } - else - { - PyErr_Format(PyExc_TypeError, - "attribute name must be string, not '%.200s'", - name->ob_type->tp_name); - return NULL; - } + if (!PyUnicode_Check(name)) { + PyErr_Format(PyExc_TypeError, + "attribute name must be string, not '%.200s'", + name->ob_type->tp_name); + return NULL; } if (tp->tp_getattro != NULL) return (*tp->tp_getattro)(v, name); if (tp->tp_getattr != NULL) - return (*tp->tp_getattr)(v, PyString_AS_STRING(name)); + return (*tp->tp_getattr)(v, PyUnicode_AsString(name)); PyErr_Format(PyExc_AttributeError, "'%.50s' object has no attribute '%.400s'", - tp->tp_name, PyString_AS_STRING(name)); + tp->tp_name, PyUnicode_AsString(name)); return NULL; } @@ -938,33 +927,22 @@ PyTypeObject *tp = v->ob_type; int err; - if (!PyString_Check(name)) { - /* The Unicode to string conversion is done here because the - existing tp_setattro slots expect a string object as name - and we wouldn't want to break those. */ - if (PyUnicode_Check(name)) { - name = _PyUnicode_AsDefaultEncodedString(name, NULL); - if (name == NULL) - return -1; - } - else - { - PyErr_Format(PyExc_TypeError, - "attribute name must be string, not '%.200s'", - name->ob_type->tp_name); - return -1; - } + if (!PyUnicode_Check(name)) { + PyErr_Format(PyExc_TypeError, + "attribute name must be string, not '%.200s'", + name->ob_type->tp_name); + return -1; } Py_INCREF(name); - PyString_InternInPlace(&name); + PyUnicode_InternInPlace(&name); if (tp->tp_setattro != NULL) { err = (*tp->tp_setattro)(v, name, value); Py_DECREF(name); return err; } if (tp->tp_setattr != NULL) { - err = (*tp->tp_setattr)(v, PyString_AS_STRING(name), value); + err = (*tp->tp_setattr)(v, PyUnicode_AsString(name), value); Py_DECREF(name); return err; } @@ -976,14 +954,14 @@ "(%s .%.100s)", tp->tp_name, value==NULL ? "del" : "assign to", - PyString_AS_STRING(name)); + PyUnicode_AsString(name)); else PyErr_Format(PyExc_TypeError, "'%.100s' object has only read-only attributes " "(%s .%.100s)", tp->tp_name, value==NULL ? "del" : "assign to", - PyString_AS_STRING(name)); + PyUnicode_AsString(name)); return -1; } @@ -1033,22 +1011,11 @@ Py_ssize_t dictoffset; PyObject **dictptr; - if (!PyString_Check(name)){ - /* The Unicode to string conversion is done here because the - existing tp_setattro slots expect a string object as name - and we wouldn't want to break those. */ - if (PyUnicode_Check(name)) { - name = PyUnicode_AsEncodedString(name, NULL, NULL); - if (name == NULL) - return NULL; - } - else - { - PyErr_Format(PyExc_TypeError, - "attribute name must be string, not '%.200s'", - name->ob_type->tp_name); - return NULL; - } + if (!PyUnicode_Check(name)){ + PyErr_Format(PyExc_TypeError, + "attribute name must be string, not '%.200s'", + name->ob_type->tp_name); + return NULL; } else Py_INCREF(name); @@ -1134,7 +1101,7 @@ PyErr_Format(PyExc_AttributeError, "'%.50s' object has no attribute '%.400s'", - tp->tp_name, PyString_AS_STRING(name)); + tp->tp_name, PyUnicode_AsString(name)); done: Py_DECREF(name); return res; @@ -1149,22 +1116,11 @@ PyObject **dictptr; int res = -1; - if (!PyString_Check(name)){ - /* The Unicode to string conversion is done here because the - existing tp_setattro slots expect a string object as name - and we wouldn't want to break those. */ - if (PyUnicode_Check(name)) { - name = PyUnicode_AsEncodedString(name, NULL, NULL); - if (name == NULL) - return -1; - } - else - { - PyErr_Format(PyExc_TypeError, - "attribute name must be string, not '%.200s'", - name->ob_type->tp_name); - return -1; - } + if (!PyUnicode_Check(name)){ + PyErr_Format(PyExc_TypeError, + "attribute name must be string, not '%.200s'", + name->ob_type->tp_name); + return -1; } else Py_INCREF(name); @@ -1212,13 +1168,13 @@ if (descr == NULL) { PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", - tp->tp_name, PyString_AS_STRING(name)); + tp->tp_name, PyUnicode_AsString(name)); goto done; } PyErr_Format(PyExc_AttributeError, "'%.50s' object attribute '%.400s' is read-only", - tp->tp_name, PyString_AS_STRING(name)); + tp->tp_name, PyUnicode_AsString(name)); done: Py_DECREF(name); return res; Modified: python/branches/py3k-struni/Objects/stringobject.c ============================================================================== --- python/branches/py3k-struni/Objects/stringobject.c (original) +++ python/branches/py3k-struni/Objects/stringobject.c Sun Jun 10 11:51:05 2007 @@ -686,6 +686,11 @@ Py_ssize_t PyString_Size(register PyObject *op) { + if (PyUnicode_Check(op)) { + op = _PyUnicode_AsDefaultEncodedString(op, NULL); + if (!op) + return -1; + } if (!PyString_Check(op)) return string_getsize(op); return ((PyStringObject *)op) -> ob_size; @@ -694,6 +699,11 @@ /*const*/ char * PyString_AsString(register PyObject *op) { + if (PyUnicode_Check(op)) { + op = _PyUnicode_AsDefaultEncodedString(op, NULL); + if (!op) + return NULL; + } if (!PyString_Check(op)) return string_getbuffer(op); return ((PyStringObject *)op) -> ob_sval; @@ -824,7 +834,7 @@ { static const char *hexdigits = "0123456789abcdef"; register PyStringObject* op = (PyStringObject*) obj; - Py_ssize_t length = PyUnicode_GET_SIZE(op); + Py_ssize_t length = PyString_GET_SIZE(op); size_t newsize = 2 + 4 * op->ob_size; PyObject *v; if (newsize > PY_SSIZE_T_MAX || newsize / 4 != op->ob_size) { Modified: python/branches/py3k-struni/Objects/typeobject.c ============================================================================== --- python/branches/py3k-struni/Objects/typeobject.c (original) +++ python/branches/py3k-struni/Objects/typeobject.c Sun Jun 10 11:51:05 2007 @@ -35,7 +35,7 @@ s = type->tp_name; else s++; - return PyString_FromString(s); + return PyUnicode_FromString(s); } } @@ -97,9 +97,9 @@ else { s = strrchr(type->tp_name, '.'); if (s != NULL) - return PyString_FromStringAndSize( + return PyUnicode_FromStringAndSize( type->tp_name, (Py_ssize_t)(s - type->tp_name)); - return PyString_FromString("__builtin__"); + return PyUnicode_FromString("__builtin__"); } } @@ -371,7 +371,7 @@ mod = type_module(type, NULL); if (mod == NULL) PyErr_Clear(); - else if (!PyString_Check(mod)) { + else if (!PyUnicode_Check(mod)) { Py_DECREF(mod); mod = NULL; } @@ -384,11 +384,11 @@ else kind = "type"; - if (mod != NULL && strcmp(PyString_AS_STRING(mod), "__builtin__")) { + if (mod != NULL && strcmp(PyUnicode_AsString(mod), "__builtin__")) { rtn = PyUnicode_FromFormat("<%s '%s.%s'>", kind, - PyString_AS_STRING(mod), - PyString_AS_STRING(name)); + PyUnicode_AsString(mod), + PyUnicode_AsString(name)); } else rtn = PyUnicode_FromFormat("<%s '%s'>", kind, type->tp_name); @@ -859,7 +859,7 @@ PyObject *res; if (*attrobj == NULL) { - *attrobj = PyString_InternFromString(attrstr); + *attrobj = PyUnicode_InternFromString(attrstr); if (*attrobj == NULL) return NULL; } @@ -1415,7 +1415,7 @@ PyObject *descr; if (dict_str == NULL) { - dict_str = PyString_InternFromString("__dict__"); + dict_str = PyUnicode_InternFromString("__dict__"); if (dict_str == NULL) return NULL; } @@ -1564,14 +1564,14 @@ unsigned char *p; Py_ssize_t i, n; - if (!PyString_Check(s)) { + if (!PyUnicode_Check(s)) { PyErr_Format(PyExc_TypeError, "__slots__ items must be strings, not '%.200s'", s->ob_type->tp_name); return 0; } - p = (unsigned char *) PyString_AS_STRING(s); - n = PyString_GET_SIZE(s); + p = (unsigned char *) PyUnicode_AsString(s); + n = strlen((char*)p)/*XXX PyString_GET_SIZE(s)*/; /* We must reject an empty name. As a hack, we bump the length to 1 so that the loop will balk on the trailing \0. */ if (n == 0) @@ -1792,22 +1792,13 @@ return NULL; } - tmp = _unicode_to_string(slots, nslots); - if (tmp == NULL) - goto bad_slots; - if (tmp != slots) { - Py_DECREF(slots); - slots = tmp; - } /* Check for valid slot names and two special cases */ for (i = 0; i < nslots; i++) { PyObject *tmp = PyTuple_GET_ITEM(slots, i); - char *s; if (!valid_identifier(tmp)) goto bad_slots; - assert(PyString_Check(tmp)); - s = PyString_AS_STRING(tmp); - if (strcmp(s, "__dict__") == 0) { + assert(PyUnicode_Check(tmp)); + if (PyUnicode_CompareWithASCIIString(tmp, "__dict__") == 0) { if (!may_add_dict || add_dict) { PyErr_SetString(PyExc_TypeError, "__dict__ slot disallowed: " @@ -1816,7 +1807,7 @@ } add_dict++; } - if (strcmp(s, "__weakref__") == 0) { + if (PyUnicode_CompareWithASCIIString(tmp, "__weakref__") == 0) { if (!may_add_weak || add_weak) { PyErr_SetString(PyExc_TypeError, "__weakref__ slot disallowed: " @@ -1836,11 +1827,11 @@ if (newslots == NULL) goto bad_slots; for (i = j = 0; i < nslots; i++) { - char *s; tmp = PyTuple_GET_ITEM(slots, i); - s = PyString_AS_STRING(tmp); - if ((add_dict && strcmp(s, "__dict__") == 0) || - (add_weak && strcmp(s, "__weakref__") == 0)) + if ((add_dict && + PyUnicode_CompareWithASCIIString(tmp, "__dict__") == 0) || + (add_weak && + PyUnicode_CompareWithASCIIString(tmp, "__weakref__") == 0)) continue; tmp =_Py_Mangle(name, tmp); if (!tmp) @@ -1917,7 +1908,15 @@ type->tp_as_sequence = &et->as_sequence; type->tp_as_mapping = &et->as_mapping; type->tp_as_buffer = &et->as_buffer; - type->tp_name = PyString_AS_STRING(name); + if (PyString_Check(name)) + type->tp_name = PyString_AsString(name); + else { + type->tp_name = PyUnicode_AsString(name); + if (!type->tp_name) { + Py_DECREF(type); + return NULL; + } + } /* Set tp_base and tp_bases */ type->tp_bases = bases; @@ -1980,7 +1979,7 @@ slotoffset = base->tp_basicsize; if (slots != NULL) { for (i = 0; i < nslots; i++, mp++) { - mp->name = PyString_AS_STRING( + mp->name = PyUnicode_AsString( PyTuple_GET_ITEM(slots, i)); mp->type = T_OBJECT_EX; mp->offset = slotoffset; @@ -2157,7 +2156,7 @@ /* Give up */ PyErr_Format(PyExc_AttributeError, "type object '%.50s' has no attribute '%.400s'", - type->tp_name, PyString_AS_STRING(name)); + type->tp_name, PyUnicode_AsString(name)); return NULL; } @@ -2473,7 +2472,7 @@ mod = type_module(type, NULL); if (mod == NULL) PyErr_Clear(); - else if (!PyString_Check(mod)) { + else if (!PyUnicode_Check(mod)) { Py_DECREF(mod); mod = NULL; } @@ -2482,8 +2481,8 @@ return NULL; if (mod != NULL && strcmp(PyString_AS_STRING(mod), "__builtin__")) rtn = PyUnicode_FromFormat("<%s.%s object at %p>", - PyString_AS_STRING(mod), - PyString_AS_STRING(name), + PyUnicode_AsString(mod), + PyUnicode_AsString(name), self); else rtn = PyUnicode_FromFormat("<%s object at %p>", @@ -2686,7 +2685,7 @@ static PyObject *copy_reg_str; if (!copy_reg_str) { - copy_reg_str = PyString_InternFromString("copy_reg"); + copy_reg_str = PyUnicode_InternFromString("copy_reg"); if (copy_reg_str == NULL) return NULL; } @@ -4330,7 +4329,7 @@ descrgetfunc f; if (getitem_str == NULL) { - getitem_str = PyString_InternFromString("__getitem__"); + getitem_str = PyUnicode_InternFromString("__getitem__"); if (getitem_str == NULL) return NULL; } @@ -4760,13 +4759,13 @@ static PyObject *getattr_str = NULL; if (getattr_str == NULL) { - getattr_str = PyString_InternFromString("__getattr__"); + getattr_str = PyUnicode_InternFromString("__getattr__"); if (getattr_str == NULL) return NULL; } if (getattribute_str == NULL) { getattribute_str = - PyString_InternFromString("__getattribute__"); + PyUnicode_InternFromString("__getattribute__"); if (getattribute_str == NULL) return NULL; } @@ -4898,7 +4897,7 @@ static PyObject *get_str = NULL; if (get_str == NULL) { - get_str = PyString_InternFromString("__get__"); + get_str = PyUnicode_InternFromString("__get__"); if (get_str == NULL) return NULL; } @@ -4968,7 +4967,7 @@ Py_ssize_t i, n; if (new_str == NULL) { - new_str = PyString_InternFromString("__new__"); + new_str = PyUnicode_InternFromString("__new__"); if (new_str == NULL) return NULL; } @@ -5490,7 +5489,7 @@ if (initialized) return; for (p = slotdefs; p->name; p++) { - p->name_strobj = PyString_InternFromString(p->name); + p->name_strobj = PyUnicode_InternFromString(p->name); if (!p->name_strobj) Py_FatalError("Out of memory interning slotdef names"); } @@ -5717,9 +5716,9 @@ if (!skip) { /* We want __class__ to return the class of the super object (i.e. super, or a subclass), not the class of su->obj. */ - skip = (PyString_Check(name) && - PyString_GET_SIZE(name) == 9 && - strcmp(PyString_AS_STRING(name), "__class__") == 0); + skip = (PyUnicode_Check(name) && + PyUnicode_GET_SIZE(name) == 9 && + PyUnicode_CompareWithASCIIString(name, "__class__") == 0); } if (!skip) { @@ -5809,7 +5808,7 @@ PyObject *class_attr; if (class_str == NULL) { - class_str = PyString_FromString("__class__"); + class_str = PyUnicode_FromString("__class__"); if (class_str == NULL) return NULL; } Modified: python/branches/py3k-struni/Objects/unicodeobject.c ============================================================================== --- python/branches/py3k-struni/Objects/unicodeobject.c (original) +++ python/branches/py3k-struni/Objects/unicodeobject.c Sun Jun 10 11:51:05 2007 @@ -458,8 +458,10 @@ /* Copy the Unicode data into the new object */ if (u != NULL) { Py_UNICODE *p = unicode->str; - while ((*p++ = *u++)) - ; + while (size--) + *p++ = *u++; + /* Don't need to write trailing 0 because + that's already done by _PyUnicode_New */ } return (PyObject *)unicode; @@ -1184,6 +1186,16 @@ return v; } +char* +PyUnicode_AsString(PyObject *unicode) +{ + assert(PyUnicode_Check(unicode)); + unicode = _PyUnicode_AsDefaultEncodedString(unicode, NULL); + if (!unicode) + return NULL; + return PyString_AsString(unicode); +} + Py_UNICODE *PyUnicode_AsUnicode(PyObject *unicode) { if (!PyUnicode_Check(unicode)) { @@ -3247,7 +3259,7 @@ goto onError; } } - if (p - PyUnicode_AS_UNICODE(v) < PyString_GET_SIZE(v)) + if (p - PyUnicode_AS_UNICODE(v) < PyUnicode_GET_SIZE(v)) if (_PyUnicode_Resize(&v, p - PyUnicode_AS_UNICODE(v)) < 0) goto onError; Py_XDECREF(errorHandler); @@ -5861,6 +5873,24 @@ return -1; } +int +PyUnicode_CompareWithASCIIString(PyObject* uni, const char* str) +{ + int i; + Py_UNICODE *id; + assert(PyUnicode_Check(uni)); + id = PyUnicode_AS_UNICODE(uni); + /* Compare Unicode string and source character set string */ + for (i = 0; id[i] && str[i]; i++) + if (id[i] != str[i]) + return ((int)id[i] < (int)str[i]) ? -1 : 1; + if (id[i]) + return 1; /* uni is longer */ + if (str[i]) + return -1; /* str is longer */ + return 0; +} + PyObject *PyUnicode_RichCompare(PyObject *left, PyObject *right, int op) @@ -8671,7 +8701,13 @@ return; } } + /* It might be that the GetItem call fails even + though the key is present in the dictionary, + namely when this happens during a stack overflow. */ + Py_ALLOW_RECURSION t = PyDict_GetItem(interned, (PyObject *)s); + Py_END_ALLOW_RECURSION + if (t) { Py_INCREF(t); Py_DECREF(*p); @@ -8679,10 +8715,13 @@ return; } + PyThreadState_GET()->recursion_critical = 1; if (PyDict_SetItem(interned, (PyObject *)s, (PyObject *)s) < 0) { PyErr_Clear(); + PyThreadState_GET()->recursion_critical = 0; return; } + PyThreadState_GET()->recursion_critical = 0; /* The two references in interned are not counted by refcnt. The deallocator will take care of this */ s->ob_refcnt -= 2; @@ -8879,6 +8918,58 @@ return (PyObject *)it; } +size_t +Py_UNICODE_strlen(const Py_UNICODE *u) +{ + int res = 0; + while(*u++) + res++; + return res; +} + +Py_UNICODE* +Py_UNICODE_strcpy(Py_UNICODE *s1, const Py_UNICODE *s2) +{ + Py_UNICODE *u = s1; + while ((*u++ = *s2++)); + return s1; +} + +Py_UNICODE* +Py_UNICODE_strncpy(Py_UNICODE *s1, const Py_UNICODE *s2, size_t n) +{ + Py_UNICODE *u = s1; + while ((*u++ = *s2++)) + if (n-- == 0) + break; + return s1; +} + +int +Py_UNICODE_strcmp(const Py_UNICODE *s1, const Py_UNICODE *s2) +{ + while (*s1 && *s2 && *s1 == *s2) + s1++, s2++; + if (*s1 && *s2) + return (*s1 < *s2) ? -1 : +1; + if (*s1) + return 1; + if (*s2) + return -1; + return 0; +} + +Py_UNICODE* +Py_UNICODE_strchr(const Py_UNICODE *s, Py_UNICODE c) +{ + const Py_UNICODE *p; + for (p = s; *p; p++) + if (*p == c) + return (Py_UNICODE*)p; + return NULL; +} + + #ifdef __cplusplus } #endif Modified: python/branches/py3k-struni/Parser/tokenizer.c ============================================================================== --- python/branches/py3k-struni/Parser/tokenizer.c (original) +++ python/branches/py3k-struni/Parser/tokenizer.c Sun Jun 10 11:51:05 2007 @@ -18,6 +18,17 @@ #include "abstract.h" #endif /* PGEN */ +#define is_potential_identifier_start(c) (\ + (c >= 'a' && c <= 'z')\ + || (c >= 'A' && c <= 'Z')\ + || c == '_') + +#define is_potential_identifier_char(c) (\ + (c >= 'a' && c <= 'z')\ + || (c >= 'A' && c <= 'Z')\ + || (c >= '0' && c <= '9')\ + || c == '_') + extern char *PyOS_Readline(FILE *, FILE *, char *); /* Return malloc'ed string including trailing \n; empty malloc'ed string for EOF; @@ -1209,7 +1220,7 @@ } /* Identifier (most frequent token!) */ - if (isalpha(c) || c == '_') { + if (is_potential_identifier_start(c)) { /* Process r"", u"" and ur"" */ switch (c) { case 'r': @@ -1227,7 +1238,7 @@ goto letter_quote; break; } - while (isalnum(c) || c == '_') { + while (is_potential_identifier_char(c)) { c = tok_nextc(tok); } tok_backup(tok, c); Modified: python/branches/py3k-struni/Python/Python-ast.c ============================================================================== --- python/branches/py3k-struni/Python/Python-ast.c (original) +++ python/branches/py3k-struni/Python/Python-ast.c Sun Jun 10 11:51:05 2007 @@ -3280,3 +3280,5 @@ init_types(); return ast2obj_mod(t); } + + Modified: python/branches/py3k-struni/Python/ast.c ============================================================================== --- python/branches/py3k-struni/Python/ast.c (original) +++ python/branches/py3k-struni/Python/ast.c Sun Jun 10 11:51:05 2007 @@ -48,7 +48,8 @@ static identifier new_identifier(const char* n, PyArena *arena) { - PyObject* id = PyString_InternFromString(n); + PyObject* id = PyUnicode_DecodeUTF8(n, strlen(n), NULL); + PyUnicode_InternInPlace(&id); PyArena_AddPyObject(arena, id); return id; } @@ -334,12 +335,10 @@ static int forbidden_name(expr_ty e, const node *n) { - const char *id; const char **p; - assert(PyString_Check(e->v.Name.id)); - id = PyString_AS_STRING(e->v.Name.id); + assert(PyUnicode_Check(e->v.Name.id)); for (p = FORBIDDEN; *p; p++) { - if (strcmp(*p, id) == 0) { + if (PyUnicode_CompareWithASCIIString(e->v.Name.id, *p) == 0) { ast_error(n, "assignment to keyword"); return 1; } @@ -375,7 +374,7 @@ switch (e->kind) { case Attribute_kind: if (ctx == Store && - !strcmp(PyString_AS_STRING(e->v.Attribute.attr), "None")) { + !PyUnicode_CompareWithASCIIString(e->v.Attribute.attr, "None")) { return ast_error(n, "assignment to None"); } e->v.Attribute.ctx = ctx; @@ -2235,6 +2234,7 @@ int i; size_t len; char *s; + PyObject *uni; len = 0; for (i = 0; i < NCH(n); i += 2) @@ -2255,13 +2255,20 @@ } --s; *s = '\0'; - PyString_InternInPlace(&str); + uni = PyUnicode_DecodeUTF8(PyString_AS_STRING(str), + PyString_GET_SIZE(str), + NULL); + Py_DECREF(str); + if (!uni) + return NULL; + str = uni; + PyUnicode_InternInPlace(&str); PyArena_AddPyObject(c->c_arena, str); return alias(str, NULL, c->c_arena); } break; case STAR: - str = PyString_InternFromString("*"); + str = PyUnicode_InternFromString("*"); PyArena_AddPyObject(c->c_arena, str); return alias(str, NULL, c->c_arena); default: Modified: python/branches/py3k-struni/Python/bltinmodule.c ============================================================================== --- python/branches/py3k-struni/Python/bltinmodule.c (original) +++ python/branches/py3k-struni/Python/bltinmodule.c Sun Jun 10 11:51:05 2007 @@ -48,7 +48,7 @@ } func = PyTuple_GET_ITEM(args, 0); /* Better be callable */ name = PyTuple_GET_ITEM(args, 1); - if (!PyString_Check(name)) { + if ((!PyString_Check(name) && !PyUnicode_Check(name))) { PyErr_SetString(PyExc_TypeError, "__build_class__: name is not a string"); return NULL; @@ -835,20 +835,23 @@ static PyObject * builtin_getattr(PyObject *self, PyObject *args) { - PyObject *v, *result, *dflt = NULL; + PyObject *v, *result, *dflt = NULL, *release = NULL; PyObject *name; if (!PyArg_UnpackTuple(args, "getattr", 2, 3, &v, &name, &dflt)) return NULL; - if (PyUnicode_Check(name)) { - name = _PyUnicode_AsDefaultEncodedString(name, NULL); - if (name == NULL) + + if (PyString_Check(name)) { + release = PyString_AsDecodedObject(name, NULL, NULL); + if (!release) return NULL; + name = release; } - if (!PyString_Check(name)) { + if (!PyUnicode_Check(name)) { PyErr_SetString(PyExc_TypeError, "getattr(): attribute name must be string"); + Py_XDECREF(release); return NULL; } result = PyObject_GetAttr(v, name); @@ -859,6 +862,7 @@ Py_INCREF(dflt); result = dflt; } + Py_XDECREF(release); return result; } @@ -894,13 +898,7 @@ if (!PyArg_UnpackTuple(args, "hasattr", 2, 2, &v, &name)) return NULL; - if (PyUnicode_Check(name)) { - name = _PyUnicode_AsDefaultEncodedString(name, NULL); - if (name == NULL) - return NULL; - } - - if (!PyString_Check(name)) { + if (!PyUnicode_Check(name)) { PyErr_SetString(PyExc_TypeError, "hasattr(): attribute name must be string"); return NULL; Modified: python/branches/py3k-struni/Python/ceval.c ============================================================================== --- python/branches/py3k-struni/Python/ceval.c (original) +++ python/branches/py3k-struni/Python/ceval.c Sun Jun 10 11:51:05 2007 @@ -454,8 +454,19 @@ return -1; } #endif + if (tstate->recursion_critical) + /* Somebody asked that we don't check for recursion. */ + return 0; + if (tstate->overflowed) { + if (tstate->recursion_depth > recursion_limit + 50) { + /* Overflowing while handling an overflow. Give up. */ + Py_FatalError("Cannot recover from stack overflow."); + } + return 0; + } if (tstate->recursion_depth > recursion_limit) { --tstate->recursion_depth; + tstate->overflowed = 1; PyErr_Format(PyExc_RuntimeError, "maximum recursion depth exceeded%s", where); @@ -2759,7 +2770,7 @@ vars into frame. This isn't too efficient right now. */ if (PyTuple_GET_SIZE(co->co_cellvars)) { int i, j, nargs, found; - char *cellname, *argname; + Py_UNICODE *cellname, *argname; PyObject *c; nargs = co->co_argcount; @@ -2776,13 +2787,13 @@ list so that we can march over it more efficiently? */ for (i = 0; i < PyTuple_GET_SIZE(co->co_cellvars); ++i) { - cellname = PyString_AS_STRING( + cellname = PyUnicode_AS_UNICODE( PyTuple_GET_ITEM(co->co_cellvars, i)); found = 0; for (j = 0; j < nargs; j++) { - argname = PyString_AS_STRING( + argname = PyUnicode_AS_UNICODE( PyTuple_GET_ITEM(co->co_varnames, j)); - if (strcmp(cellname, argname) == 0) { + if (Py_UNICODE_strcmp(cellname, argname) == 0) { c = PyCell_New(GETLOCAL(j)); if (c == NULL) goto fail; @@ -3428,7 +3439,7 @@ if (PyMethod_Check(func)) return PyEval_GetFuncName(PyMethod_GET_FUNCTION(func)); else if (PyFunction_Check(func)) - return PyString_AsString(((PyFunctionObject*)func)->func_name); + return PyUnicode_AsString(((PyFunctionObject*)func)->func_name); else if (PyCFunction_Check(func)) return ((PyCFunctionObject*)func)->m_ml->ml_name; else @@ -4052,8 +4063,8 @@ break; } if (skip_leading_underscores && - PyString_Check(name) && - PyString_AS_STRING(name)[0] == '_') + PyUnicode_Check(name) && + PyUnicode_AS_UNICODE(name)[0] == '_') { Py_DECREF(name); continue; Modified: python/branches/py3k-struni/Python/compile.c ============================================================================== --- python/branches/py3k-struni/Python/compile.c (original) +++ python/branches/py3k-struni/Python/compile.c Sun Jun 10 11:51:05 2007 @@ -194,16 +194,16 @@ { /* Name mangling: __private becomes _classname__private. This is independent from how the name is used. */ - const char *p, *name = PyString_AsString(ident); - char *buffer; + const Py_UNICODE *p, *name = PyUnicode_AS_UNICODE(ident); + Py_UNICODE *buffer; size_t nlen, plen; - if (privateobj == NULL || !PyString_Check(privateobj) || + if (privateobj == NULL || !PyUnicode_Check(privateobj) || name == NULL || name[0] != '_' || name[1] != '_') { Py_INCREF(ident); return ident; } - p = PyString_AsString(privateobj); - nlen = strlen(name); + p = PyUnicode_AS_UNICODE(privateobj); + nlen = Py_UNICODE_strlen(name); /* Don't mangle __id__ or names with dots. The only time a name with a dot can occur is when @@ -214,26 +214,26 @@ mangling of the module name, e.g. __M.X. */ if ((name[nlen-1] == '_' && name[nlen-2] == '_') - || strchr(name, '.')) { + || Py_UNICODE_strchr(name, '.')) { Py_INCREF(ident); return ident; /* Don't mangle __whatever__ */ } /* Strip leading underscores from class name */ while (*p == '_') p++; - if (*p == '\0') { + if (*p == 0) { Py_INCREF(ident); return ident; /* Don't mangle if class is just underscores */ } - plen = strlen(p); - ident = PyString_FromStringAndSize(NULL, 1 + nlen + plen); + plen = Py_UNICODE_strlen(p); + ident = PyUnicode_FromStringAndSize(NULL, 1 + nlen + plen); if (!ident) return 0; /* ident = "_" + p[:plen] + name # i.e. 1+plen+nlen bytes */ - buffer = PyString_AS_STRING(ident); + buffer = PyUnicode_AS_UNICODE(ident); buffer[0] = '_'; - strncpy(buffer+1, p, plen); - strcpy(buffer+1+plen, name); + Py_UNICODE_strncpy(buffer+1, p, plen); + Py_UNICODE_strcpy(buffer+1+plen, name); return ident; } @@ -259,7 +259,7 @@ int merged; if (!__doc__) { - __doc__ = PyString_InternFromString("__doc__"); + __doc__ = PyUnicode_InternFromString("__doc__"); if (!__doc__) return NULL; } @@ -551,7 +551,7 @@ { char tmpname[256]; PyOS_snprintf(tmpname, sizeof(tmpname), "_[%d]", ++c->u->u_tmpname); - return PyString_FromString(tmpname); + return PyUnicode_FromString(tmpname); } /* Allocate a new block and return a pointer to it. @@ -1143,7 +1143,7 @@ int addNone = 1; static PyObject *module; if (!module) { - module = PyString_FromString(""); + module = PyUnicode_FromString(""); if (!module) return NULL; } @@ -1362,7 +1362,7 @@ goto error; if (!return_str) { - return_str = PyString_InternFromString("return"); + return_str = PyUnicode_InternFromString("return"); if (!return_str) goto error; } @@ -1488,12 +1488,12 @@ /* initialize statics */ if (build_class == NULL) { - build_class = PyString_FromString("__build_class__"); + build_class = PyUnicode_FromString("__build_class__"); if (build_class == NULL) return 0; } if (locals == NULL) { - locals = PyString_FromString("__locals__"); + locals = PyUnicode_FromString("__locals__"); if (locals == NULL) return 0; } @@ -1533,7 +1533,7 @@ /* ... and store it into f_locals */ ADDOP_IN_SCOPE(c, STORE_LOCALS); /* load __name__ ... */ - str = PyString_InternFromString("__name__"); + str = PyUnicode_InternFromString("__name__"); if (!str || !compiler_nameop(c, str, Load)) { Py_XDECREF(str); compiler_exit_scope(c); @@ -1541,7 +1541,7 @@ } Py_DECREF(str); /* ... and store it as __module__ */ - str = PyString_InternFromString("__module__"); + str = PyUnicode_InternFromString("__module__"); if (!str || !compiler_nameop(c, str, Store)) { Py_XDECREF(str); compiler_exit_scope(c); @@ -1627,7 +1627,7 @@ assert(e->kind == Lambda_kind); if (!name) { - name = PyString_InternFromString(""); + name = PyUnicode_InternFromString(""); if (!name) return 0; } @@ -2027,17 +2027,17 @@ If there is a dot in name, we need to split it and emit a LOAD_ATTR for each name. */ - const char *src = PyString_AS_STRING(name); - const char *dot = strchr(src, '.'); + const Py_UNICODE *src = PyUnicode_AS_UNICODE(name); + const Py_UNICODE *dot = Py_UNICODE_strchr(src, '.'); if (dot) { /* Consume the base module name to get the first attribute */ src = dot + 1; while (dot) { /* NB src is only defined when dot != NULL */ PyObject *attr; - dot = strchr(src, '.'); - attr = PyString_FromStringAndSize(src, - dot ? dot - src : strlen(src)); + dot = Py_UNICODE_strchr(src, '.'); + attr = PyUnicode_FromUnicode(src, + dot ? dot - src : Py_UNICODE_strlen(src)); if (!attr) return -1; ADDOP_O(c, LOAD_ATTR, attr, names); @@ -2081,11 +2081,11 @@ } else { identifier tmp = alias->name; - const char *base = PyString_AS_STRING(alias->name); - char *dot = strchr(base, '.'); + const Py_UNICODE *base = PyUnicode_AS_UNICODE(alias->name); + Py_UNICODE *dot = Py_UNICODE_strchr(base, '.'); if (dot) - tmp = PyString_FromStringAndSize(base, - dot - base); + tmp = PyUnicode_FromUnicode(base, + dot - base); r = compiler_nameop(c, tmp, Store); if (dot) { Py_DECREF(tmp); @@ -2122,8 +2122,8 @@ } if (s->lineno > c->c_future->ff_lineno) { - if (!strcmp(PyString_AS_STRING(s->v.ImportFrom.module), - "__future__")) { + if (!PyUnicode_CompareWithASCIIString(s->v.ImportFrom.module, + "__future__")) { Py_DECREF(level); Py_DECREF(names); return compiler_error(c, @@ -2142,7 +2142,7 @@ alias_ty alias = (alias_ty)asdl_seq_GET(s->v.ImportFrom.names, i); identifier store_name; - if (i == 0 && *PyString_AS_STRING(alias->name) == '*') { + if (i == 0 && *PyUnicode_AS_UNICODE(alias->name) == '*') { assert(n == 1); ADDOP(c, IMPORT_STAR); return 1; @@ -2172,7 +2172,7 @@ if (Py_OptimizeFlag) return 1; if (assertion_error == NULL) { - assertion_error = PyString_FromString("AssertionError"); + assertion_error = PyUnicode_FromString("AssertionError"); if (assertion_error == NULL) return 0; } @@ -2417,7 +2417,7 @@ /* First check for assignment to __debug__. Param? */ if ((ctx == Store || ctx == AugStore || ctx == Del) - && !strcmp(PyString_AS_STRING(name), "__debug__")) { + && !PyUnicode_CompareWithASCIIString(name, "__debug__")) { return compiler_error(c, "can not assign to __debug__"); } @@ -2455,7 +2455,7 @@ } /* XXX Leave assert here, but handle __doc__ and the like better */ - assert(scope || PyString_AS_STRING(name)[0] == '_'); + assert(scope || PyUnicode_AS_UNICODE(name)[0] == '_'); switch (optype) { case OP_DEREF: @@ -2889,7 +2889,7 @@ { static identifier name; if (!name) { - name = PyString_FromString(""); + name = PyUnicode_FromString(""); if (!name) return 0; } @@ -2904,7 +2904,7 @@ { static identifier name; if (!name) { - name = PyString_FromString(""); + name = PyUnicode_FromString(""); if (!name) return 0; } @@ -2919,7 +2919,7 @@ { static identifier name; if (!name) { - name = PyString_FromString(""); + name = PyUnicode_FromString(""); if (!name) return 0; } @@ -2957,8 +2957,8 @@ case Name_kind: /* __debug__ is not assignable, so we can optimize * it away in if and while statements */ - if (strcmp(PyString_AS_STRING(e->v.Name.id), - "__debug__") == 0) + if (PyUnicode_CompareWithASCIIString(e->v.Name.id, + "__debug__") == 0) return ! Py_OptimizeFlag; /* fall through */ default: @@ -2999,12 +2999,12 @@ assert(s->kind == With_kind); if (!enter_attr) { - enter_attr = PyString_InternFromString("__enter__"); + enter_attr = PyUnicode_InternFromString("__enter__"); if (!enter_attr) return 0; } if (!exit_attr) { - exit_attr = PyString_InternFromString("__exit__"); + exit_attr = PyUnicode_InternFromString("__exit__"); if (!exit_attr) return 0; } Modified: python/branches/py3k-struni/Python/future.c ============================================================================== --- python/branches/py3k-struni/Python/future.c (original) +++ python/branches/py3k-struni/Python/future.c Sun Jun 10 11:51:05 2007 @@ -55,7 +55,7 @@ static PyObject *future; if (!future) { - future = PyString_InternFromString("__future__"); + future = PyUnicode_InternFromString("__future__"); if (!future) return 0; } Modified: python/branches/py3k-struni/Python/import.c ============================================================================== --- python/branches/py3k-struni/Python/import.c (original) +++ python/branches/py3k-struni/Python/import.c Sun Jun 10 11:51:05 2007 @@ -1920,7 +1920,7 @@ if (m == NULL) goto err_return; d = PyModule_GetDict(m); - s = PyString_InternFromString(name); + s = PyUnicode_InternFromString(name); if (s == NULL) goto err_return; err = PyDict_SetItemString(d, "__path__", s); @@ -1949,7 +1949,7 @@ PyObject *pname; PyObject *result; - pname = PyString_FromString(name); + pname = PyUnicode_FromString(name); if (pname == NULL) return NULL; result = PyImport_Import(pname); @@ -2084,12 +2084,12 @@ return Py_None; if (namestr == NULL) { - namestr = PyString_InternFromString("__name__"); + namestr = PyUnicode_InternFromString("__name__"); if (namestr == NULL) return NULL; } if (pathstr == NULL) { - pathstr = PyString_InternFromString("__path__"); + pathstr = PyUnicode_InternFromString("__path__"); if (pathstr == NULL) return NULL; } @@ -2097,9 +2097,18 @@ *buf = '\0'; *p_buflen = 0; modname = PyDict_GetItem(globals, namestr); - if (modname == NULL || !PyString_Check(modname)) + if (modname == NULL || (!PyString_Check(modname) && !PyUnicode_Check(modname))) return Py_None; + if (PyUnicode_Check(modname)) { + /* XXX need to support Unicode better */ + modname = _PyUnicode_AsDefaultEncodedString(modname, NULL); + if (!modname) { + PyErr_Clear(); + return NULL; + } + } + modpath = PyDict_GetItem(globals, pathstr); if (modpath != NULL) { Py_ssize_t len = PyString_GET_SIZE(modname); @@ -2254,13 +2263,23 @@ } return 0; } - if (!PyString_Check(item)) { + if (PyString_Check(item)) { + /* XXX there shouldn't be any str8 objects here */ + PyObject *uni = PyUnicode_DecodeASCII(PyString_AsString(item), + PyString_Size(item), + "strict"); + Py_DECREF(item); + if (!uni) + return 0; + item = uni; + } + if (!PyUnicode_Check(item)) { PyErr_SetString(PyExc_TypeError, - "Item in ``from list'' not a string"); + "Item in ``from list'' not a unicode string"); Py_DECREF(item); return 0; } - if (PyString_AS_STRING(item)[0] == '*') { + if (PyUnicode_AS_UNICODE(item)[0] == '*') { PyObject *all; Py_DECREF(item); /* See if the package defines __all__ */ @@ -2279,9 +2298,23 @@ } hasit = PyObject_HasAttr(mod, item); if (!hasit) { - char *subname = PyString_AS_STRING(item); + PyObject *item8; + char *subname; PyObject *submod; char *p; + if (!Py_FileSystemDefaultEncoding) { + item8 = PyUnicode_EncodeASCII(PyUnicode_AsUnicode(item), + PyUnicode_GetSize(item), + "strict"); + } else { + item8 = PyUnicode_AsEncodedObject(item, + Py_FileSystemDefaultEncoding, "strict"); + } + if (!item8) { + PyErr_SetString(PyExc_ValueError, "Cannot encode path item"); + return 0; + } + subname = PyBytes_AsString(item8); if (buflen + strlen(subname) >= MAXPATHLEN) { PyErr_SetString(PyExc_ValueError, "Module name too long"); @@ -2292,6 +2325,7 @@ *p++ = '.'; strcpy(p, subname); submod = import_submodule(mod, subname, buf); + Py_DECREF(item8); Py_XDECREF(submod); if (submod == NULL) { Py_DECREF(item); @@ -2515,10 +2549,10 @@ /* Initialize constant string objects */ if (silly_list == NULL) { - import_str = PyString_InternFromString("__import__"); + import_str = PyUnicode_InternFromString("__import__"); if (import_str == NULL) return NULL; - builtins_str = PyString_InternFromString("__builtins__"); + builtins_str = PyUnicode_InternFromString("__builtins__"); if (builtins_str == NULL) return NULL; silly_list = Py_BuildValue("[s]", "__doc__"); Modified: python/branches/py3k-struni/Python/modsupport.c ============================================================================== --- python/branches/py3k-struni/Python/modsupport.c (original) +++ python/branches/py3k-struni/Python/modsupport.c Sun Jun 10 11:51:05 2007 @@ -65,7 +65,7 @@ return NULL; d = PyModule_GetDict(m); if (methods != NULL) { - n = PyString_FromString(name); + n = PyUnicode_FromString(name); if (n == NULL) return NULL; for (ml = methods; ml->ml_name != NULL; ml++) { @@ -689,5 +689,5 @@ int PyModule_AddStringConstant(PyObject *m, const char *name, const char *value) { - return PyModule_AddObject(m, name, PyString_FromString(value)); + return PyModule_AddObject(m, name, PyUnicode_FromString(value)); } Modified: python/branches/py3k-struni/Python/pystate.c ============================================================================== --- python/branches/py3k-struni/Python/pystate.c (original) +++ python/branches/py3k-struni/Python/pystate.c Sun Jun 10 11:51:05 2007 @@ -167,6 +167,8 @@ tstate->frame = NULL; tstate->recursion_depth = 0; + tstate->overflowed = 0; + tstate->recursion_critical = 0; tstate->tracing = 0; tstate->use_tracing = 0; tstate->tick_counter = 0; Modified: python/branches/py3k-struni/Python/pythonrun.c ============================================================================== --- python/branches/py3k-struni/Python/pythonrun.c (original) +++ python/branches/py3k-struni/Python/pythonrun.c Sun Jun 10 11:51:05 2007 @@ -1133,6 +1133,8 @@ PyObject *f = PySys_GetObject("stderr"); Py_INCREF(value); if (f == NULL) + _PyObject_Dump(value); + if (f == NULL) fprintf(stderr, "lost sys.stderr\n"); else { fflush(stdout); Modified: python/branches/py3k-struni/Python/symtable.c ============================================================================== --- python/branches/py3k-struni/Python/symtable.c (original) +++ python/branches/py3k-struni/Python/symtable.c Sun Jun 10 11:51:05 2007 @@ -92,7 +92,7 @@ PyOS_snprintf(buf, sizeof(buf), "", - PyString_AS_STRING(ste->ste_name), + PyUnicode_AsString(ste->ste_name), PyInt_AS_LONG(ste->ste_id), ste->ste_lineno); return PyUnicode_FromString(buf); } @@ -190,7 +190,7 @@ listcomp = NULL, setcomp = NULL; #define GET_IDENTIFIER(VAR) \ - ((VAR) ? (VAR) : ((VAR) = PyString_InternFromString(# VAR))) + ((VAR) ? (VAR) : ((VAR) = PyUnicode_InternFromString(# VAR))) #define DUPLICATE_ARGUMENT \ "duplicate argument '%s' in function definition" @@ -390,13 +390,13 @@ if (flags & DEF_PARAM) { PyErr_Format(PyExc_SyntaxError, "name '%s' is parameter and global", - PyString_AS_STRING(name)); + PyUnicode_AsString(name)); return 0; } if (flags & DEF_NONLOCAL) { PyErr_Format(PyExc_SyntaxError, "name '%s' is nonlocal and global", - PyString_AS_STRING(name)); + PyUnicode_AsString(name)); return 0; } SET_SCOPE(scopes, name, GLOBAL_EXPLICIT); @@ -410,7 +410,7 @@ if (flags & DEF_PARAM) { PyErr_Format(PyExc_SyntaxError, "name '%s' is parameter and nonlocal", - PyString_AS_STRING(name)); + PyUnicode_AsString(name)); return 0; } if (!bound) { @@ -421,7 +421,7 @@ if (!PySet_Contains(bound, name)) { PyErr_Format(PyExc_SyntaxError, "no binding for nonlocal '%s' found", - PyString_AS_STRING(name)); + PyUnicode_AsString(name)); return 0; } @@ -524,7 +524,7 @@ PyOS_snprintf(buf, sizeof(buf), "import * is not allowed in function '%.100s' " "because it is %s", - PyString_AS_STRING(ste->ste_name), trailer); + PyUnicode_AsString(ste->ste_name), trailer); break; } @@ -984,7 +984,7 @@ PyOS_snprintf(tmpname, sizeof(tmpname), "_[%d]", ++st->st_cur->ste_tmpname); - tmp = PyString_InternFromString(tmpname); + tmp = PyUnicode_InternFromString(tmpname); if (!tmp) return 0; if (!symtable_add_def(st, tmp, DEF_LOCAL)) @@ -1129,7 +1129,7 @@ asdl_seq *seq = s->v.Global.names; for (i = 0; i < asdl_seq_LEN(seq); i++) { identifier name = (identifier)asdl_seq_GET(seq, i); - char *c_name = PyString_AS_STRING(name); + char *c_name = PyUnicode_AsString(name); long cur = symtable_lookup(st, name); if (cur < 0) return 0; @@ -1156,7 +1156,7 @@ asdl_seq *seq = s->v.Nonlocal.names; for (i = 0; i < asdl_seq_LEN(seq); i++) { identifier name = (identifier)asdl_seq_GET(seq, i); - char *c_name = PyString_AS_STRING(name); + char *c_name = PyUnicode_AsString(name); long cur = symtable_lookup(st, name); if (cur < 0) return 0; @@ -1316,7 +1316,7 @@ static int symtable_implicit_arg(struct symtable *st, int pos) { - PyObject *id = PyString_FromFormat(".%d", pos); + PyObject *id = PyUnicode_FromFormat(".%d", pos); if (id == NULL) return 0; if (!symtable_add_def(st, id, DEF_PARAM)) { @@ -1425,10 +1425,10 @@ */ PyObject *store_name; PyObject *name = (a->asname == NULL) ? a->name : a->asname; - const char *base = PyString_AS_STRING(name); - char *dot = strchr(base, '.'); + const Py_UNICODE *base = PyUnicode_AS_UNICODE(name); + Py_UNICODE *dot = Py_UNICODE_strchr(base, '.'); if (dot) { - store_name = PyString_FromStringAndSize(base, dot - base); + store_name = PyUnicode_FromUnicode(base, dot - base); if (!store_name) return 0; } @@ -1436,7 +1436,7 @@ store_name = name; Py_INCREF(store_name); } - if (strcmp(PyString_AS_STRING(name), "*")) { + if (PyUnicode_CompareWithASCIIString(name, "*")) { int r = symtable_add_def(st, store_name, DEF_IMPORT); Py_DECREF(store_name); return r; Modified: python/branches/py3k-struni/Python/sysmodule.c ============================================================================== --- python/branches/py3k-struni/Python/sysmodule.c (original) +++ python/branches/py3k-struni/Python/sysmodule.c Sun Jun 10 11:51:05 2007 @@ -280,7 +280,7 @@ int i; for (i = 0; i < 7; ++i) { if (whatstrings[i] == NULL) { - name = PyString_InternFromString(whatnames[i]); + name = PyUnicode_InternFromString(whatnames[i]); if (name == NULL) return -1; whatstrings[i] = name; @@ -801,7 +801,7 @@ if (list == NULL) return NULL; for (i = 0; PyImport_Inittab[i].name != NULL; i++) { - PyObject *name = PyString_FromString( + PyObject *name = PyUnicode_FromString( PyImport_Inittab[i].name); if (name == NULL) break; From nnorwitz at gmail.com Sun Jun 10 15:11:07 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sun, 10 Jun 2007 09:11:07 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures refleak (1) Message-ID: <20070610131107.GA16510@python.psfb.org> test_collections leaked [46, 46, 46] references, sum=138 From python-3000-checkins at python.org Sun Jun 10 17:29:58 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Sun, 10 Jun 2007 17:29:58 +0200 (CEST) Subject: [Python-3000-checkins] r55852 - python/branches/p3yk/Lib/test/test_collections.py Message-ID: <20070610152958.3E87C1E4011@bag.python.org> Author: guido.van.rossum Date: Sun Jun 10 17:29:51 2007 New Revision: 55852 Modified: python/branches/p3yk/Lib/test/test_collections.py Log: Add some more examples, e.g. generators and dict views. Modified: python/branches/p3yk/Lib/test/test_collections.py ============================================================================== --- python/branches/p3yk/Lib/test/test_collections.py (original) +++ python/branches/p3yk/Lib/test/test_collections.py Sun Jun 10 17:29:51 2007 @@ -96,6 +96,9 @@ # Check some iterables samples = [bytes(), str(), unicode(), tuple(), list(), set(), frozenset(), dict(), + dict().keys(), dict().items(), dict().values(), + (lambda: (yield))(), + (x for x in []), ] for x in samples: self.failUnless(isinstance(x, Iterable), repr(x)) @@ -121,30 +124,42 @@ samples = [iter(bytes()), iter(str()), iter(unicode()), iter(tuple()), iter(list()), iter(dict()), iter(set()), iter(frozenset()), + iter(dict().keys()), iter(dict().items()), + iter(dict().values()), + (lambda: (yield))(), + (x for x in []), ] for x in samples: self.failUnless(isinstance(x, Iterator), repr(x)) self.failUnless(issubclass(type(x), Iterator), repr(type(x))) def test_Sized(self): - non_samples = [None, 42, 3.14, 1j] + non_samples = [None, 42, 3.14, 1j, + (lambda: (yield))(), + (x for x in []), + ] for x in non_samples: self.failIf(isinstance(x, Sized), repr(x)) self.failIf(issubclass(type(x), Sized), repr(type(x))) samples = [bytes(), str(), unicode(), tuple(), list(), set(), frozenset(), dict(), + dict().keys(), dict().items(), dict().values(), ] for x in samples: self.failUnless(isinstance(x, Sized), repr(x)) self.failUnless(issubclass(type(x), Sized), repr(type(x))) def test_Container(self): - non_samples = [None, 42, 3.14, 1j] + non_samples = [None, 42, 3.14, 1j, + (lambda: (yield))(), + (x for x in []), + ] for x in non_samples: self.failIf(isinstance(x, Container), repr(x)) self.failIf(issubclass(type(x), Container), repr(type(x))) samples = [bytes(), str(), unicode(), tuple(), list(), set(), frozenset(), dict(), +## dict().keys(), dict().items(), dict().values(), ] for x in samples: self.failUnless(isinstance(x, Container), repr(x)) From python-3000-checkins at python.org Sun Jun 10 17:32:00 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Sun, 10 Jun 2007 17:32:00 +0200 (CEST) Subject: [Python-3000-checkins] r55853 - python/branches/p3yk/Lib/test/test_collections.py Message-ID: <20070610153200.3DC7E1E400B@bag.python.org> Author: guido.van.rossum Date: Sun Jun 10 17:31:59 2007 New Revision: 55853 Modified: python/branches/p3yk/Lib/test/test_collections.py Log: keys() and items() *are* containers -- just values() isn't. Modified: python/branches/p3yk/Lib/test/test_collections.py ============================================================================== --- python/branches/p3yk/Lib/test/test_collections.py (original) +++ python/branches/p3yk/Lib/test/test_collections.py Sun Jun 10 17:31:59 2007 @@ -159,7 +159,7 @@ self.failIf(issubclass(type(x), Container), repr(type(x))) samples = [bytes(), str(), unicode(), tuple(), list(), set(), frozenset(), dict(), -## dict().keys(), dict().items(), dict().values(), + dict().keys(), dict().items(), ] for x in samples: self.failUnless(isinstance(x, Container), repr(x)) From nnorwitz at gmail.com Sun Jun 10 19:06:18 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sun, 10 Jun 2007 10:06:18 -0700 Subject: [Python-3000-checkins] r55850 - in python/branches/py3k-struni: Include/ceval.h Include/pystate.h Include/stringobject.h Include/unicodeobject.h Lib/test/test_frozen.py Lib/test/test_new.py Lib/test/test_sys.py Modules/_codecsmodule.c Modules/_ho Message-ID: On 6/10/07, martin.v.loewis wrote: > Author: martin.v.loewis > Date: Sun Jun 10 11:51:05 2007 > New Revision: 55850 > > Modified: python/branches/py3k-struni/Modules/unicodedata.c > ============================================================================== > --- python/branches/py3k-struni/Modules/unicodedata.c (original) > +++ python/branches/py3k-struni/Modules/unicodedata.c Sun Jun 10 11:51:05 2007 > @@ -515,7 +515,7 @@ > /* Hangul Decomposition adds three characters in > a single step, so we need atleast that much room. */ > if (space < 3) { > - Py_ssize_t newsize = PyString_GET_SIZE(result) + 10; > + Py_ssize_t newsize = PyUnicode_GET_SIZE(result) + 10; > space += 10; > if (PyUnicode_Resize(&result, newsize) == -1) > return NULL; Martin, Is it a problem to add a constant value (10 in this case) to the new unicode object? Does the size of unicode (UCS-2 vs 4) matter? Does it matter if there are unicode escapes U+000...? Even if it doesn't matter in this specific example what are the cases where it does matter? (I'm remembering the block of code where we didn't allocate enough for U+000.... for ucs-4.) Thanks, n From python-3000-checkins at python.org Sun Jun 10 23:09:40 2007 From: python-3000-checkins at python.org (martin.v.loewis) Date: Sun, 10 Jun 2007 23:09:40 +0200 (CEST) Subject: [Python-3000-checkins] r55861 - python/branches/py3k-struni/Objects/classobject.c Message-ID: <20070610210940.E44BA1E4008@bag.python.org> Author: martin.v.loewis Date: Sun Jun 10 23:09:40 2007 New Revision: 55861 Modified: python/branches/py3k-struni/Objects/classobject.c Log: Fix getclassname. Fixes test_descrtut. Modified: python/branches/py3k-struni/Objects/classobject.c ============================================================================== --- python/branches/py3k-struni/Objects/classobject.c (original) +++ python/branches/py3k-struni/Objects/classobject.c Sun Jun 10 23:09:40 2007 @@ -313,8 +313,8 @@ PyErr_Clear(); return; } - if (PyString_Check(name)) { - strncpy(buf, PyString_AS_STRING(name), bufsize); + if (PyUnicode_Check(name)) { + strncpy(buf, PyUnicode_AsString(name), bufsize); buf[bufsize-1] = '\0'; } Py_DECREF(name); From python-3000-checkins at python.org Sun Jun 10 23:13:37 2007 From: python-3000-checkins at python.org (martin.v.loewis) Date: Sun, 10 Jun 2007 23:13:37 +0200 (CEST) Subject: [Python-3000-checkins] r55862 - python/branches/py3k-struni/Objects/typeobject.c Message-ID: <20070610211337.BB3E31E4008@bag.python.org> Author: martin.v.loewis Date: Sun Jun 10 23:13:34 2007 New Revision: 55862 Modified: python/branches/py3k-struni/Objects/typeobject.c Log: Expect unicode in class_name. Modified: python/branches/py3k-struni/Objects/typeobject.c ============================================================================== --- python/branches/py3k-struni/Objects/typeobject.c (original) +++ python/branches/py3k-struni/Objects/typeobject.c Sun Jun 10 23:13:34 2007 @@ -1010,7 +1010,7 @@ } if (name == NULL) return NULL; - if (!PyString_Check(name)) { + if (!PyUnicode_Check(name)) { Py_DECREF(name); return NULL; } @@ -1032,7 +1032,7 @@ o = class_name(o); PyErr_Format(PyExc_TypeError, "duplicate base class %s", - o ? PyString_AS_STRING(o) : "?"); + o ? PyUnicode_AsString(o) : "?"); Py_XDECREF(o); return -1; } @@ -1078,7 +1078,7 @@ while (PyDict_Next(set, &i, &k, &v) && (size_t)off < sizeof(buf)) { PyObject *name = class_name(k); off += PyOS_snprintf(buf + off, sizeof(buf) - off, " %s", - name ? PyString_AS_STRING(name) : "?"); + name ? PyUnicode_AsString(name) : "?"); Py_XDECREF(name); if (--n && (size_t)(off+1) < sizeof(buf)) { buf[off++] = ','; From python-3000-checkins at python.org Mon Jun 11 00:30:21 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Mon, 11 Jun 2007 00:30:21 +0200 (CEST) Subject: [Python-3000-checkins] r55864 - in python/branches/p3yk: Lib/CGIHTTPServer.py Lib/_strptime.py Lib/anydbm.py Lib/bsddb/__init__.py Lib/bsddb/dbshelve.py Lib/bsddb/dbtables.py Lib/bsddb/test/test_1413192.py Lib/bsddb/test/test_basics.py Lib/bsddb/test/test_env_close.py Lib/bsddb/test/test_sequence.py Lib/dbhash.py Lib/distutils/ccompiler.py Lib/distutils/cmd.py Lib/distutils/command/build_scripts.py Lib/distutils/command/install_scripts.py Lib/distutils/command/register.py Lib/distutils/dir_util.py Lib/dumbdbm.py Lib/encodings/uu_codec.py Lib/imputil.py Lib/mailbox.py Lib/mhlib.py Lib/os.py Lib/plat-atheos/IN.py Lib/plat-mac/bundlebuilder.py Lib/plat-mac/macostools.py Lib/plat-sunos5/IN.py Lib/plat-sunos5/STROPTS.py Lib/plat-unixware7/IN.py Lib/plat-unixware7/STROPTS.py Lib/pty.py Lib/stat.py Lib/tarfile.py Lib/tempfile.py Lib/test/output/test_tokenize Lib/test/test_builtin.py Lib/test/test_compile.py Lib/test/test_descr.py Lib/test/test_dumbdbm.py Lib/test/test_format.py Lib/test/test_grammar.py Lib/test/test_hexoct.py Lib/test/test_long.py Lib/test/test_strptime.py Lib/test/test_subprocess.py Lib/test/test_tarfile.py Lib/test/test_tempfile.py Lib/test/test_unicode_file.py Lib/test/test_uu.py Lib/test/test_xmlrpc.py Lib/test/test_zipimport.py Lib/test/tokenize_tests.txt Lib/tokenize.py Lib/uu.py Misc/NEWS Objects/longobject.c Objects/stringobject.c Objects/unicodeobject.c Python/ast.c Python/mystrtoul.c setup.py Message-ID: <20070610223021.3C4591E4008@bag.python.org> Author: georg.brandl Date: Mon Jun 11 00:29:40 2007 New Revision: 55864 Modified: python/branches/p3yk/Lib/CGIHTTPServer.py python/branches/p3yk/Lib/_strptime.py python/branches/p3yk/Lib/anydbm.py python/branches/p3yk/Lib/bsddb/__init__.py python/branches/p3yk/Lib/bsddb/dbshelve.py python/branches/p3yk/Lib/bsddb/dbtables.py python/branches/p3yk/Lib/bsddb/test/test_1413192.py python/branches/p3yk/Lib/bsddb/test/test_basics.py python/branches/p3yk/Lib/bsddb/test/test_env_close.py python/branches/p3yk/Lib/bsddb/test/test_sequence.py python/branches/p3yk/Lib/dbhash.py python/branches/p3yk/Lib/distutils/ccompiler.py python/branches/p3yk/Lib/distutils/cmd.py python/branches/p3yk/Lib/distutils/command/build_scripts.py python/branches/p3yk/Lib/distutils/command/install_scripts.py python/branches/p3yk/Lib/distutils/command/register.py python/branches/p3yk/Lib/distutils/dir_util.py python/branches/p3yk/Lib/dumbdbm.py python/branches/p3yk/Lib/encodings/uu_codec.py python/branches/p3yk/Lib/imputil.py python/branches/p3yk/Lib/mailbox.py python/branches/p3yk/Lib/mhlib.py python/branches/p3yk/Lib/os.py python/branches/p3yk/Lib/plat-atheos/IN.py python/branches/p3yk/Lib/plat-mac/bundlebuilder.py python/branches/p3yk/Lib/plat-mac/macostools.py python/branches/p3yk/Lib/plat-sunos5/IN.py python/branches/p3yk/Lib/plat-sunos5/STROPTS.py python/branches/p3yk/Lib/plat-unixware7/IN.py python/branches/p3yk/Lib/plat-unixware7/STROPTS.py python/branches/p3yk/Lib/pty.py python/branches/p3yk/Lib/stat.py python/branches/p3yk/Lib/tarfile.py python/branches/p3yk/Lib/tempfile.py python/branches/p3yk/Lib/test/output/test_tokenize python/branches/p3yk/Lib/test/test_builtin.py python/branches/p3yk/Lib/test/test_compile.py python/branches/p3yk/Lib/test/test_descr.py python/branches/p3yk/Lib/test/test_dumbdbm.py python/branches/p3yk/Lib/test/test_format.py python/branches/p3yk/Lib/test/test_grammar.py python/branches/p3yk/Lib/test/test_hexoct.py python/branches/p3yk/Lib/test/test_long.py python/branches/p3yk/Lib/test/test_strptime.py python/branches/p3yk/Lib/test/test_subprocess.py python/branches/p3yk/Lib/test/test_tarfile.py python/branches/p3yk/Lib/test/test_tempfile.py python/branches/p3yk/Lib/test/test_unicode_file.py python/branches/p3yk/Lib/test/test_uu.py python/branches/p3yk/Lib/test/test_xmlrpc.py python/branches/p3yk/Lib/test/test_zipimport.py python/branches/p3yk/Lib/test/tokenize_tests.txt python/branches/p3yk/Lib/tokenize.py python/branches/p3yk/Lib/uu.py python/branches/p3yk/Misc/NEWS python/branches/p3yk/Objects/longobject.c python/branches/p3yk/Objects/stringobject.c python/branches/p3yk/Objects/unicodeobject.c python/branches/p3yk/Python/ast.c python/branches/p3yk/Python/mystrtoul.c python/branches/p3yk/setup.py Log: PEP 3127: new octal literals, binary literals. Modified: python/branches/p3yk/Lib/CGIHTTPServer.py ============================================================================== --- python/branches/p3yk/Lib/CGIHTTPServer.py (original) +++ python/branches/p3yk/Lib/CGIHTTPServer.py Mon Jun 11 00:29:40 2007 @@ -353,7 +353,7 @@ st = os.stat(path) except os.error: return False - return st.st_mode & 0111 != 0 + return st.st_mode & 0o111 != 0 def test(HandlerClass = CGIHTTPRequestHandler, Modified: python/branches/p3yk/Lib/_strptime.py ============================================================================== --- python/branches/p3yk/Lib/_strptime.py (original) +++ python/branches/p3yk/Lib/_strptime.py Mon Jun 11 00:29:40 2007 @@ -107,7 +107,7 @@ # magical; just happened to have used it everywhere else where a # static date was needed. am_pm = [] - for hour in (01,22): + for hour in (1, 22): time_tuple = time.struct_time((1999,3,17,hour,44,55,2,76,0)) am_pm.append(time.strftime("%p", time_tuple).lower()) self.am_pm = am_pm Modified: python/branches/p3yk/Lib/anydbm.py ============================================================================== --- python/branches/p3yk/Lib/anydbm.py (original) +++ python/branches/p3yk/Lib/anydbm.py Mon Jun 11 00:29:40 2007 @@ -3,7 +3,7 @@ Instead of import dbm - d = dbm.open(file, 'w', 0666) + d = dbm.open(file, 'w', 0o666) use @@ -63,7 +63,7 @@ error = tuple(_errors) -def open(file, flag = 'r', mode = 0666): +def open(file, flag = 'r', mode = 0o666): # guess the type of an existing database from whichdb import whichdb result=whichdb(file) Modified: python/branches/p3yk/Lib/bsddb/__init__.py ============================================================================== --- python/branches/p3yk/Lib/bsddb/__init__.py (original) +++ python/branches/p3yk/Lib/bsddb/__init__.py Mon Jun 11 00:29:40 2007 @@ -294,7 +294,7 @@ #---------------------------------------------------------------------- # Compatibility object factory functions -def hashopen(file, flag='c', mode=0666, pgsize=None, ffactor=None, nelem=None, +def hashopen(file, flag='c', mode=0o666, pgsize=None, ffactor=None, nelem=None, cachesize=None, lorder=None, hflags=0): flags = _checkflag(flag, file) @@ -310,7 +310,7 @@ #---------------------------------------------------------------------- -def btopen(file, flag='c', mode=0666, +def btopen(file, flag='c', mode=0o666, btflags=0, cachesize=None, maxkeypage=None, minkeypage=None, pgsize=None, lorder=None): @@ -328,7 +328,7 @@ #---------------------------------------------------------------------- -def rnopen(file, flag='c', mode=0666, +def rnopen(file, flag='c', mode=0o666, rnflags=0, cachesize=None, pgsize=None, lorder=None, rlen=None, delim=None, source=None, pad=None): Modified: python/branches/p3yk/Lib/bsddb/dbshelve.py ============================================================================== --- python/branches/p3yk/Lib/bsddb/dbshelve.py (original) +++ python/branches/p3yk/Lib/bsddb/dbshelve.py Mon Jun 11 00:29:40 2007 @@ -40,7 +40,7 @@ #------------------------------------------------------------------------ -def open(filename, flags=db.DB_CREATE, mode=0660, filetype=db.DB_HASH, +def open(filename, flags=db.DB_CREATE, mode=0o660, filetype=db.DB_HASH, dbenv=None, dbname=None): """ A simple factory function for compatibility with the standard Modified: python/branches/p3yk/Lib/bsddb/dbtables.py ============================================================================== --- python/branches/p3yk/Lib/bsddb/dbtables.py (original) +++ python/branches/p3yk/Lib/bsddb/dbtables.py Mon Jun 11 00:29:40 2007 @@ -134,9 +134,9 @@ class bsdTableDB : - def __init__(self, filename, dbhome, create=0, truncate=0, mode=0600, + def __init__(self, filename, dbhome, create=0, truncate=0, mode=0o600, recover=0, dbflags=0): - """bsdTableDB(filename, dbhome, create=0, truncate=0, mode=0600) + """bsdTableDB(filename, dbhome, create=0, truncate=0, mode=0o600) Open database name in the dbhome BerkeleyDB directory. Use keyword arguments when calling this constructor. Modified: python/branches/p3yk/Lib/bsddb/test/test_1413192.py ============================================================================== --- python/branches/p3yk/Lib/bsddb/test/test_1413192.py (original) +++ python/branches/p3yk/Lib/bsddb/test/test_1413192.py Mon Jun 11 00:29:40 2007 @@ -18,4 +18,4 @@ the_txn = env.txn_begin() map = db.DB(env) -map.open('xxx.db', "p", db.DB_HASH, db.DB_CREATE, 0666, txn=the_txn) +map.open('xxx.db', "p", db.DB_HASH, db.DB_CREATE, 0o666, txn=the_txn) Modified: python/branches/p3yk/Lib/bsddb/test/test_basics.py ============================================================================== --- python/branches/p3yk/Lib/bsddb/test/test_basics.py (original) +++ python/branches/p3yk/Lib/bsddb/test/test_basics.py Mon Jun 11 00:29:40 2007 @@ -44,7 +44,7 @@ dbtype = db.DB_UNKNOWN # must be set in derived class dbopenflags = 0 dbsetflags = 0 - dbmode = 0660 + dbmode = 0o660 dbname = None useEnv = 0 envflags = 0 Modified: python/branches/p3yk/Lib/bsddb/test/test_env_close.py ============================================================================== --- python/branches/p3yk/Lib/bsddb/test/test_env_close.py (original) +++ python/branches/p3yk/Lib/bsddb/test/test_env_close.py Mon Jun 11 00:29:40 2007 @@ -50,10 +50,10 @@ dbenv = db.DBEnv() dbenv.open(self.homeDir, db.DB_INIT_CDB| db.DB_CREATE |db.DB_THREAD|db.DB_INIT_MPOOL, - 0666) + 0o666) d = db.DB(dbenv) - d.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0666) + d.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0o666) try: dbenv.close() @@ -75,10 +75,10 @@ dbenv = db.DBEnv() dbenv.open(self.homeDir, db.DB_INIT_CDB| db.DB_CREATE |db.DB_THREAD|db.DB_INIT_MPOOL, - 0666) + 0o666) d = db.DB(dbenv) - d.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0666) + d.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0o666) try: dbenv.close() Modified: python/branches/p3yk/Lib/bsddb/test/test_sequence.py ============================================================================== --- python/branches/p3yk/Lib/bsddb/test/test_sequence.py (original) +++ python/branches/p3yk/Lib/bsddb/test/test_sequence.py Mon Jun 11 00:29:40 2007 @@ -26,9 +26,9 @@ tempfile.tempdir = None self.dbenv = db.DBEnv() - self.dbenv.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL, 0666) + self.dbenv.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL, 0o666) self.d = db.DB(self.dbenv) - self.d.open(self.filename, db.DB_BTREE, db.DB_CREATE, 0666) + self.d.open(self.filename, db.DB_BTREE, db.DB_CREATE, 0o666) def tearDown(self): if hasattr(self, 'seq'): Modified: python/branches/p3yk/Lib/dbhash.py ============================================================================== --- python/branches/p3yk/Lib/dbhash.py (original) +++ python/branches/p3yk/Lib/dbhash.py Mon Jun 11 00:29:40 2007 @@ -12,5 +12,5 @@ error = bsddb.error # Exported for anydbm -def open(file, flag = 'r', mode=0666): +def open(file, flag = 'r', mode=0o666): return bsddb.hashopen(file, flag, mode) Modified: python/branches/p3yk/Lib/distutils/ccompiler.py ============================================================================== --- python/branches/p3yk/Lib/distutils/ccompiler.py (original) +++ python/branches/p3yk/Lib/distutils/ccompiler.py Mon Jun 11 00:29:40 2007 @@ -1040,7 +1040,7 @@ def move_file (self, src, dst): return move_file (src, dst, dry_run=self.dry_run) - def mkpath (self, name, mode=0777): + def mkpath (self, name, mode=0o777): mkpath (name, mode, self.dry_run) Modified: python/branches/p3yk/Lib/distutils/cmd.py ============================================================================== --- python/branches/p3yk/Lib/distutils/cmd.py (original) +++ python/branches/p3yk/Lib/distutils/cmd.py Mon Jun 11 00:29:40 2007 @@ -357,7 +357,7 @@ util.execute(func, args, msg, dry_run=self.dry_run) - def mkpath (self, name, mode=0777): + def mkpath (self, name, mode=0o777): dir_util.mkpath(name, mode, dry_run=self.dry_run) Modified: python/branches/p3yk/Lib/distutils/command/build_scripts.py ============================================================================== --- python/branches/p3yk/Lib/distutils/command/build_scripts.py (original) +++ python/branches/p3yk/Lib/distutils/command/build_scripts.py Mon Jun 11 00:29:40 2007 @@ -119,8 +119,8 @@ if self.dry_run: log.info("changing mode of %s", file) else: - oldmode = os.stat(file)[ST_MODE] & 07777 - newmode = (oldmode | 0555) & 07777 + oldmode = os.stat(file)[ST_MODE] & 0o7777 + newmode = (oldmode | 0o555) & 0o7777 if newmode != oldmode: log.info("changing mode of %s from %o to %o", file, oldmode, newmode) Modified: python/branches/p3yk/Lib/distutils/command/install_scripts.py ============================================================================== --- python/branches/p3yk/Lib/distutils/command/install_scripts.py (original) +++ python/branches/p3yk/Lib/distutils/command/install_scripts.py Mon Jun 11 00:29:40 2007 @@ -53,7 +53,7 @@ if self.dry_run: log.info("changing mode of %s", file) else: - mode = ((os.stat(file)[ST_MODE]) | 0555) & 07777 + mode = ((os.stat(file)[ST_MODE]) | 0o555) & 0o7777 log.info("changing mode of %s to %o", file, mode) os.chmod(file, mode) Modified: python/branches/p3yk/Lib/distutils/command/register.py ============================================================================== --- python/branches/p3yk/Lib/distutils/command/register.py (original) +++ python/branches/p3yk/Lib/distutils/command/register.py Mon Jun 11 00:29:40 2007 @@ -183,7 +183,7 @@ username, password)) f.close() try: - os.chmod(rc, 0600) + os.chmod(rc, 0o600) except: pass elif choice == '2': Modified: python/branches/p3yk/Lib/distutils/dir_util.py ============================================================================== --- python/branches/p3yk/Lib/distutils/dir_util.py (original) +++ python/branches/p3yk/Lib/distutils/dir_util.py Mon Jun 11 00:29:40 2007 @@ -18,7 +18,7 @@ # I don't use os.makedirs because a) it's new to Python 1.5.2, and # b) it blows up if the directory already exists (I want to silently # succeed in that case). -def mkpath (name, mode=0777, verbose=0, dry_run=0): +def mkpath (name, mode=0o777, verbose=0, dry_run=0): """Create a directory and any missing ancestor directories. If the directory already exists (or if 'name' is the empty string, which means the current directory, which of course exists), then do @@ -85,7 +85,7 @@ # mkpath () -def create_tree (base_dir, files, mode=0777, verbose=0, dry_run=0): +def create_tree (base_dir, files, mode=0o777, verbose=0, dry_run=0): """Create all the empty directories under 'base_dir' needed to put 'files' there. 'base_dir' is just the a name of a directory Modified: python/branches/p3yk/Lib/dumbdbm.py ============================================================================== --- python/branches/p3yk/Lib/dumbdbm.py (original) +++ python/branches/p3yk/Lib/dumbdbm.py Mon Jun 11 00:29:40 2007 @@ -219,7 +219,7 @@ self._os.chmod(file, self._mode) -def open(file, flag=None, mode=0666): +def open(file, flag=None, mode=0o666): """Open the database file, filename, and return corresponding object. The flag argument, used to control how the database is opened in the @@ -228,7 +228,7 @@ not exist. The optional mode argument is the UNIX mode of the file, used only when - the database has to be created. It defaults to octal code 0666 (and + the database has to be created. It defaults to octal code 0o666 (and will be modified by the prevailing umask). """ Modified: python/branches/p3yk/Lib/encodings/uu_codec.py ============================================================================== --- python/branches/p3yk/Lib/encodings/uu_codec.py (original) +++ python/branches/p3yk/Lib/encodings/uu_codec.py Mon Jun 11 00:29:40 2007 @@ -12,7 +12,7 @@ ### Codec APIs -def uu_encode(input,errors='strict',filename='',mode=0666): +def uu_encode(input,errors='strict',filename='',mode=0o666): """ Encodes the object input and returns a tuple (output object, length consumed). @@ -31,7 +31,7 @@ write = outfile.write # Encode - write('begin %o %s\n' % (mode & 0777, filename)) + write('begin %o %s\n' % (mode & 0o777, filename)) chunk = read(45) while chunk: write(b2a_uu(chunk)) Modified: python/branches/p3yk/Lib/imputil.py ============================================================================== --- python/branches/p3yk/Lib/imputil.py (original) +++ python/branches/p3yk/Lib/imputil.py Mon Jun 11 00:29:40 2007 @@ -476,7 +476,7 @@ s = _os_stat(pathname) except OSError: return None - return (s.st_mode & 0170000) == 0040000 + return (s.st_mode & 0o170000) == 0o040000 def _timestamp(pathname): "Return the file modification time as a Long." Modified: python/branches/p3yk/Lib/mailbox.py ============================================================================== --- python/branches/p3yk/Lib/mailbox.py (original) +++ python/branches/p3yk/Lib/mailbox.py Mon Jun 11 00:29:40 2007 @@ -227,10 +227,10 @@ Mailbox.__init__(self, dirname, factory, create) if not os.path.exists(self._path): if create: - os.mkdir(self._path, 0700) - os.mkdir(os.path.join(self._path, 'tmp'), 0700) - os.mkdir(os.path.join(self._path, 'new'), 0700) - os.mkdir(os.path.join(self._path, 'cur'), 0700) + os.mkdir(self._path, 0o700) + os.mkdir(os.path.join(self._path, 'tmp'), 0o700) + os.mkdir(os.path.join(self._path, 'new'), 0o700) + os.mkdir(os.path.join(self._path, 'cur'), 0o700) else: raise NoSuchMailboxError(self._path) self._toc = {} @@ -802,9 +802,9 @@ Mailbox.__init__(self, path, factory, create) if not os.path.exists(self._path): if create: - os.mkdir(self._path, 0700) + os.mkdir(self._path, 0o700) os.close(os.open(os.path.join(self._path, '.mh_sequences'), - os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0600)) + os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o600)) else: raise NoSuchMailboxError(self._path) self._locked = False Modified: python/branches/p3yk/Lib/mhlib.py ============================================================================== --- python/branches/p3yk/Lib/mhlib.py (original) +++ python/branches/p3yk/Lib/mhlib.py Mon Jun 11 00:29:40 2007 @@ -67,7 +67,7 @@ MH_PROFILE = '~/.mh_profile' PATH = '~/Mail' MH_SEQUENCES = '.mh_sequences' -FOLDER_PROTECT = 0700 +FOLDER_PROTECT = 0o700 # Imported modules Modified: python/branches/p3yk/Lib/os.py ============================================================================== --- python/branches/p3yk/Lib/os.py (original) +++ python/branches/p3yk/Lib/os.py Mon Jun 11 00:29:40 2007 @@ -147,8 +147,8 @@ # Super directory utilities. # (Inspired by Eric Raymond; the doc strings are mostly his) -def makedirs(name, mode=0777): - """makedirs(path [, mode=0777]) +def makedirs(name, mode=0o777): + """makedirs(path [, mode=0o777]) Super-mkdir; create a leaf directory and all intermediate ones. Works like mkdir, except that any intermediate path segment (not Modified: python/branches/p3yk/Lib/plat-atheos/IN.py ============================================================================== --- python/branches/p3yk/Lib/plat-atheos/IN.py (original) +++ python/branches/p3yk/Lib/plat-atheos/IN.py Mon Jun 11 00:29:40 2007 @@ -557,7 +557,7 @@ # Included from bits/dirent.h def _D_ALLOC_NAMLEN(d): return (_D_EXACT_NAMLEN (d) + 1) -def IFTODT(mode): return (((mode) & 0170000) >> 12) +def IFTODT(mode): return (((mode) & 0o170000) >> 12) def DTTOIF(dirtype): return ((dirtype) << 12) @@ -567,17 +567,17 @@ MAXNAMLEN = 255 # Included from posix/stat.h -S_IFMT = 00170000 -S_IFSOCK = 0140000 -S_IFLNK = 0120000 -S_IFREG = 0100000 -S_IFBLK = 0060000 -S_IFDIR = 0040000 -S_IFCHR = 0020000 -S_IFIFO = 0010000 -S_ISUID = 0004000 -S_ISGID = 0002000 -S_ISVTX = 0001000 +S_IFMT = 0o0170000 +S_IFSOCK = 0o140000 +S_IFLNK = 0o120000 +S_IFREG = 0o100000 +S_IFBLK = 0o060000 +S_IFDIR = 0o040000 +S_IFCHR = 0o020000 +S_IFIFO = 0o010000 +S_ISUID = 0o004000 +S_ISGID = 0o002000 +S_ISVTX = 0o001000 def S_ISLNK(m): return (((m) & S_IFMT) == S_IFLNK) def S_ISREG(m): return (((m) & S_IFMT) == S_IFREG) @@ -592,18 +592,18 @@ def S_ISSOCK(m): return (((m) & S_IFMT) == S_IFSOCK) -S_IRWXU = 00700 -S_IRUSR = 00400 -S_IWUSR = 00200 -S_IXUSR = 00100 -S_IRWXG = 00070 -S_IRGRP = 00040 -S_IWGRP = 00020 -S_IXGRP = 00010 -S_IRWXO = 00007 -S_IROTH = 00004 -S_IWOTH = 00002 -S_IXOTH = 00001 +S_IRWXU = 0o0700 +S_IRUSR = 0o0400 +S_IWUSR = 0o0200 +S_IXUSR = 0o0100 +S_IRWXG = 0o0070 +S_IRGRP = 0o0040 +S_IWGRP = 0o0020 +S_IXGRP = 0o0010 +S_IRWXO = 0o0007 +S_IROTH = 0o0004 +S_IWOTH = 0o0002 +S_IXOTH = 0o0001 S_IRWXUGO = (S_IRWXU|S_IRWXG|S_IRWXO) S_IALLUGO = (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO) S_IRUGO = (S_IRUSR|S_IRGRP|S_IROTH) @@ -612,24 +612,24 @@ _STAT_VER_KERNEL = 0 # Included from posix/fcntl.h -O_ACCMODE = 0003 +O_ACCMODE = 0o003 O_RWMASK = O_ACCMODE O_RDONLY = 00 -O_WRONLY = 01 -O_RDWR = 02 -O_CREAT = 0100 -O_EXCL = 0200 -O_NOCTTY = 0400 -O_TRUNC = 01000 -O_APPEND = 02000 -O_NONBLOCK = 04000 +O_WRONLY = 0o1 +O_RDWR = 0o2 +O_CREAT = 0o100 +O_EXCL = 0o200 +O_NOCTTY = 0o400 +O_TRUNC = 0o1000 +O_APPEND = 0o2000 +O_NONBLOCK = 0o4000 O_NDELAY = O_NONBLOCK -O_SYNC = 010000 +O_SYNC = 0o10000 O_FSYNC = O_SYNC -O_ASYNC = 020000 +O_ASYNC = 0o20000 FASYNC = O_ASYNC -O_DIRECTORY = 040000 -O_NOTRAVERSE = 0100000 +O_DIRECTORY = 0o40000 +O_NOTRAVERSE = 0o100000 O_NOFOLLOW = O_NOTRAVERSE F_DUPFD = 0 F_GETFD = 1 Modified: python/branches/p3yk/Lib/plat-mac/bundlebuilder.py ============================================================================== --- python/branches/p3yk/Lib/plat-mac/bundlebuilder.py (original) +++ python/branches/p3yk/Lib/plat-mac/bundlebuilder.py Mon Jun 11 00:29:40 2007 @@ -504,7 +504,7 @@ standalone = self.standalone semi_standalone = self.semi_standalone open(bootstrappath, "w").write(BOOTSTRAP_SCRIPT % locals()) - os.chmod(bootstrappath, 0775) + os.chmod(bootstrappath, 0o775) if self.iconfile is not None: iconbase = os.path.basename(self.iconfile) @@ -603,7 +603,7 @@ walk(path) else: mod = os.stat(path)[stat.ST_MODE] - if not (mod & 0100): + if not (mod & 0o100): continue relpath = path[len(self.bundlepath):] self.message("Stripping %s" % relpath, 2) Modified: python/branches/p3yk/Lib/plat-mac/macostools.py ============================================================================== --- python/branches/p3yk/Lib/plat-mac/macostools.py (original) +++ python/branches/p3yk/Lib/plat-mac/macostools.py Mon Jun 11 00:29:40 2007 @@ -61,7 +61,7 @@ if os.sep == ':' and not ':' in head: head = head + ':' mkdirs(head) - os.mkdir(dst, 0777) + os.mkdir(dst, 0o777) def touched(dst): """Tell the finder a file has changed. No-op on MacOSX.""" Modified: python/branches/p3yk/Lib/plat-sunos5/IN.py ============================================================================== --- python/branches/p3yk/Lib/plat-sunos5/IN.py (original) +++ python/branches/p3yk/Lib/plat-sunos5/IN.py Mon Jun 11 00:29:40 2007 @@ -97,7 +97,7 @@ NZERO = 20 NULL = 0 NULL = 0 -CMASK = 022 +CMASK = 0o22 CDLIMIT = (1<<11) NBPS = 0x20000 NBPSCTR = 512 @@ -733,13 +733,13 @@ _XRS_ID = 0x78727300 GETCONTEXT = 0 SETCONTEXT = 1 -UC_SIGMASK = 001 -UC_STACK = 002 -UC_CPU = 004 -UC_MAU = 010 +UC_SIGMASK = 0o01 +UC_STACK = 0o02 +UC_CPU = 0o04 +UC_MAU = 0o10 UC_FPU = UC_MAU -UC_INTR = 020 -UC_ASR = 040 +UC_INTR = 0o20 +UC_ASR = 0o40 UC_MCONTEXT = (UC_CPU|UC_FPU|UC_ASR) UC_ALL = (UC_SIGMASK|UC_STACK|UC_MCONTEXT) _SIGQUEUE_MAX = 32 @@ -1021,14 +1021,14 @@ AT_TIMES = (AT_ATIME|AT_MTIME|AT_CTIME) AT_NOSET = (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\ AT_BLKSIZE|AT_NBLOCKS|AT_VCODE) -VSUID = 04000 -VSGID = 02000 -VSVTX = 01000 -VREAD = 00400 -VWRITE = 00200 -VEXEC = 00100 -MODEMASK = 07777 -PERMMASK = 00777 +VSUID = 0o4000 +VSGID = 0o2000 +VSVTX = 0o1000 +VREAD = 0o0400 +VWRITE = 0o0200 +VEXEC = 0o0100 +MODEMASK = 0o7777 +PERMMASK = 0o0777 def MANDMODE(mode): return (((mode) & (VSGID|(VEXEC>>3))) == VSGID) VSA_ACL = 0x0001 Modified: python/branches/p3yk/Lib/plat-sunos5/STROPTS.py ============================================================================== --- python/branches/p3yk/Lib/plat-sunos5/STROPTS.py (original) +++ python/branches/p3yk/Lib/plat-sunos5/STROPTS.py Mon Jun 11 00:29:40 2007 @@ -94,7 +94,7 @@ NZERO = 20 NULL = 0 NULL = 0 -CMASK = 022 +CMASK = 0o22 CDLIMIT = (1<<11) NBPS = 0x20000 NBPSCTR = 512 @@ -730,13 +730,13 @@ _XRS_ID = 0x78727300 GETCONTEXT = 0 SETCONTEXT = 1 -UC_SIGMASK = 001 -UC_STACK = 002 -UC_CPU = 004 -UC_MAU = 010 +UC_SIGMASK = 0o01 +UC_STACK = 0o02 +UC_CPU = 0o04 +UC_MAU = 0o10 UC_FPU = UC_MAU -UC_INTR = 020 -UC_ASR = 040 +UC_INTR = 0o20 +UC_ASR = 0o40 UC_MCONTEXT = (UC_CPU|UC_FPU|UC_ASR) UC_ALL = (UC_SIGMASK|UC_STACK|UC_MCONTEXT) _SIGQUEUE_MAX = 32 @@ -1400,14 +1400,14 @@ AT_TIMES = (AT_ATIME|AT_MTIME|AT_CTIME) AT_NOSET = (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\ AT_BLKSIZE|AT_NBLOCKS|AT_VCODE) -VSUID = 04000 -VSGID = 02000 -VSVTX = 01000 -VREAD = 00400 -VWRITE = 00200 -VEXEC = 00100 -MODEMASK = 07777 -PERMMASK = 00777 +VSUID = 0o4000 +VSGID = 0o2000 +VSVTX = 0o1000 +VREAD = 0o0400 +VWRITE = 0o0200 +VEXEC = 0o0100 +MODEMASK = 0o7777 +PERMMASK = 0o0777 def MANDMODE(mode): return (((mode) & (VSGID|(VEXEC>>3))) == VSGID) VSA_ACL = 0x0001 Modified: python/branches/p3yk/Lib/plat-unixware7/IN.py ============================================================================== --- python/branches/p3yk/Lib/plat-unixware7/IN.py (original) +++ python/branches/p3yk/Lib/plat-unixware7/IN.py Mon Jun 11 00:29:40 2007 @@ -187,8 +187,8 @@ NC_TPI_COTS_ORD = 3 NC_TPI_RAW = 4 NC_NOFLAG = 00 -NC_VISIBLE = 01 -NC_BROADCAST = 02 +NC_VISIBLE = 0o1 +NC_BROADCAST = 0o2 NC_NOPROTOFMLY = "-" NC_LOOPBACK = "loopback" NC_INET = "inet" Modified: python/branches/p3yk/Lib/plat-unixware7/STROPTS.py ============================================================================== --- python/branches/p3yk/Lib/plat-unixware7/STROPTS.py (original) +++ python/branches/p3yk/Lib/plat-unixware7/STROPTS.py Mon Jun 11 00:29:40 2007 @@ -65,41 +65,41 @@ ES_MACADTLID = 7 ES_PRVID = 8 ES_TPGETMAJOR = 9 -SA_EXEC = 001 -SA_WRITE = 002 -SA_READ = 004 -SA_SUBSIZE = 010 +SA_EXEC = 0o01 +SA_WRITE = 0o02 +SA_READ = 0o04 +SA_SUBSIZE = 0o10 # Included from sys/stropts_f.h X_STR = (ord('S')<<8) -X_I_BASE = (X_STR|0200) -X_I_NREAD = (X_STR|0201) -X_I_PUSH = (X_STR|0202) -X_I_POP = (X_STR|0203) -X_I_LOOK = (X_STR|0204) -X_I_FLUSH = (X_STR|0205) -X_I_SRDOPT = (X_STR|0206) -X_I_GRDOPT = (X_STR|0207) -X_I_STR = (X_STR|0210) -X_I_SETSIG = (X_STR|0211) -X_I_GETSIG = (X_STR|0212) -X_I_FIND = (X_STR|0213) -X_I_LINK = (X_STR|0214) -X_I_UNLINK = (X_STR|0215) -X_I_PEEK = (X_STR|0217) -X_I_FDINSERT = (X_STR|0220) -X_I_SENDFD = (X_STR|0221) -X_I_RECVFD = (X_STR|0222) +X_I_BASE = (X_STR|0o200) +X_I_NREAD = (X_STR|0o201) +X_I_PUSH = (X_STR|0o202) +X_I_POP = (X_STR|0o203) +X_I_LOOK = (X_STR|0o204) +X_I_FLUSH = (X_STR|0o205) +X_I_SRDOPT = (X_STR|0o206) +X_I_GRDOPT = (X_STR|0o207) +X_I_STR = (X_STR|0o210) +X_I_SETSIG = (X_STR|0o211) +X_I_GETSIG = (X_STR|0o212) +X_I_FIND = (X_STR|0o213) +X_I_LINK = (X_STR|0o214) +X_I_UNLINK = (X_STR|0o215) +X_I_PEEK = (X_STR|0o217) +X_I_FDINSERT = (X_STR|0o220) +X_I_SENDFD = (X_STR|0o221) +X_I_RECVFD = (X_STR|0o222) # Included from unistd.h # Included from sys/unistd.h -R_OK = 004 -W_OK = 002 -X_OK = 001 +R_OK = 0o04 +W_OK = 0o02 +X_OK = 0o01 F_OK = 000 -EFF_ONLY_OK = 010 -EX_OK = 020 +EFF_ONLY_OK = 0o10 +EX_OK = 0o20 SEEK_SET = 0 SEEK_CUR = 1 SEEK_END = 2 @@ -289,40 +289,40 @@ ANYMARK = 0x01 LASTMARK = 0x02 STR = (ord('S')<<8) -I_NREAD = (STR|01) -I_PUSH = (STR|02) -I_POP = (STR|03) -I_LOOK = (STR|04) -I_FLUSH = (STR|05) -I_SRDOPT = (STR|06) -I_GRDOPT = (STR|07) -I_STR = (STR|010) -I_SETSIG = (STR|011) -I_GETSIG = (STR|012) -I_FIND = (STR|013) -I_LINK = (STR|014) -I_UNLINK = (STR|015) -I_PEEK = (STR|017) -I_FDINSERT = (STR|020) -I_SENDFD = (STR|021) -I_RECVFD = (STR|022) -I_E_RECVFD = (STR|016) -I_RECVFD = (STR|016) -I_RECVFD = (STR|022) -I_SWROPT = (STR|023) -I_GWROPT = (STR|024) -I_LIST = (STR|025) -I_PLINK = (STR|026) -I_PUNLINK = (STR|027) -I_FLUSHBAND = (STR|034) -I_CKBAND = (STR|035) -I_GETBAND = (STR|036) -I_ATMARK = (STR|037) -I_SETCLTIME = (STR|040) -I_GETCLTIME = (STR|041) -I_CANPUT = (STR|042) -I_S_RECVFD = (STR|043) -I_STATS = (STR|044) -I_BIGPIPE = (STR|045) -I_GETTP = (STR|046) +I_NREAD = (STR|0o1) +I_PUSH = (STR|0o2) +I_POP = (STR|0o3) +I_LOOK = (STR|0o4) +I_FLUSH = (STR|0o5) +I_SRDOPT = (STR|0o6) +I_GRDOPT = (STR|0o7) +I_STR = (STR|0o10) +I_SETSIG = (STR|0o11) +I_GETSIG = (STR|0o12) +I_FIND = (STR|0o13) +I_LINK = (STR|0o14) +I_UNLINK = (STR|0o15) +I_PEEK = (STR|0o17) +I_FDINSERT = (STR|0o20) +I_SENDFD = (STR|0o21) +I_RECVFD = (STR|0o22) +I_E_RECVFD = (STR|0o16) +I_RECVFD = (STR|0o16) +I_RECVFD = (STR|0o22) +I_SWROPT = (STR|0o23) +I_GWROPT = (STR|0o24) +I_LIST = (STR|0o25) +I_PLINK = (STR|0o26) +I_PUNLINK = (STR|0o27) +I_FLUSHBAND = (STR|0o34) +I_CKBAND = (STR|0o35) +I_GETBAND = (STR|0o36) +I_ATMARK = (STR|0o37) +I_SETCLTIME = (STR|0o40) +I_GETCLTIME = (STR|0o41) +I_CANPUT = (STR|0o42) +I_S_RECVFD = (STR|0o43) +I_STATS = (STR|0o44) +I_BIGPIPE = (STR|0o45) +I_GETTP = (STR|0o46) INFTIM = -1 Modified: python/branches/p3yk/Lib/pty.py ============================================================================== --- python/branches/p3yk/Lib/pty.py (original) +++ python/branches/p3yk/Lib/pty.py Mon Jun 11 00:29:40 2007 @@ -55,7 +55,7 @@ pass else: try: - tty_name, master_fd = sgi._getpty(os.O_RDWR, 0666, 0) + tty_name, master_fd = sgi._getpty(os.O_RDWR, 0o666, 0) except IOError as msg: raise os.error, msg return master_fd, tty_name Modified: python/branches/p3yk/Lib/stat.py ============================================================================== --- python/branches/p3yk/Lib/stat.py (original) +++ python/branches/p3yk/Lib/stat.py Mon Jun 11 00:29:40 2007 @@ -24,21 +24,21 @@ # Extract bits from the mode def S_IMODE(mode): - return mode & 07777 + return mode & 0o7777 def S_IFMT(mode): - return mode & 0170000 + return mode & 0o170000 # Constants used as S_IFMT() for various file types # (not all are implemented on all systems) -S_IFDIR = 0040000 -S_IFCHR = 0020000 -S_IFBLK = 0060000 -S_IFREG = 0100000 -S_IFIFO = 0010000 -S_IFLNK = 0120000 -S_IFSOCK = 0140000 +S_IFDIR = 0o040000 +S_IFCHR = 0o020000 +S_IFBLK = 0o060000 +S_IFREG = 0o100000 +S_IFIFO = 0o010000 +S_IFLNK = 0o120000 +S_IFSOCK = 0o140000 # Functions to test for each file type @@ -65,25 +65,25 @@ # Names for permission bits -S_ISUID = 04000 -S_ISGID = 02000 +S_ISUID = 0o4000 +S_ISGID = 0o2000 S_ENFMT = S_ISGID -S_ISVTX = 01000 -S_IREAD = 00400 -S_IWRITE = 00200 -S_IEXEC = 00100 -S_IRWXU = 00700 -S_IRUSR = 00400 -S_IWUSR = 00200 -S_IXUSR = 00100 -S_IRWXG = 00070 -S_IRGRP = 00040 -S_IWGRP = 00020 -S_IXGRP = 00010 -S_IRWXO = 00007 -S_IROTH = 00004 -S_IWOTH = 00002 -S_IXOTH = 00001 +S_ISVTX = 0o1000 +S_IREAD = 0o0400 +S_IWRITE = 0o0200 +S_IEXEC = 0o0100 +S_IRWXU = 0o0700 +S_IRUSR = 0o0400 +S_IWUSR = 0o0200 +S_IXUSR = 0o0100 +S_IRWXG = 0o0070 +S_IRGRP = 0o0040 +S_IWGRP = 0o0020 +S_IXGRP = 0o0010 +S_IRWXO = 0o0007 +S_IROTH = 0o0004 +S_IWOTH = 0o0002 +S_IXOTH = 0o0001 # Names for file flags Modified: python/branches/p3yk/Lib/tarfile.py ============================================================================== --- python/branches/p3yk/Lib/tarfile.py (original) +++ python/branches/p3yk/Lib/tarfile.py Mon Jun 11 00:29:40 2007 @@ -141,26 +141,26 @@ #--------------------------------------------------------- # Bits used in the mode field, values in octal. #--------------------------------------------------------- -S_IFLNK = 0120000 # symbolic link -S_IFREG = 0100000 # regular file -S_IFBLK = 0060000 # block device -S_IFDIR = 0040000 # directory -S_IFCHR = 0020000 # character device -S_IFIFO = 0010000 # fifo - -TSUID = 04000 # set UID on execution -TSGID = 02000 # set GID on execution -TSVTX = 01000 # reserved - -TUREAD = 0400 # read by owner -TUWRITE = 0200 # write by owner -TUEXEC = 0100 # execute/search by owner -TGREAD = 0040 # read by group -TGWRITE = 0020 # write by group -TGEXEC = 0010 # execute/search by group -TOREAD = 0004 # read by other -TOWRITE = 0002 # write by other -TOEXEC = 0001 # execute/search by other +S_IFLNK = 0o120000 # symbolic link +S_IFREG = 0o100000 # regular file +S_IFBLK = 0o060000 # block device +S_IFDIR = 0o040000 # directory +S_IFCHR = 0o020000 # character device +S_IFIFO = 0o010000 # fifo + +TSUID = 0o4000 # set UID on execution +TSGID = 0o2000 # set GID on execution +TSVTX = 0o1000 # reserved + +TUREAD = 0o400 # read by owner +TUWRITE = 0o200 # write by owner +TUEXEC = 0o100 # execute/search by owner +TGREAD = 0o040 # read by group +TGWRITE = 0o020 # write by group +TGEXEC = 0o010 # execute/search by group +TOREAD = 0o004 # read by other +TOWRITE = 0o002 # write by other +TOEXEC = 0o001 # execute/search by other #--------------------------------------------------------- # initialization @@ -192,7 +192,7 @@ """ # There are two possible encodings for a number field, see # itn() below. - if s[0] != chr(0200): + if s[0] != chr(0o200): try: n = int(nts(s) or "0", 8) except ValueError: @@ -210,7 +210,7 @@ # POSIX 1003.1-1988 requires numbers to be encoded as a string of # octal digits followed by a null-byte, this allows values up to # (8**(digits-1))-1. GNU tar allows storing numbers greater than - # that if necessary. A leading 0200 byte indicates this particular + # that if necessary. A leading 0o200 byte indicates this particular # encoding, the following digits-1 bytes are a big-endian # representation. This allows values up to (256**(digits-1))-1. if 0 <= n < 8 ** (digits - 1): @@ -226,9 +226,9 @@ s = "" for i in range(digits - 1): - s = chr(n & 0377) + s + s = chr(n & 0o377) + s n >>= 8 - s = chr(0200) + s + s = chr(0o200) + s return s def uts(s, encoding, errors): @@ -920,7 +920,7 @@ of the member. """ self.name = name # member name - self.mode = 0644 # file permissions + self.mode = 0o644 # file permissions self.uid = 0 # user id self.gid = 0 # group id self.size = 0 # file size @@ -960,7 +960,7 @@ """ info = { "name": normpath(self.name), - "mode": self.mode & 07777, + "mode": self.mode & 0o7777, "uid": self.uid, "gid": self.gid, "size": self.size, @@ -1103,7 +1103,7 @@ """ parts = [ stn(info.get("name", ""), 100), - itn(info.get("mode", 0) & 07777, 8, format), + itn(info.get("mode", 0) & 0o7777, 8, format), itn(info.get("uid", 0), 8, format), itn(info.get("gid", 0), 8, format), itn(info.get("size", 0), 12, format), @@ -2019,7 +2019,7 @@ # Extract directory with a safe mode, so that # all files below can be extracted as well. try: - os.makedirs(os.path.join(path, tarinfo.name), 0700) + os.makedirs(os.path.join(path, tarinfo.name), 0o700) except EnvironmentError: pass directories.append(tarinfo) Modified: python/branches/p3yk/Lib/tempfile.py ============================================================================== --- python/branches/p3yk/Lib/tempfile.py (original) +++ python/branches/p3yk/Lib/tempfile.py Mon Jun 11 00:29:40 2007 @@ -200,7 +200,7 @@ name = next(namer) filename = _os.path.join(dir, name) try: - fd = _os.open(filename, flags, 0600) + fd = _os.open(filename, flags, 0o600) fp = _os.fdopen(fd, 'w') fp.write('blat') fp.close() @@ -239,7 +239,7 @@ name = next(names) file = _os.path.join(dir, pre + name + suf) try: - fd = _os.open(file, flags, 0600) + fd = _os.open(file, flags, 0o600) _set_cloexec(fd) return (fd, _os.path.abspath(file)) except OSError as e: @@ -331,7 +331,7 @@ name = next(names) file = _os.path.join(dir, prefix + name + suffix) try: - _os.mkdir(file, 0700) + _os.mkdir(file, 0o700) return file except OSError as e: if e.errno == _errno.EEXIST: Modified: python/branches/p3yk/Lib/test/output/test_tokenize ============================================================================== --- python/branches/p3yk/Lib/test/output/test_tokenize (original) +++ python/branches/p3yk/Lib/test/output/test_tokenize Mon Jun 11 00:29:40 2007 @@ -124,66 +124,80 @@ 39,5-39,7: OP '!=' 39,8-39,11: NUMBER '255' 39,11-39,12: NEWLINE '\n' -40,0-40,4: NUMBER '0377' -40,5-40,7: OP '!=' -40,8-40,11: NUMBER '255' -40,11-40,12: NEWLINE '\n' +40,0-40,5: NUMBER '0o377' +40,6-40,8: OP '!=' +40,9-40,12: NUMBER '255' +40,12-40,13: NEWLINE '\n' 41,0-41,10: NUMBER '2147483647' 41,13-41,15: OP '!=' -41,16-41,28: NUMBER '017777777777' -41,28-41,29: NEWLINE '\n' +41,16-41,29: NUMBER '0o17777777777' +41,29-41,30: NEWLINE '\n' 42,0-42,1: OP '-' 42,1-42,11: NUMBER '2147483647' 42,11-42,12: OP '-' 42,12-42,13: NUMBER '1' 42,14-42,16: OP '!=' -42,17-42,29: NUMBER '020000000000' -42,29-42,30: NEWLINE '\n' -43,0-43,12: NUMBER '037777777777' -43,13-43,15: OP '!=' -43,16-43,17: OP '-' -43,17-43,18: NUMBER '1' -43,18-43,19: NEWLINE '\n' +42,17-42,30: NUMBER '0o20000000000' +42,30-42,31: NEWLINE '\n' +43,0-43,13: NUMBER '0o37777777777' +43,14-43,16: OP '!=' +43,17-43,18: OP '-' +43,18-43,19: NUMBER '1' +43,19-43,20: NEWLINE '\n' 44,0-44,10: NUMBER '0xffffffff' 44,11-44,13: OP '!=' 44,14-44,15: OP '-' 44,15-44,16: NUMBER '1' -44,16-44,17: NEWLINE '\n' +44,16-44,17: OP ';' +44,18-44,31: NUMBER '0o37777777777' +44,32-44,34: OP '!=' +44,35-44,36: OP '-' +44,36-44,37: NUMBER '1' +44,37-44,38: OP ';' +44,39-44,40: OP '-' +44,40-44,49: NUMBER '0o1234567' +44,50-44,52: OP '==' +44,53-44,64: NUMBER '0O001234567' +44,64-44,65: OP ';' +44,66-44,73: NUMBER '0b10101' +44,74-44,76: OP '==' +44,77-44,87: NUMBER '0B00010101' +44,87-44,88: NEWLINE '\n' 45,0-45,1: NL '\n' 46,0-46,15: COMMENT '# Long integers' 46,15-46,16: NL '\n' 47,0-47,1: NAME 'x' 47,2-47,3: OP '=' -47,4-47,6: NUMBER '0L' -47,6-47,7: NEWLINE '\n' +47,4-47,5: NUMBER '0' +47,5-47,6: NEWLINE '\n' 48,0-48,1: NAME 'x' 48,2-48,3: OP '=' -48,4-48,6: NUMBER '0l' -48,6-48,7: NEWLINE '\n' +48,4-48,5: NUMBER '0' +48,5-48,6: NEWLINE '\n' 49,0-49,1: NAME 'x' 49,2-49,3: OP '=' -49,4-49,23: NUMBER '0xffffffffffffffffL' -49,23-49,24: NEWLINE '\n' +49,4-49,22: NUMBER '0xffffffffffffffff' +49,22-49,23: NEWLINE '\n' 50,0-50,1: NAME 'x' 50,2-50,3: OP '=' -50,4-50,23: NUMBER '0xffffffffffffffffl' -50,23-50,24: NEWLINE '\n' +50,4-50,22: NUMBER '0xffffffffffffffff' +50,22-50,23: NEWLINE '\n' 51,0-51,1: NAME 'x' 51,2-51,3: OP '=' -51,4-51,23: NUMBER '077777777777777777L' +51,4-51,23: NUMBER '0o77777777777777777' 51,23-51,24: NEWLINE '\n' 52,0-52,1: NAME 'x' 52,2-52,3: OP '=' -52,4-52,23: NUMBER '077777777777777777l' +52,4-52,23: NUMBER '0B11101010111111111' 52,23-52,24: NEWLINE '\n' 53,0-53,1: NAME 'x' 53,2-53,3: OP '=' -53,4-53,35: NUMBER '123456789012345678901234567890L' -53,35-53,36: NEWLINE '\n' +53,4-53,34: NUMBER '123456789012345678901234567890' +53,34-53,35: NEWLINE '\n' 54,0-54,1: NAME 'x' 54,2-54,3: OP '=' -54,4-54,35: NUMBER '123456789012345678901234567890l' -54,35-54,36: NEWLINE '\n' +54,4-54,34: NUMBER '123456789012345678901234567890' +54,34-54,35: NEWLINE '\n' 55,0-55,1: NL '\n' 56,0-56,24: COMMENT '# Floating-point numbers' 56,24-56,25: NL '\n' Modified: python/branches/p3yk/Lib/test/test_builtin.py ============================================================================== --- python/branches/p3yk/Lib/test/test_builtin.py (original) +++ python/branches/p3yk/Lib/test/test_builtin.py Mon Jun 11 00:29:40 2007 @@ -795,8 +795,27 @@ self.assertRaises(TypeError, int, 1, 12) - self.assertEqual(int('0123', 0), 83) + # tests with base 0 + self.assertRaises(ValueError, int, ' 0123 ', 0) # old octal syntax + self.assertEqual(int('000', 0), 0) + self.assertEqual(int('0o123', 0), 83) + self.assertEqual(int('0x123', 0), 291) + self.assertEqual(int('0b100', 0), 4) + self.assertEqual(int(' 0O123 ', 0), 83) + self.assertEqual(int(' 0X123 ', 0), 291) + self.assertEqual(int(' 0B100 ', 0), 4) + + # without base still base 10 + self.assertEqual(int('0123'), 123) + self.assertEqual(int('0123', 10), 123) + + # tests with prefix and base != 0 self.assertEqual(int('0x123', 16), 291) + self.assertEqual(int('0o123', 8), 83) + self.assertEqual(int('0b100', 2), 4) + self.assertEqual(int('0X123', 16), 291) + self.assertEqual(int('0O123', 8), 83) + self.assertEqual(int('0B100', 2), 4) # SF bug 1334662: int(string, base) wrong answers # Various representations of 2**32 evaluated to 0 @@ -1348,10 +1367,10 @@ self.assertEquals(next(it, 42), 42) def test_oct(self): - self.assertEqual(oct(100), '0144') - self.assertEqual(oct(100), '0144') - self.assertEqual(oct(-100), '-0144') - self.assertEqual(oct(-100), '-0144') + self.assertEqual(oct(100), '0o144') + self.assertEqual(oct(100), '0o144') + self.assertEqual(oct(-100), '-0o144') + self.assertEqual(oct(-100), '-0o144') self.assertRaises(TypeError, oct, ()) def write_testfile(self): Modified: python/branches/p3yk/Lib/test/test_compile.py ============================================================================== --- python/branches/p3yk/Lib/test/test_compile.py (original) +++ python/branches/p3yk/Lib/test/test_compile.py Mon Jun 11 00:29:40 2007 @@ -158,21 +158,22 @@ def test_literals_with_leading_zeroes(self): for arg in ["077787", "0xj", "0x.", "0e", "090000000000000", - "080000000000000", "000000000000009", "000000000000008"]: + "080000000000000", "000000000000009", "000000000000008", + "0b42", "0BADCAFE", "0o123456789", "0b1.1", "0o4.2", + "0b101j2", "0o153j2", "0b100e1", "0o777e1", "0777", + "000777", "000000000000007"]: self.assertRaises(SyntaxError, eval, arg) - self.assertEqual(eval("0777"), 511) - self.assertEqual(eval("000777"), 511) self.assertEqual(eval("0xff"), 255) - self.assertEqual(eval("0XfF"), 255) self.assertEqual(eval("0777."), 777) self.assertEqual(eval("0777.0"), 777) self.assertEqual(eval("000000000000000000000000000000000000000000000000000777e0"), 777) self.assertEqual(eval("0777e1"), 7770) self.assertEqual(eval("0e0"), 0) - self.assertEqual(eval("0000E-012"), 0) + self.assertEqual(eval("0000e-012"), 0) self.assertEqual(eval("09.5"), 9.5) self.assertEqual(eval("0777j"), 777j) + self.assertEqual(eval("000"), 0) self.assertEqual(eval("00j"), 0j) self.assertEqual(eval("00.0"), 0) self.assertEqual(eval("0e3"), 0) @@ -181,9 +182,12 @@ self.assertEqual(eval("090000000000000e0"), 90000000000000.) self.assertEqual(eval("090000000000000e-0"), 90000000000000.) self.assertEqual(eval("090000000000000j"), 90000000000000j) - self.assertEqual(eval("000000000000007"), 7) self.assertEqual(eval("000000000000008."), 8.) self.assertEqual(eval("000000000000009."), 9.) + self.assertEqual(eval("0b101010"), 42) + self.assertEqual(eval("-0b000000000010"), -2) + self.assertEqual(eval("0o777"), 511) + self.assertEqual(eval("-0o0000010"), -8) def test_unary_minus(self): # Verify treatment of unary minus on negative numbers SF bug #660455 Modified: python/branches/p3yk/Lib/test/test_descr.py ============================================================================== --- python/branches/p3yk/Lib/test/test_descr.py (original) +++ python/branches/p3yk/Lib/test/test_descr.py Mon Jun 11 00:29:40 2007 @@ -2124,17 +2124,14 @@ class octlong(int): __slots__ = [] def __str__(self): - s = oct(self) - if s[-1] == 'L': - s = s[:-1] - return s + return oct(self) def __add__(self, other): return self.__class__(super(octlong, self).__add__(other)) __radd__ = __add__ - vereq(str(octlong(3) + 5), "010") + vereq(str(octlong(3) + 5), "0o10") # (Note that overriding __radd__ here only seems to work # because the example uses a short int left argument.) - vereq(str(5 + octlong(3000)), "05675") + vereq(str(5 + octlong(3000)), "0o5675") a = octlong(12345) vereq(a, 12345) vereq(int(a), 12345) Modified: python/branches/p3yk/Lib/test/test_dumbdbm.py ============================================================================== --- python/branches/p3yk/Lib/test/test_dumbdbm.py (original) +++ python/branches/p3yk/Lib/test/test_dumbdbm.py Mon Jun 11 00:29:40 2007 @@ -44,17 +44,17 @@ return try: - old_umask = os.umask(0002) - f = dumbdbm.open(_fname, 'c', 0637) + old_umask = os.umask(0o002) + f = dumbdbm.open(_fname, 'c', 0o637) f.close() finally: os.umask(old_umask) - expected_mode = 0635 + expected_mode = 0o635 if os.name != 'posix': # Windows only supports setting the read-only attribute. # This shouldn't fail, but doesn't work like Unix either. - expected_mode = 0666 + expected_mode = 0o666 import stat st = os.stat(_fname + '.dat') Modified: python/branches/p3yk/Lib/test/test_format.py ============================================================================== --- python/branches/p3yk/Lib/test/test_format.py (original) +++ python/branches/p3yk/Lib/test/test_format.py Mon Jun 11 00:29:40 2007 @@ -122,7 +122,7 @@ # same, except no 0 flag testboth("%#+27.23X", big, " +0X001234567890ABCDEF12345") -big = 012345670123456701234567012345670 # 32 octal digits +big = 0o12345670123456701234567012345670 # 32 octal digits testboth("%o", big, "12345670123456701234567012345670") testboth("%o", -big, "-12345670123456701234567012345670") testboth("%5o", -big, "-12345670123456701234567012345670") @@ -142,25 +142,26 @@ testboth("%34.33o", big, " 012345670123456701234567012345670") testboth("%-34.33o", big, "012345670123456701234567012345670 ") testboth("%o", big, "12345670123456701234567012345670") -testboth("%#o", big, "012345670123456701234567012345670") -testboth("%#o", -big, "-012345670123456701234567012345670") -testboth("%#.34o", -big, "-0012345670123456701234567012345670") -testboth("%#+.34o", big, "+0012345670123456701234567012345670") -testboth("%# .34o", big, " 0012345670123456701234567012345670") -testboth("%#+.34o", big, "+0012345670123456701234567012345670") -testboth("%#-+.34o", big, "+0012345670123456701234567012345670") -testboth("%#-+37.34o", big, "+0012345670123456701234567012345670 ") -testboth("%#+37.34o", big, " +0012345670123456701234567012345670") +testboth("%#o", big, "0o12345670123456701234567012345670") +testboth("%#o", -big, "-0o12345670123456701234567012345670") +testboth("%#.34o", -big, "-0o0012345670123456701234567012345670") +testboth("%#+.34o", big, "+0o0012345670123456701234567012345670") +testboth("%# .34o", big, " 0o0012345670123456701234567012345670") +testboth("%#-+.34o", big, "+0o0012345670123456701234567012345670") +testboth("%#-+39.34o", big, "+0o0012345670123456701234567012345670 ") +testboth("%#+39.34o", big, " +0o0012345670123456701234567012345670") # next one gets one leading zero from precision testboth("%.33o", big, "012345670123456701234567012345670") -# base marker shouldn't change that, since "0" is redundant -testboth("%#.33o", big, "012345670123456701234567012345670") -# but reduce precision, and base marker should add a zero -testboth("%#.32o", big, "012345670123456701234567012345670") -# one leading zero from precision, and another from "0" flag & width +# one leading zero from precision +testboth("%#.33o", big, "0o012345670123456701234567012345670") +# leading zero vanishes +testboth("%#.32o", big, "0o12345670123456701234567012345670") +# one leading zero from precision, and another from '0' flag & width testboth("%034.33o", big, "0012345670123456701234567012345670") -# base marker shouldn't change that -testboth("%0#34.33o", big, "0012345670123456701234567012345670") +# max width includes base marker; padding zeroes come after marker +testboth("%0#38.33o", big, "0o000012345670123456701234567012345670") +# padding spaces come before marker +testboth("%#36.33o", big, " 0o012345670123456701234567012345670") # Some small ints, in both Python int and long flavors). testboth("%d", 42, "42") @@ -171,10 +172,10 @@ testboth("%#x", 1, "0x1") testboth("%#X", 1, "0X1") testboth("%#X", 1, "0X1") -testboth("%#o", 1, "01") -testboth("%#o", 1, "01") -testboth("%#o", 0, "0") -testboth("%#o", 0, "0") +testboth("%#o", 1, "0o1") +testboth("%#o", 1, "0o1") +testboth("%#o", 0, "0o0") +testboth("%#o", 0, "0o0") testboth("%o", 0, "0") testboth("%o", 0, "0") testboth("%d", 0, "0") @@ -189,10 +190,10 @@ testboth("%x", 0x42, "42") testboth("%x", -0x42, "-42") -testboth("%o", 042, "42") -testboth("%o", -042, "-42") -testboth("%o", 042, "42") -testboth("%o", -042, "-42") +testboth("%o", 0o42, "42") +testboth("%o", -0o42, "-42") +testboth("%o", 0o42, "42") +testboth("%o", -0o42, "-42") # Test exception for unknown format characters if verbose: Modified: python/branches/p3yk/Lib/test/test_grammar.py ============================================================================== --- python/branches/p3yk/Lib/test/test_grammar.py (original) +++ python/branches/p3yk/Lib/test/test_grammar.py Mon Jun 11 00:29:40 2007 @@ -27,26 +27,32 @@ self.assertEquals(x, 0, 'backslash ending comment') def testPlainIntegers(self): + self.assertEquals(type(000), type(0)) self.assertEquals(0xff, 255) - self.assertEquals(0377, 255) - self.assertEquals(2147483647, 017777777777) + self.assertEquals(0o377, 255) + self.assertEquals(2147483647, 0o17777777777) + self.assertEquals(0b1001, 9) from sys import maxint if maxint == 2147483647: - self.assertEquals(-2147483647-1, -020000000000) + self.assertEquals(-2147483647-1, -0o20000000000) # XXX -2147483648 - self.assert_(037777777777 > 0) + self.assert_(0o37777777777 > 0) self.assert_(0xffffffff > 0) - for s in '2147483648', '040000000000', '0x100000000': + self.assert_(0b1111111111111111111111111111111 > 0) + for s in ('2147483648', '0o40000000000', '0x100000000', + '0b10000000000000000000000000000000'): try: x = eval(s) except OverflowError: self.fail("OverflowError on huge integer literal %r" % s) elif maxint == 9223372036854775807: - self.assertEquals(-9223372036854775807-1, -01000000000000000000000) - self.assert_(01777777777777777777777 > 0) + self.assertEquals(-9223372036854775807-1, -0o1000000000000000000000) + self.assert_(0o1777777777777777777777 > 0) self.assert_(0xffffffffffffffff > 0) - for s in '9223372036854775808', '02000000000000000000000', \ - '0x10000000000000000': + self.assert_(0b11111111111111111111111111111111111111111111111111111111111111 > 0) + for s in '9223372036854775808', '0o2000000000000000000000', \ + '0x10000000000000000', \ + '0b100000000000000000000000000000000000000000000000000000000000000': try: x = eval(s) except OverflowError: @@ -56,13 +62,13 @@ def testLongIntegers(self): x = 0 - x = 0 - x = 0xffffffffffffffff x = 0xffffffffffffffff - x = 077777777777777777 - x = 077777777777777777 - x = 123456789012345678901234567890 + x = 0Xffffffffffffffff + x = 0o77777777777777777 + x = 0O77777777777777777 x = 123456789012345678901234567890 + x = 0b100000000000000000000000000000000000000000000000000000000000000000000 + x = 0B111111111111111111111111111111111111111111111111111111111111111111111 def testFloats(self): x = 3.14 Modified: python/branches/p3yk/Lib/test/test_hexoct.py ============================================================================== --- python/branches/p3yk/Lib/test/test_hexoct.py (original) +++ python/branches/p3yk/Lib/test/test_hexoct.py Mon Jun 11 00:29:40 2007 @@ -65,49 +65,49 @@ def test_oct_baseline(self): # Baseline tests self.assertEqual(00, 0) - self.assertEqual(020, 16) + self.assertEqual(0o20, 16) if platform_long_is_32_bits: - self.assertEqual(017777777777, 2147483647) + self.assertEqual(0o17777777777, 2147483647) else: - self.assertEqual(0777777777777777777777, 9223372036854775807) + self.assertEqual(0o777777777777777777777, 9223372036854775807) # Ditto with a minus sign and parentheses self.assertEqual(-(00), 0) - self.assertEqual(-(020), -16) + self.assertEqual(-(0o20), -16) if platform_long_is_32_bits: - self.assertEqual(-(017777777777), -2147483647) + self.assertEqual(-(0o17777777777), -2147483647) else: - self.assertEqual(-(0777777777777777777777), -9223372036854775807) + self.assertEqual(-(0o777777777777777777777), -9223372036854775807) # Ditto with a minus sign and NO parentheses self.assertEqual(-00, 0) - self.assertEqual(-020, -16) + self.assertEqual(-0o20, -16) if platform_long_is_32_bits: - self.assertEqual(-017777777777, -2147483647) + self.assertEqual(-0o17777777777, -2147483647) else: - self.assertEqual(-0777777777777777777777, -9223372036854775807) + self.assertEqual(-0o777777777777777777777, -9223372036854775807) def test_oct_unsigned(self): if platform_long_is_32_bits: # Positive constants - self.assertEqual(020000000000, 2147483648) - self.assertEqual(037777777777, 4294967295) + self.assertEqual(0o20000000000, 2147483648) + self.assertEqual(0o37777777777, 4294967295) # Ditto with a minus sign and parentheses - self.assertEqual(-(020000000000), -2147483648) - self.assertEqual(-(037777777777), -4294967295) + self.assertEqual(-(0o20000000000), -2147483648) + self.assertEqual(-(0o37777777777), -4294967295) # Ditto with a minus sign and NO parentheses # This failed in Python 2.2 through 2.2.2 and in 2.3a1 - self.assertEqual(-020000000000, -2147483648) - self.assertEqual(-037777777777, -4294967295) + self.assertEqual(-0o20000000000, -2147483648) + self.assertEqual(-0o37777777777, -4294967295) else: # Positive constants - self.assertEqual(01000000000000000000000, 9223372036854775808) - self.assertEqual(01777777777777777777777, 18446744073709551615) + self.assertEqual(0o1000000000000000000000, 9223372036854775808) + self.assertEqual(0o1777777777777777777777, 18446744073709551615) # Ditto with a minus sign and parentheses - self.assertEqual(-(01000000000000000000000), -9223372036854775808) - self.assertEqual(-(01777777777777777777777), -18446744073709551615) + self.assertEqual(-(0o1000000000000000000000), -9223372036854775808) + self.assertEqual(-(0o1777777777777777777777), -18446744073709551615) # Ditto with a minus sign and NO parentheses # This failed in Python 2.2 through 2.2.2 and in 2.3a1 - self.assertEqual(-01000000000000000000000, -9223372036854775808) - self.assertEqual(-01777777777777777777777, -18446744073709551615) + self.assertEqual(-0o1000000000000000000000, -9223372036854775808) + self.assertEqual(-0o1777777777777777777777, -18446744073709551615) def test_main(): test_support.run_unittest(TextHexOct) Modified: python/branches/p3yk/Lib/test/test_long.py ============================================================================== --- python/branches/p3yk/Lib/test/test_long.py (original) +++ python/branches/p3yk/Lib/test/test_long.py Mon Jun 11 00:29:40 2007 @@ -195,9 +195,6 @@ self.check_bitop_identities_3(x, y, self.getran((lenx + leny)//2)) def slow_format(self, x, base): - if (x, base) == (0, 8): - # this is an oddball! - return "0" digits = [] sign = 0 if x < 0: @@ -208,7 +205,7 @@ digits.reverse() digits = digits or [0] return '-'[:sign] + \ - {8: '0', 10: '', 16: '0x'}[base] + \ + {2: '0b', 8: '0o', 10: '', 16: '0x'}[base] + \ "".join(map(lambda i: "0123456789abcdef"[i], digits)) def check_format_1(self, x): Modified: python/branches/p3yk/Lib/test/test_strptime.py ============================================================================== --- python/branches/p3yk/Lib/test/test_strptime.py (original) +++ python/branches/p3yk/Lib/test/test_strptime.py Mon Jun 11 00:29:40 2007 @@ -463,8 +463,8 @@ "of the year") test_helper((1917, 12, 31), "Dec 31 on Monday with year starting and " "ending on Monday") - test_helper((2007, 01, 07), "First Sunday of 2007") - test_helper((2007, 01, 14), "Second Sunday of 2007") + test_helper((2007, 1, 7), "First Sunday of 2007") + test_helper((2007, 1, 14), "Second Sunday of 2007") test_helper((2006, 12, 31), "Last Sunday of 2006") test_helper((2006, 12, 24), "Second to last Sunday of 2006") Modified: python/branches/p3yk/Lib/test/test_subprocess.py ============================================================================== --- python/branches/p3yk/Lib/test/test_subprocess.py (original) +++ python/branches/p3yk/Lib/test/test_subprocess.py Mon Jun 11 00:29:40 2007 @@ -533,7 +533,7 @@ os.write(f, "exec %s -c 'import sys; sys.exit(47)'\n" % sys.executable) os.close(f) - os.chmod(fname, 0700) + os.chmod(fname, 0o700) p = subprocess.Popen(fname) p.wait() os.remove(fname) @@ -575,7 +575,7 @@ os.write(f, "exec %s -c 'import sys; sys.exit(47)'\n" % sys.executable) os.close(f) - os.chmod(fname, 0700) + os.chmod(fname, 0o700) rc = subprocess.call(fname) os.remove(fname) self.assertEqual(rc, 47) Modified: python/branches/p3yk/Lib/test/test_tarfile.py ============================================================================== --- python/branches/p3yk/Lib/test/test_tarfile.py (original) +++ python/branches/p3yk/Lib/test/test_tarfile.py Mon Jun 11 00:29:40 2007 @@ -164,7 +164,7 @@ def test_check_members(self): for tarinfo in self.tar: - self.assert_(int(tarinfo.mtime) == 07606136617, + self.assert_(int(tarinfo.mtime) == 0o7606136617, "wrong mtime for %s" % tarinfo.name) if not tarinfo.name.startswith("ustar/"): continue @@ -299,7 +299,7 @@ self.assert_(md5sum(self.tar.extractfile(tarinfo).read()) == chksum, "wrong md5sum for %s" % tarinfo.name) - kwargs["mtime"] = 07606136617 + kwargs["mtime"] = 0o7606136617 kwargs["uid"] = 1000 kwargs["gid"] = 100 if "old-v7" not in tarinfo.name: @@ -979,7 +979,7 @@ # uid > 8 digits tarinfo = tarfile.TarInfo("name") - tarinfo.uid = 010000000 + tarinfo.uid = 0o10000000 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT) def test_gnu_limits(self): @@ -992,7 +992,7 @@ # uid >= 256 ** 7 tarinfo = tarfile.TarInfo("name") - tarinfo.uid = 04000000000000000000 + tarinfo.uid = 0o4000000000000000000 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.GNU_FORMAT) def test_pax_limits(self): @@ -1004,7 +1004,7 @@ tarinfo.tobuf(tarfile.PAX_FORMAT) tarinfo = tarfile.TarInfo("name") - tarinfo.uid = 04000000000000000000 + tarinfo.uid = 0o4000000000000000000 tarinfo.tobuf(tarfile.PAX_FORMAT) Modified: python/branches/p3yk/Lib/test/test_tempfile.py ============================================================================== --- python/branches/p3yk/Lib/test/test_tempfile.py (original) +++ python/branches/p3yk/Lib/test/test_tempfile.py Mon Jun 11 00:29:40 2007 @@ -264,7 +264,7 @@ file = self.do_create() mode = stat.S_IMODE(os.stat(file.name).st_mode) - expected = 0600 + expected = 0o600 if sys.platform in ('win32', 'os2emx', 'mac'): # There's no distinction among 'user', 'group' and 'world'; # replicate the 'user' bits. @@ -482,8 +482,8 @@ dir = self.do_create() try: mode = stat.S_IMODE(os.stat(dir).st_mode) - mode &= 0777 # Mask off sticky bits inherited from /tmp - expected = 0700 + mode &= 0o777 # Mask off sticky bits inherited from /tmp + expected = 0o700 if sys.platform in ('win32', 'os2emx', 'mac'): # There's no distinction among 'user', 'group' and 'world'; # replicate the 'user' bits. @@ -517,7 +517,7 @@ self.name = tempfile.mktemp(dir=dir, prefix=pre, suffix=suf) # Create the file. This will raise an exception if it's # mysteriously appeared in the meanwhile. - os.close(os.open(self.name, self._bflags, 0600)) + os.close(os.open(self.name, self._bflags, 0o600)) def __del__(self): self._unlink(self.name) Modified: python/branches/p3yk/Lib/test/test_unicode_file.py ============================================================================== --- python/branches/p3yk/Lib/test/test_unicode_file.py (original) +++ python/branches/p3yk/Lib/test/test_unicode_file.py Mon Jun 11 00:29:40 2007 @@ -48,7 +48,7 @@ self.failUnless(os.path.exists(os.path.abspath(filename))) self.failUnless(os.path.isfile(os.path.abspath(filename))) self.failUnless(os.access(os.path.abspath(filename), os.R_OK)) - os.chmod(filename, 0777) + os.chmod(filename, 0o777) os.utime(filename, None) os.utime(filename, (time.time(), time.time())) # Copy/rename etc tests using the same filename Modified: python/branches/p3yk/Lib/test/test_uu.py ============================================================================== --- python/branches/p3yk/Lib/test/test_uu.py (original) +++ python/branches/p3yk/Lib/test/test_uu.py Mon Jun 11 00:29:40 2007 @@ -24,21 +24,21 @@ inp = cStringIO.StringIO(plaintext) out = cStringIO.StringIO() uu.encode(inp, out, "t1") - self.assertEqual(out.getvalue(), encodedtextwrapped % (0666, "t1")) + self.assertEqual(out.getvalue(), encodedtextwrapped % (0o666, "t1")) inp = cStringIO.StringIO(plaintext) out = cStringIO.StringIO() - uu.encode(inp, out, "t1", 0644) - self.assertEqual(out.getvalue(), encodedtextwrapped % (0644, "t1")) + uu.encode(inp, out, "t1", 0o644) + self.assertEqual(out.getvalue(), encodedtextwrapped % (0o644, "t1")) def test_decode(self): - inp = cStringIO.StringIO(encodedtextwrapped % (0666, "t1")) + inp = cStringIO.StringIO(encodedtextwrapped % (0o666, "t1")) out = cStringIO.StringIO() uu.decode(inp, out) self.assertEqual(out.getvalue(), plaintext) inp = cStringIO.StringIO( "UUencoded files may contain many lines,\n" + "even some that have 'begin' in them.\n" + - encodedtextwrapped % (0666, "t1") + encodedtextwrapped % (0o666, "t1") ) out = cStringIO.StringIO() uu.decode(inp, out) @@ -75,14 +75,14 @@ def test_encode(self): sys.stdin = cStringIO.StringIO(plaintext) sys.stdout = cStringIO.StringIO() - uu.encode("-", "-", "t1", 0666) + uu.encode("-", "-", "t1", 0o666) self.assertEqual( sys.stdout.getvalue(), - encodedtextwrapped % (0666, "t1") + encodedtextwrapped % (0o666, "t1") ) def test_decode(self): - sys.stdin = cStringIO.StringIO(encodedtextwrapped % (0666, "t1")) + sys.stdin = cStringIO.StringIO(encodedtextwrapped % (0o666, "t1")) sys.stdout = cStringIO.StringIO() uu.decode("-", "-") self.assertEqual(sys.stdout.getvalue(), plaintext) @@ -120,21 +120,21 @@ fin = open(self.tmpin, 'rb') fout = open(self.tmpout, 'w') - uu.encode(fin, fout, self.tmpin, mode=0644) + uu.encode(fin, fout, self.tmpin, mode=0o644) fin.close() fout.close() fout = open(self.tmpout, 'r') s = fout.read() fout.close() - self.assertEqual(s, encodedtextwrapped % (0644, self.tmpin)) + self.assertEqual(s, encodedtextwrapped % (0o644, self.tmpin)) # in_file and out_file as filenames - uu.encode(self.tmpin, self.tmpout, self.tmpin, mode=0644) + uu.encode(self.tmpin, self.tmpout, self.tmpin, mode=0o644) fout = open(self.tmpout, 'r') s = fout.read() fout.close() - self.assertEqual(s, encodedtextwrapped % (0644, self.tmpin)) + self.assertEqual(s, encodedtextwrapped % (0o644, self.tmpin)) finally: self._kill(fin) @@ -143,7 +143,7 @@ def test_decode(self): try: f = open(self.tmpin, 'w') - f.write(encodedtextwrapped % (0644, self.tmpout)) + f.write(encodedtextwrapped % (0o644, self.tmpout)) f.close() f = open(self.tmpin, 'r') @@ -161,7 +161,7 @@ def test_decodetwice(self): # Verify that decode() will refuse to overwrite an existing file try: - f = cStringIO.StringIO(encodedtextwrapped % (0644, self.tmpout)) + f = cStringIO.StringIO(encodedtextwrapped % (0o644, self.tmpout)) f = open(self.tmpin, 'r') uu.decode(f) Modified: python/branches/p3yk/Lib/test/test_xmlrpc.py ============================================================================== --- python/branches/p3yk/Lib/test/test_xmlrpc.py (original) +++ python/branches/p3yk/Lib/test/test_xmlrpc.py Mon Jun 11 00:29:40 2007 @@ -22,9 +22,9 @@ u'ukey\u4000': 'regular value', 'datetime1': xmlrpclib.DateTime('20050210T11:41:23'), 'datetime2': xmlrpclib.DateTime( - (2005, 02, 10, 11, 41, 23, 0, 1, -1)), + (2005, 2, 10, 11, 41, 23, 0, 1, -1)), 'datetime3': xmlrpclib.DateTime( - datetime.datetime(2005, 02, 10, 11, 41, 23)), + datetime.datetime(2005, 2, 10, 11, 41, 23)), }] class XMLRPCTestCase(unittest.TestCase): @@ -38,7 +38,7 @@ # by the marshalling code. This can't be done via test_dump_load() # since with use_datetime set to 1 the unmarshaller would create # datetime objects for the 'datetime[123]' keys as well - dt = datetime.datetime(2005, 02, 10, 11, 41, 23) + dt = datetime.datetime(2005, 2, 10, 11, 41, 23) s = xmlrpclib.dumps((dt,)) (newdt,), m = xmlrpclib.loads(s, use_datetime=1) self.assertEquals(newdt, dt) @@ -51,7 +51,7 @@ # This checks that an unwrapped datetime.date object can be handled # by the marshalling code. This can't be done via test_dump_load() # since the unmarshaller produces a datetime object - d = datetime.datetime(2005, 02, 10, 11, 41, 23).date() + d = datetime.datetime(2005, 2, 10, 11, 41, 23).date() s = xmlrpclib.dumps((d,)) (newd,), m = xmlrpclib.loads(s, use_datetime=1) self.assertEquals(newd.date(), d) @@ -65,7 +65,7 @@ # This checks that an unwrapped datetime.time object can be handled # by the marshalling code. This can't be done via test_dump_load() # since the unmarshaller produces a datetime object - t = datetime.datetime(2005, 02, 10, 11, 41, 23).time() + t = datetime.datetime(2005, 2, 10, 11, 41, 23).time() s = xmlrpclib.dumps((t,)) (newt,), m = xmlrpclib.loads(s, use_datetime=1) today = datetime.datetime.now().date().strftime("%Y%m%d") Modified: python/branches/p3yk/Lib/test/test_zipimport.py ============================================================================== --- python/branches/p3yk/Lib/test/test_zipimport.py (original) +++ python/branches/p3yk/Lib/test/test_zipimport.py Mon Jun 11 00:29:40 2007 @@ -364,7 +364,7 @@ finally: # If we leave "the read-only bit" set on Windows, nothing can # delete TESTMOD, and later tests suffer bogus failures. - os.chmod(TESTMOD, 0666) + os.chmod(TESTMOD, 0o666) test_support.unlink(TESTMOD) def testNotZipFile(self): Modified: python/branches/p3yk/Lib/test/tokenize_tests.txt ============================================================================== --- python/branches/p3yk/Lib/test/tokenize_tests.txt (original) +++ python/branches/p3yk/Lib/test/tokenize_tests.txt Mon Jun 11 00:29:40 2007 @@ -37,21 +37,21 @@ # Ordinary integers 0xff != 255 -0377 != 255 -2147483647 != 017777777777 --2147483647-1 != 020000000000 -037777777777 != -1 -0xffffffff != -1 +0o377 != 255 +2147483647 != 0o17777777777 +-2147483647-1 != 0o20000000000 +0o37777777777 != -1 +0xffffffff != -1; 0o37777777777 != -1; -0o1234567 == 0O001234567; 0b10101 == 0B00010101 # Long integers -x = 0L -x = 0l -x = 0xffffffffffffffffL -x = 0xffffffffffffffffl -x = 077777777777777777L -x = 077777777777777777l -x = 123456789012345678901234567890L -x = 123456789012345678901234567890l +x = 0 +x = 0 +x = 0xffffffffffffffff +x = 0xffffffffffffffff +x = 0o77777777777777777 +x = 0B11101010111111111 +x = 123456789012345678901234567890 +x = 123456789012345678901234567890 # Floating-point numbers x = 3.14 Modified: python/branches/p3yk/Lib/tokenize.py ============================================================================== --- python/branches/p3yk/Lib/tokenize.py (original) +++ python/branches/p3yk/Lib/tokenize.py Mon Jun 11 00:29:40 2007 @@ -49,10 +49,11 @@ Ignore = Whitespace + any(r'\\\r?\n' + Whitespace) + maybe(Comment) Name = r'[a-zA-Z_]\w*' -Hexnumber = r'0[xX][\da-fA-F]*[lL]?' -Octnumber = r'0[0-7]*[lL]?' -Decnumber = r'[1-9]\d*[lL]?' -Intnumber = group(Hexnumber, Octnumber, Decnumber) +Hexnumber = r'0[xX][\da-fA-F]*' +Binnumber = r'0[bB][01]*' +Octnumber = r'0[oO][0-7]*' +Decnumber = r'(?:0+|[1-9]\d*)' +Intnumber = group(Hexnumber, Binnumber, Octnumber, Decnumber) Exponent = r'[eE][-+]?\d+' Pointfloat = group(r'\d+\.\d*', r'\.\d+') + maybe(Exponent) Expfloat = r'\d+' + Exponent Modified: python/branches/p3yk/Lib/uu.py ============================================================================== --- python/branches/p3yk/Lib/uu.py (original) +++ python/branches/p3yk/Lib/uu.py Mon Jun 11 00:29:40 2007 @@ -68,11 +68,11 @@ if name is None: name = '-' if mode is None: - mode = 0666 + mode = 0o666 # # Write the data # - out_file.write('begin %o %s\n' % ((mode&0777),name)) + out_file.write('begin %o %s\n' % ((mode & 0o777),name)) data = in_file.read(45) while len(data) > 0: out_file.write(binascii.b2a_uu(data)) Modified: python/branches/p3yk/Misc/NEWS ============================================================================== --- python/branches/p3yk/Misc/NEWS (original) +++ python/branches/p3yk/Misc/NEWS Mon Jun 11 00:29:40 2007 @@ -26,6 +26,10 @@ Core and Builtins ----------------- +- PEP 3127: octal literals now start with "0o". Old-style octal literals + are invalid. There are binary literals with a prefix of "0b". + This also affects int(x, 0). + - None, True, False are now keywords. - PEP 3119: isinstance() and issubclass() can be overridden. Modified: python/branches/p3yk/Objects/longobject.c ============================================================================== --- python/branches/p3yk/Objects/longobject.c (original) +++ python/branches/p3yk/Objects/longobject.c Mon Jun 11 00:29:40 2007 @@ -1424,7 +1424,7 @@ /* Convert a long int object to a string, using a given conversion base. Return a string object. - If base is 8 or 16, add the proper prefix '0' or '0x'. */ + If base is 2, 8 or 16, add the proper prefix '0b', '0o' or '0x'. */ static PyObject * long_format(PyObject *aa, int base) @@ -1551,14 +1551,18 @@ Py_DECREF(scratch); } - if (base == 8) { - if (size_a != 0) - *--p = '0'; - } - else if (base == 16) { + if (base == 16) { *--p = 'x'; *--p = '0'; } + else if (base == 8) { + *--p = 'o'; + *--p = '0'; + } + else if (base == 2) { + *--p = 'b'; + *--p = '0'; + } else if (base != 10) { *--p = '#'; *--p = '0' + base%10; @@ -1675,9 +1679,9 @@ PyObject * PyLong_FromString(char *str, char **pend, int base) { - int sign = 1; + int sign = 1, error_if_nonzero = 0; char *start, *orig_str = str; - PyLongObject *z; + PyLongObject *z = NULL; PyObject *strobj, *strrepr; Py_ssize_t slen; @@ -1701,10 +1705,21 @@ base = 10; else if (str[1] == 'x' || str[1] == 'X') base = 16; - else + else if (str[1] == 'o' || str[1] == 'O') base = 8; + else if (str[1] == 'b' || str[1] == 'B') + base = 2; + else { + /* "old" (C-style) octal literal, now invalid. + it might still be zero though */ + error_if_nonzero = 1; + base = 10; + } } - if (base == 16 && str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) + if (str[0] == '0' && + ((base == 16 && (str[1] == 'x' || str[1] == 'X')) || + (base == 8 && (str[1] == 'o' || str[1] == 'O')) || + (base == 2 && (str[1] == 'b' || str[1] == 'B')))) str += 2; start = str; @@ -1908,6 +1923,15 @@ } if (z == NULL) return NULL; + if (error_if_nonzero) { + /* reset the base to 0, else the exception message + doesn't make too much sense */ + base = 0; + if (z->ob_size != 0) + goto onError; + /* there might still be other problems, therefore base + remains zero here for the same reason */ + } if (str == start) goto onError; if (sign < 0) Modified: python/branches/p3yk/Objects/stringobject.c ============================================================================== --- python/branches/p3yk/Objects/stringobject.c (original) +++ python/branches/p3yk/Objects/stringobject.c Mon Jun 11 00:29:40 2007 @@ -4243,6 +4243,7 @@ result = val->ob_type->tp_str(val); break; case 'o': + numnondigits = 2; result = val->ob_type->tp_as_number->nb_oct(val); break; case 'x': @@ -4283,32 +4284,16 @@ assert(numdigits > 0); /* Get rid of base marker unless F_ALT */ - if ((flags & F_ALT) == 0) { - /* Need to skip 0x, 0X or 0. */ - int skipped = 0; - switch (type) { - case 'o': - assert(buf[sign] == '0'); - /* If 0 is only digit, leave it alone. */ - if (numdigits > 1) { - skipped = 1; - --numdigits; - } - break; - case 'x': - case 'X': - assert(buf[sign] == '0'); - assert(buf[sign + 1] == 'x'); - skipped = 2; - numnondigits -= 2; - break; - } - if (skipped) { - buf += skipped; - len -= skipped; - if (sign) - buf[0] = '-'; - } + if (((flags & F_ALT) == 0 && + (type == 'o' || type == 'x' || type == 'X'))) { + assert(buf[sign] == '0'); + assert(buf[sign+1] == 'x' || buf[sign+1] == 'X' || + buf[sign+1] == 'o'); + numnondigits -= 2; + buf += 2; + len -= 2; + if (sign) + buf[0] = '-'; assert(len == numnondigits + numdigits); assert(numdigits > 0); } @@ -4377,9 +4362,10 @@ prec = 1; if ((flags & F_ALT) && - (type == 'x' || type == 'X')) { - /* When converting under %#x or %#X, there are a number + (type == 'x' || type == 'X' || type == 'o')) { + /* When converting under %#o, %#x or %#X, there are a number * of issues that cause pain: + * - for %#o, we want a different base marker than C * - when 0 is being converted, the C standard leaves off * the '0x' or '0X', which is inconsistent with other * %#x/%#X conversions and inconsistent with Python's @@ -4407,7 +4393,7 @@ prec, type); } - /* buf = '+'/'-'/'' + '0'/'0x'/'' + '[0-9]'*max(prec, len(x in octal)) + /* buf = '+'/'-'/'' + '0o'/'0x'/'' + '[0-9]'*max(prec, len(x in octal)) * worst case buf = '-0x' + [0-9]*prec, where prec >= 11 */ if (buflen <= 14 || buflen <= (size_t)3 + (size_t)prec) { @@ -4805,7 +4791,8 @@ if (width > len) width--; } - if ((flags & F_ALT) && (c == 'x' || c == 'X')) { + if ((flags & F_ALT) && + (c == 'x' || c == 'X' || c == 'o')) { assert(pbuf[0] == '0'); assert(pbuf[1] == c); if (fill != ' ') { @@ -4828,7 +4815,7 @@ if (sign) *res++ = sign; if ((flags & F_ALT) && - (c == 'x' || c == 'X')) { + (c == 'x' || c == 'X' || c == 'o')) { assert(pbuf[0] == '0'); assert(pbuf[1] == c); *res++ = *pbuf++; Modified: python/branches/p3yk/Objects/unicodeobject.c ============================================================================== --- python/branches/p3yk/Objects/unicodeobject.c (original) +++ python/branches/p3yk/Objects/unicodeobject.c Mon Jun 11 00:29:40 2007 @@ -7354,9 +7354,10 @@ } if ((flags & F_ALT) && - (type == 'x' || type == 'X')) { - /* When converting under %#x or %#X, there are a number + (type == 'x' || type == 'X' || type == 'o')) { + /* When converting under %#o, %#x or %#X, there are a number * of issues that cause pain: + * - for %#o, we want a different base marker than C * - when 0 is being converted, the C standard leaves off * the '0x' or '0X', which is inconsistent with other * %#x/%#X conversions and inconsistent with Python's @@ -7814,7 +7815,7 @@ if (width > len) width--; } - if ((flags & F_ALT) && (c == 'x' || c == 'X')) { + if ((flags & F_ALT) && (c == 'x' || c == 'X' || c == 'o')) { assert(pbuf[0] == '0'); assert(pbuf[1] == c); if (fill != ' ') { @@ -7836,7 +7837,7 @@ if (fill == ' ') { if (sign) *res++ = sign; - if ((flags & F_ALT) && (c == 'x' || c == 'X')) { + if ((flags & F_ALT) && (c == 'x' || c == 'X' || c == 'o')) { assert(pbuf[0] == '0'); assert(pbuf[1] == c); *res++ = *pbuf++; Modified: python/branches/p3yk/Python/ast.c ============================================================================== --- python/branches/p3yk/Python/ast.c (original) +++ python/branches/p3yk/Python/ast.c Mon Jun 11 00:29:40 2007 @@ -3029,8 +3029,6 @@ #ifndef WITHOUT_COMPLEX imflag = *end == 'j' || *end == 'J'; #endif - if (*end == 'l' || *end == 'L') - return PyLong_FromString((char *)s, (char **)0, 0); if (s[0] == '0') { x = (long) PyOS_strtoul((char *)s, (char **)&end, 0); if (x < 0 && errno == 0) { Modified: python/branches/p3yk/Python/mystrtoul.c ============================================================================== --- python/branches/p3yk/Python/mystrtoul.c (original) +++ python/branches/p3yk/Python/mystrtoul.c Mon Jun 11 00:29:40 2007 @@ -91,7 +91,7 @@ ** This is a general purpose routine for converting ** an ascii string to an integer in an arbitrary base. ** Leading white space is ignored. If 'base' is zero -** it looks for a leading 0, 0x or 0X to tell which +** it looks for a leading 0b, 0o or 0x to tell which ** base. If these are absent it defaults to 10. ** Base must be 0 or between 2 and 36 (inclusive). ** If 'ptr' is non-NULL it will contain a pointer to @@ -110,29 +110,57 @@ while (*str && isspace(Py_CHARMASK(*str))) ++str; - /* check for leading 0 or 0x for auto-base or base 16 */ + /* check for leading 0b, 0o or 0x for auto-base or base 16 */ switch (base) { - case 0: /* look for leading 0, 0x or 0X */ - if (*str == '0') { + case 0: /* look for leading 0b, 0o or 0x */ + if (*str == '0') { + ++str; + if (*str == 'x' || *str == 'X') { ++str; - if (*str == 'x' || *str == 'X') { - ++str; - base = 16; - } - else - base = 8; - } - else - base = 10; - break; - - case 16: /* skip leading 0x or 0X */ - if (*str == '0') { + base = 16; + } else if (*str == 'o' || *str == 'O') { ++str; - if (*str == 'x' || *str == 'X') + base = 8; + } else if (*str == 'b' || *str == 'B') { + ++str; + base = 2; + } else { + /* skip all zeroes... */ + while (*str == '0') + ++str; + while (isspace(Py_CHARMASK(*str))) ++str; + if (ptr) + *ptr = str; + return 0; } - break; + } + else + base = 10; + break; + + /* even with explicit base, skip leading 0? prefix */ + case 16: + if (*str == '0') { + ++str; + if (*str == 'x' || *str == 'X') + ++str; + } + break; + case 8: + if (*str == '0') { + ++str; + if (*str == 'o' || *str == 'O') + ++str; + } + break; + case 2: + if(*str == '0') { + ++str; + if (*str == 'b' || *str == 'B') + ++str; + } + break; } /* catch silly bases */ Modified: python/branches/p3yk/setup.py ============================================================================== --- python/branches/p3yk/setup.py (original) +++ python/branches/p3yk/setup.py Mon Jun 11 00:29:40 2007 @@ -1499,8 +1499,8 @@ def install(self): outfiles = install_lib.install(self) - self.set_file_modes(outfiles, 0644, 0755) - self.set_dir_modes(self.install_dir, 0755) + self.set_file_modes(outfiles, 0o644, 0o755) + self.set_dir_modes(self.install_dir, 0o755) return outfiles def set_file_modes(self, files, defaultMode, sharedLibMode): From python-3000-checkins at python.org Mon Jun 11 00:31:45 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Mon, 11 Jun 2007 00:31:45 +0200 (CEST) Subject: [Python-3000-checkins] r55865 - in python/branches/p3yk/Tools: i18n/msgfmt.py pybench/Arithmetic.py pybench/CommandLine.py pybench/Numbers.py pybench/systimes.py scripts/classfix.py scripts/fixcid.py scripts/ftpmirror.py scripts/linktree.py scripts/methfix.py scripts/pathfix.py scripts/which.py unicode/makeunicodedata.py webchecker/websucker.py Message-ID: <20070610223145.E00171E4008@bag.python.org> Author: georg.brandl Date: Mon Jun 11 00:31:37 2007 New Revision: 55865 Modified: python/branches/p3yk/Tools/i18n/msgfmt.py python/branches/p3yk/Tools/pybench/Arithmetic.py python/branches/p3yk/Tools/pybench/CommandLine.py python/branches/p3yk/Tools/pybench/Numbers.py python/branches/p3yk/Tools/pybench/systimes.py python/branches/p3yk/Tools/scripts/classfix.py python/branches/p3yk/Tools/scripts/fixcid.py python/branches/p3yk/Tools/scripts/ftpmirror.py python/branches/p3yk/Tools/scripts/linktree.py python/branches/p3yk/Tools/scripts/methfix.py python/branches/p3yk/Tools/scripts/pathfix.py python/branches/p3yk/Tools/scripts/which.py python/branches/p3yk/Tools/unicode/makeunicodedata.py python/branches/p3yk/Tools/webchecker/websucker.py Log: Some octal literal fixes in Tools. Modified: python/branches/p3yk/Tools/i18n/msgfmt.py ============================================================================== --- python/branches/p3yk/Tools/i18n/msgfmt.py (original) +++ python/branches/p3yk/Tools/i18n/msgfmt.py Mon Jun 11 00:31:37 2007 @@ -83,7 +83,7 @@ voffsets += [l2, o2+valuestart] offsets = koffsets + voffsets output = struct.pack("Iiiiiii", - 0x950412deL, # Magic + 0x950412de, # Magic 0, # Version len(keys), # # of entries 7*4, # start of key index Modified: python/branches/p3yk/Tools/pybench/Arithmetic.py ============================================================================== --- python/branches/p3yk/Tools/pybench/Arithmetic.py (original) +++ python/branches/p3yk/Tools/pybench/Arithmetic.py Mon Jun 11 00:31:37 2007 @@ -476,9 +476,9 @@ for i in range(self.rounds): - a = 2220001L - b = 100001L - c = 30005L + a = 2220001 + b = 100001 + c = 30005 c = a + b c = b + c @@ -504,9 +504,9 @@ c = b / a c = c / b - a = 2220001L - b = 100001L - c = 30005L + a = 2220001 + b = 100001 + c = 30005 c = a + b c = b + c @@ -532,9 +532,9 @@ c = b / a c = c / b - a = 2220001L - b = 100001L - c = 30005L + a = 2220001 + b = 100001 + c = 30005 c = a + b c = b + c @@ -560,9 +560,9 @@ c = b / a c = c / b - a = 2220001L - b = 100001L - c = 30005L + a = 2220001 + b = 100001 + c = 30005 c = a + b c = b + c @@ -588,9 +588,9 @@ c = b / a c = c / b - a = 2220001L - b = 100001L - c = 30005L + a = 2220001 + b = 100001 + c = 30005 c = a + b c = b + c Modified: python/branches/p3yk/Tools/pybench/CommandLine.py ============================================================================== --- python/branches/p3yk/Tools/pybench/CommandLine.py (original) +++ python/branches/p3yk/Tools/pybench/CommandLine.py Mon Jun 11 00:31:37 2007 @@ -82,7 +82,7 @@ else: f = open(name, mode) if 'w' in mode: - os.chmod(name, 0600) + os.chmod(name, 0o600) return f def option_dict(options): Modified: python/branches/p3yk/Tools/pybench/Numbers.py ============================================================================== --- python/branches/p3yk/Tools/pybench/Numbers.py (original) +++ python/branches/p3yk/Tools/pybench/Numbers.py Mon Jun 11 00:31:37 2007 @@ -598,185 +598,185 @@ for i in range(self.rounds): - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 def calibrate(self): Modified: python/branches/p3yk/Tools/pybench/systimes.py ============================================================================== --- python/branches/p3yk/Tools/pybench/systimes.py (original) +++ python/branches/p3yk/Tools/pybench/systimes.py Mon Jun 11 00:31:37 2007 @@ -180,9 +180,9 @@ ### Testing def some_workload(): - x = 0L - for i in range(10000000L): - x = x + 1L + x = 0 + for i in range(10000000): + x = x + 1 def test_workload(): print 'Testing systimes() under load conditions' Modified: python/branches/p3yk/Tools/scripts/classfix.py ============================================================================== --- python/branches/p3yk/Tools/scripts/classfix.py (original) +++ python/branches/p3yk/Tools/scripts/classfix.py Mon Jun 11 00:31:37 2007 @@ -129,7 +129,7 @@ # First copy the file's mode to the temp file try: statbuf = os.stat(filename) - os.chmod(tempname, statbuf[ST_MODE] & 07777) + os.chmod(tempname, statbuf[ST_MODE] & 0o7777) except os.error as msg: err('%s: warning: chmod failed (%r)\n' % (tempname, msg)) # Then make a backup of the original file as filename~ Modified: python/branches/p3yk/Tools/scripts/fixcid.py ============================================================================== --- python/branches/p3yk/Tools/scripts/fixcid.py (original) +++ python/branches/p3yk/Tools/scripts/fixcid.py Mon Jun 11 00:31:37 2007 @@ -174,7 +174,7 @@ # First copy the file's mode to the temp file try: statbuf = os.stat(filename) - os.chmod(tempname, statbuf[ST_MODE] & 07777) + os.chmod(tempname, statbuf[ST_MODE] & 0o7777) except os.error as msg: err(tempname + ': warning: chmod failed (' + str(msg) + ')\n') # Then make a backup of the original file as filename~ Modified: python/branches/p3yk/Tools/scripts/ftpmirror.py ============================================================================== --- python/branches/p3yk/Tools/scripts/ftpmirror.py (original) +++ python/branches/p3yk/Tools/scripts/ftpmirror.py Mon Jun 11 00:31:37 2007 @@ -375,7 +375,7 @@ return dirname = os.path.dirname(pathname) if dirname: makedir(dirname) - os.mkdir(pathname, 0777) + os.mkdir(pathname, 0o777) # Write a dictionary to a file in a way that can be read back using # rval() but is still somewhat readable (i.e. not a single long line). Modified: python/branches/p3yk/Tools/scripts/linktree.py ============================================================================== --- python/branches/p3yk/Tools/scripts/linktree.py (original) +++ python/branches/p3yk/Tools/scripts/linktree.py Mon Jun 11 00:31:37 2007 @@ -31,7 +31,7 @@ print oldtree + ': not a directory' return 1 try: - os.mkdir(newtree, 0777) + os.mkdir(newtree, 0o777) except os.error as msg: print newtree + ': cannot mkdir:', msg return 1 @@ -63,7 +63,7 @@ if os.path.isdir(oldname) and \ not os.path.islink(oldname): try: - os.mkdir(newname, 0777) + os.mkdir(newname, 0o777) ok = 1 except: print newname + \ Modified: python/branches/p3yk/Tools/scripts/methfix.py ============================================================================== --- python/branches/p3yk/Tools/scripts/methfix.py (original) +++ python/branches/p3yk/Tools/scripts/methfix.py Mon Jun 11 00:31:37 2007 @@ -140,7 +140,7 @@ # First copy the file's mode to the temp file try: statbuf = os.stat(filename) - os.chmod(tempname, statbuf[ST_MODE] & 07777) + os.chmod(tempname, statbuf[ST_MODE] & 0o7777) except os.error as msg: err('%s: warning: chmod failed (%r)\n' % (tempname, msg)) # Then make a backup of the original file as filename~ Modified: python/branches/p3yk/Tools/scripts/pathfix.py ============================================================================== --- python/branches/p3yk/Tools/scripts/pathfix.py (original) +++ python/branches/p3yk/Tools/scripts/pathfix.py Mon Jun 11 00:31:37 2007 @@ -121,7 +121,7 @@ # First copy the file's mode to the temp file try: statbuf = os.stat(filename) - os.chmod(tempname, statbuf[ST_MODE] & 07777) + os.chmod(tempname, statbuf[ST_MODE] & 0o7777) except os.error as msg: err('%s: warning: chmod failed (%r)\n' % (tempname, msg)) # Then make a backup of the original file as filename~ Modified: python/branches/p3yk/Tools/scripts/which.py ============================================================================== --- python/branches/p3yk/Tools/scripts/which.py (original) +++ python/branches/p3yk/Tools/scripts/which.py Mon Jun 11 00:31:37 2007 @@ -35,7 +35,7 @@ msg(filename + ': not a disk file') else: mode = S_IMODE(st[ST_MODE]) - if mode & 0111: + if mode & 0o111: if not ident: print filename ident = st[:3] Modified: python/branches/p3yk/Tools/unicode/makeunicodedata.py ============================================================================== --- python/branches/p3yk/Tools/unicode/makeunicodedata.py (original) +++ python/branches/p3yk/Tools/unicode/makeunicodedata.py Mon Jun 11 00:31:37 2007 @@ -757,7 +757,7 @@ h = 0 for c in map(ord, s.upper()): h = (h * magic) + c - ix = h & 0xff000000L + ix = h & 0xff000000 if ix: h = (h ^ ((ix>>24) & 0xff)) & 0x00ffffff return h Modified: python/branches/p3yk/Tools/webchecker/websucker.py ============================================================================== --- python/branches/p3yk/Tools/webchecker/websucker.py (original) +++ python/branches/p3yk/Tools/webchecker/websucker.py Mon Jun 11 00:31:37 2007 @@ -119,7 +119,7 @@ print "Huh? Don't know how to make dir", dir return makedirs(head) - os.mkdir(dir, 0777) + os.mkdir(dir, 0o777) if __name__ == '__main__': sys.exit(main() or 0) From python-3000-checkins at python.org Mon Jun 11 00:37:45 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Mon, 11 Jun 2007 00:37:45 +0200 (CEST) Subject: [Python-3000-checkins] r55866 - python/branches/p3yk/Parser/tokenizer.c Message-ID: <20070610223745.BA9621E400C@bag.python.org> Author: georg.brandl Date: Mon Jun 11 00:37:43 2007 New Revision: 55866 Modified: python/branches/p3yk/Parser/tokenizer.c Log: Tokenizer changes for PEP 3127. Modified: python/branches/p3yk/Parser/tokenizer.c ============================================================================== --- python/branches/p3yk/Parser/tokenizer.c (original) +++ python/branches/p3yk/Parser/tokenizer.c Mon Jun 11 00:37:43 2007 @@ -1310,7 +1310,7 @@ /* Number */ if (isdigit(c)) { if (c == '0') { - /* Hex or octal -- maybe. */ + /* Hex, octal or binary -- maybe. */ c = tok_nextc(tok); if (c == '.') goto fraction; @@ -1324,18 +1324,27 @@ c = tok_nextc(tok); } while (isxdigit(c)); } + else if (c == 'o' || c == 'O') { + /* Octal */ + do { + c = tok_nextc(tok); + } while ('0' <= c && c < '8'); + } + else if (c == 'b' || c == 'B') { + /* Binary */ + do { + c = tok_nextc(tok); + } while (c == '0' || c == '1'); + } else { - int found_decimal = 0; - /* Octal; c is first char of it */ - /* There's no 'isoctdigit' macro, sigh */ - while ('0' <= c && c < '8') { + int nonzero = 0; + /* maybe old-style octal; c is first char of it */ + /* in any case, allow '0' as a literal */ + while (c == '0') + c = tok_nextc(tok); + while (isdigit(c)) { + nonzero = 1; c = tok_nextc(tok); - } - if (isdigit(c)) { - found_decimal = 1; - do { - c = tok_nextc(tok); - } while (isdigit(c)); } if (c == '.') goto fraction; @@ -1345,7 +1354,7 @@ else if (c == 'j' || c == 'J') goto imaginary; #endif - else if (found_decimal) { + else if (nonzero) { tok->done = E_TOKEN; tok_backup(tok, c); return ERRORTOKEN; From python-3000-checkins at python.org Mon Jun 11 00:37:56 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Mon, 11 Jun 2007 00:37:56 +0200 (CEST) Subject: [Python-3000-checkins] r55867 - python/branches/p3yk/Doc/ref/ref2.tex Message-ID: <20070610223756.275891E4008@bag.python.org> Author: georg.brandl Date: Mon Jun 11 00:37:55 2007 New Revision: 55867 Modified: python/branches/p3yk/Doc/ref/ref2.tex Log: Some docs for PEP 3127. Modified: python/branches/p3yk/Doc/ref/ref2.tex ============================================================================== --- python/branches/p3yk/Doc/ref/ref2.tex (original) +++ python/branches/p3yk/Doc/ref/ref2.tex Mon Jun 11 00:37:55 2007 @@ -565,6 +565,7 @@ \index{floating point literal} \index{hexadecimal literal} \index{octal literal} +\index{binary literal} \index{decimal literal} \index{imaginary literal} \index{complex!literal} @@ -574,35 +575,32 @@ `\code{-}' and the literal \code{1}. -\subsection{Integer and long integer literals\label{integers}} +\subsection{Integer literals\label{integers}} -Integer and long integer literals are described by the following +Integer literals are described by the following lexical definitions: \begin{productionlist} - \production{longinteger} - {\token{integer} ("l" | "L")} \production{integer} {\token{decimalinteger} | \token{octinteger} | \token{hexinteger}} \production{decimalinteger} - {\token{nonzerodigit} \token{digit}* | "0"} + {\token{nonzerodigit} \token{digit}* | "0"+} \production{octinteger} - {"0" \token{octdigit}+} + {"0" ("o" | "O") \token{octdigit}+} \production{hexinteger} {"0" ("x" | "X") \token{hexdigit}+} + \production{bininteger} + {"0" ("b" | "B") \token{bindigit}+} \production{nonzerodigit} {"1"..."9"} \production{octdigit} {"0"..."7"} \production{hexdigit} {\token{digit} | "a"..."f" | "A"..."F"} + \production{bindigit} + {"0"..."1"} \end{productionlist} -Although both lower case \character{l} and upper case \character{L} are -allowed as suffix for long integers, it is strongly recommended to always -use \character{L}, since the letter \character{l} looks too much like the -digit \character{1}. - Plain integer literals that are above the largest representable plain integer (e.g., 2147483647 when using 32-bit arithmetic) are accepted as if they were long integers instead.\footnote{In versions of Python @@ -613,13 +611,16 @@ from their unsigned value.} There is no limit for long integer literals apart from what can be stored in available memory. -Some examples of plain integer literals (first row) and long integer -literals (second and third rows): +Note that leading zeros in a non-zero decimal number are not allowed. +This is for disambiguation with C-style octal literals, which Python +used before version 3.0. + +Some examples of integer literals: \begin{verbatim} -7 2147483647 0177 -3L 79228162514264337593543950336L 0377L 0x100000000L - 79228162514264337593543950336 0xdeadbeef +7 2147483647 0o177 0b100110111 +3 79228162514264337593543950336 0o377 0x100000000 + 79228162514264337593543950336 0xdeadbeef \end{verbatim} @@ -644,12 +645,10 @@ {("e" | "E") ["+" | "-"] \token{digit}+} \end{productionlist} -Note that the integer and exponent parts of floating point numbers -can look like octal integers, but are interpreted using radix 10. For -example, \samp{077e010} is legal, and denotes the same number -as \samp{77e10}. -The allowed range of floating point literals is -implementation-dependent. +Note that the integer and exponent parts are always interpreted using +radix 10. For example, \samp{077e010} is legal, and denotes the same +number as \samp{77e10}. +The allowed range of floating point literals is implementation-dependent. Some examples of floating point literals: \begin{verbatim} From nnorwitz at gmail.com Mon Jun 11 00:43:54 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sun, 10 Jun 2007 15:43:54 -0700 Subject: [Python-3000-checkins] r55865 - in python/branches/p3yk/Tools: i18n/msgfmt.py pybench/Arithmetic.py pybench/CommandLine.py pybench/Numbers.py pybench/systimes.py scripts/classfix.py scripts/fixcid.py scripts/ftpmirror.py scripts/linktree.py scrip Message-ID: On 6/10/07, georg.brandl wrote: > Author: georg.brandl > Date: Mon Jun 11 00:31:37 2007 > New Revision: 55865 > > Log: > Some octal literal fixes in Tools. > > > Modified: python/branches/p3yk/Tools/pybench/Numbers.py > ============================================================================== > --- python/branches/p3yk/Tools/pybench/Numbers.py (original) > +++ python/branches/p3yk/Tools/pybench/Numbers.py Mon Jun 11 00:31:37 2007 > ... > - 1234567890L < 3456789012345L > - 1234567890L > 3456789012345L > - 1234567890L == 3456789012345L > - 1234567890L > 3456789012345L > - 1234567890L < 3456789012345L > + 1234567890 < 3456789012345 > + 1234567890 > 3456789012345 > + 1234567890 == 3456789012345 > + 1234567890 > 3456789012345 > + 1234567890 < 3456789012345 > ... This changes the semantics for this test on 64-bit boxes. Well, kinda. It was comparing between ints and longs before this change. At least, that was the original intent. I'm not sure how much that even made sense since ints and longs were unified. I assume there are str/uni tests in pybench as well. These won't make sense once strings and unicode are merged. n From python-3000-checkins at python.org Mon Jun 11 00:44:43 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Mon, 11 Jun 2007 00:44:43 +0200 (CEST) Subject: [Python-3000-checkins] r55868 - python/branches/p3yk/Objects/intobject.c Message-ID: <20070610224443.E704D1E4008@bag.python.org> Author: georg.brandl Date: Mon Jun 11 00:44:39 2007 New Revision: 55868 Modified: python/branches/p3yk/Objects/intobject.c Log: Missed a place in intobject.c. Is that used anymore anyway? Modified: python/branches/p3yk/Objects/intobject.c ============================================================================== --- python/branches/p3yk/Objects/intobject.c (original) +++ python/branches/p3yk/Objects/intobject.c Mon Jun 11 00:44:39 2007 @@ -927,11 +927,9 @@ char buf[100]; long x = v -> ob_ival; if (x < 0) - PyOS_snprintf(buf, sizeof(buf), "-0%lo", -x); - else if (x == 0) - strcpy(buf, "0"); + PyOS_snprintf(buf, sizeof(buf), "-0o%lo", -x); else - PyOS_snprintf(buf, sizeof(buf), "0%lo", x); + PyOS_snprintf(buf, sizeof(buf), "0o%lo", x); return PyString_FromString(buf); } From guido at python.org Mon Jun 11 00:52:05 2007 From: guido at python.org (Guido van Rossum) Date: Sun, 10 Jun 2007 15:52:05 -0700 Subject: [Python-3000-checkins] r55868 - python/branches/p3yk/Objects/intobject.c In-Reply-To: <20070610224443.E704D1E4008@bag.python.org> References: <20070610224443.E704D1E4008@bag.python.org> Message-ID: No, intobject.c has #if 0 at the top and a matching #endif at the bottom. I don't know what it hasn't been removed -- Martin? On 6/10/07, georg.brandl wrote: > Author: georg.brandl > Date: Mon Jun 11 00:44:39 2007 > New Revision: 55868 > > Modified: > python/branches/p3yk/Objects/intobject.c > Log: > Missed a place in intobject.c. Is that used anymore anyway? > > > Modified: python/branches/p3yk/Objects/intobject.c > ============================================================================== > --- python/branches/p3yk/Objects/intobject.c (original) > +++ python/branches/p3yk/Objects/intobject.c Mon Jun 11 00:44:39 2007 > @@ -927,11 +927,9 @@ > char buf[100]; > long x = v -> ob_ival; > if (x < 0) > - PyOS_snprintf(buf, sizeof(buf), "-0%lo", -x); > - else if (x == 0) > - strcpy(buf, "0"); > + PyOS_snprintf(buf, sizeof(buf), "-0o%lo", -x); > else > - PyOS_snprintf(buf, sizeof(buf), "0%lo", x); > + PyOS_snprintf(buf, sizeof(buf), "0o%lo", x); > return PyString_FromString(buf); > } > > _______________________________________________ > 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 nnorwitz at gmail.com Mon Jun 11 03:11:35 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sun, 10 Jun 2007 21:11:35 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures refleak (1) Message-ID: <20070611011135.GA31888@python.psfb.org> test_collections leaked [46, 46, 46] references, sum=138 From python-3000-checkins at python.org Mon Jun 11 03:32:12 2007 From: python-3000-checkins at python.org (neal.norwitz) Date: Mon, 11 Jun 2007 03:32:12 +0200 (CEST) Subject: [Python-3000-checkins] r55871 - in python/branches/p3yk: Doc/lib/libctypes.tex Doc/lib/libthreading.tex Doc/lib/liburllib2.tex Doc/whatsnew/whatsnew26.tex Include/pyport.h Lib/_strptime.py Lib/ctypes/test/test_numbers.py Lib/distutils/command/build_py.py Lib/distutils/tests/test_build_py.py Lib/ftplib.py Lib/test/test_compile.py Lib/test/test_multibytecodec.py Lib/test/test_str.py Lib/test/test_strptime.py Lib/test/test_structmembers.py Lib/test/test_threading.py Lib/test/test_unicode.py Lib/test/test_urllib2.py Lib/test/test_urllib2_localnet.py Lib/test/test_urllib2net.py Lib/threading.py Lib/urllib2.py Misc/ACKS Modules/_bsddb.c Modules/_ctypes/_ctypes.c Modules/_ctypes/callbacks.c Modules/_ctypes/callproc.c Modules/_ctypes/cfield.c Modules/_ctypes/ctypes.h Modules/_ctypes/libffi/src/x86/ffi.c Modules/_ctypes/libffi/src/x86/ffi64.c Modules/_ctypes/stgdict.c Modules/_sqlite/cache.c Modules/_testcapimodule.c Modules/cjkcodecs/multibytecodec.c Modules/getbuildinfo.c Modules/socketmodule.c Objects/bufferobject.c Objects/stringobject.c Objects/unicodeobject.c PC/pyconfig.h PCbuild/pcbuild.sln Python/ast.c Python/compile.c Python/peephole.c Python/structmember.c README Tools/buildbot/build-amd64.bat Tools/buildbot/clean-amd64.bat Tools/buildbot/test-amd64.bat Tools/scripts/reindent.py configure configure.in Message-ID: <20070611013212.C39271E400A@bag.python.org> Author: neal.norwitz Date: Mon Jun 11 03:31:49 2007 New Revision: 55871 Added: python/branches/p3yk/Lib/test/test_urllib2_localnet.py - copied, changed from r55860, python/trunk/Lib/test/test_urllib2_localnet.py python/branches/p3yk/Tools/buildbot/build-amd64.bat - copied unchanged from r55860, python/trunk/Tools/buildbot/build-amd64.bat python/branches/p3yk/Tools/buildbot/clean-amd64.bat - copied unchanged from r55860, python/trunk/Tools/buildbot/clean-amd64.bat python/branches/p3yk/Tools/buildbot/test-amd64.bat - copied unchanged from r55860, python/trunk/Tools/buildbot/test-amd64.bat Modified: python/branches/p3yk/ (props changed) python/branches/p3yk/Doc/lib/libctypes.tex python/branches/p3yk/Doc/lib/libthreading.tex python/branches/p3yk/Doc/lib/liburllib2.tex python/branches/p3yk/Doc/whatsnew/whatsnew26.tex python/branches/p3yk/Include/pyport.h python/branches/p3yk/Lib/_strptime.py python/branches/p3yk/Lib/ctypes/test/test_numbers.py python/branches/p3yk/Lib/distutils/command/build_py.py python/branches/p3yk/Lib/distutils/tests/test_build_py.py python/branches/p3yk/Lib/ftplib.py python/branches/p3yk/Lib/test/test_compile.py python/branches/p3yk/Lib/test/test_multibytecodec.py python/branches/p3yk/Lib/test/test_str.py python/branches/p3yk/Lib/test/test_strptime.py python/branches/p3yk/Lib/test/test_structmembers.py python/branches/p3yk/Lib/test/test_threading.py python/branches/p3yk/Lib/test/test_unicode.py python/branches/p3yk/Lib/test/test_urllib2.py python/branches/p3yk/Lib/test/test_urllib2net.py python/branches/p3yk/Lib/threading.py python/branches/p3yk/Lib/urllib2.py python/branches/p3yk/Misc/ACKS python/branches/p3yk/Modules/_bsddb.c python/branches/p3yk/Modules/_ctypes/_ctypes.c python/branches/p3yk/Modules/_ctypes/callbacks.c python/branches/p3yk/Modules/_ctypes/callproc.c python/branches/p3yk/Modules/_ctypes/cfield.c python/branches/p3yk/Modules/_ctypes/ctypes.h python/branches/p3yk/Modules/_ctypes/libffi/src/x86/ffi.c python/branches/p3yk/Modules/_ctypes/libffi/src/x86/ffi64.c python/branches/p3yk/Modules/_ctypes/stgdict.c python/branches/p3yk/Modules/_sqlite/cache.c python/branches/p3yk/Modules/_testcapimodule.c python/branches/p3yk/Modules/cjkcodecs/multibytecodec.c python/branches/p3yk/Modules/getbuildinfo.c python/branches/p3yk/Modules/socketmodule.c python/branches/p3yk/Objects/bufferobject.c python/branches/p3yk/Objects/stringobject.c python/branches/p3yk/Objects/unicodeobject.c python/branches/p3yk/PC/pyconfig.h python/branches/p3yk/PCbuild/pcbuild.sln python/branches/p3yk/Python/ast.c python/branches/p3yk/Python/compile.c python/branches/p3yk/Python/peephole.c python/branches/p3yk/Python/structmember.c python/branches/p3yk/README python/branches/p3yk/Tools/scripts/reindent.py (props changed) python/branches/p3yk/configure python/branches/p3yk/configure.in Log: Merged revisions 55729-55868 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r55731 | neal.norwitz | 2007-06-01 00:29:12 -0700 (Fri, 01 Jun 2007) | 7 lines SF 1668596/1720897: distutils now copies data files even if package_dir is empty. This needs to be backported. I'm too tired tonight. It would be great if someone backports this if the buildbots are ok with it. Otherwise, I will try to get to it tomorrow. ........ r55732 | georg.brandl | 2007-06-01 04:33:33 -0700 (Fri, 01 Jun 2007) | 2 lines Bug #1722484: remove docstrings again when running with -OO. ........ r55735 | georg.brandl | 2007-06-01 12:20:27 -0700 (Fri, 01 Jun 2007) | 2 lines Fix wrong issue number. ........ r55739 | brett.cannon | 2007-06-01 20:02:29 -0700 (Fri, 01 Jun 2007) | 3 lines Have configure raise an error when building on AtheOS. Code specific to AtheOS will be removed in Python 2.7. ........ r55746 | neal.norwitz | 2007-06-02 11:33:53 -0700 (Sat, 02 Jun 2007) | 1 line Update expected birthday of 2.6 ........ r55751 | neal.norwitz | 2007-06-03 13:32:50 -0700 (Sun, 03 Jun 2007) | 10 lines Backout the original 'fix' to 1721309 which had no effect. Different versions of Berkeley DB handle this differently. The comments and bug report should have the details. Memory is allocated in 4.4 (and presumably earlier), but not in 4.5. Thus 4.5 has the free error, but not earlier versions. Mostly update comments, plus make the free conditional. This fix was already applied to the 2.5 branch. ........ r55752 | brett.cannon | 2007-06-03 16:13:41 -0700 (Sun, 03 Jun 2007) | 6 lines Make _strptime.TimeRE().pattern() use ``\s+`` for matching whitespace instead of ``\s*``. This prevents patterns from "stealing" bits from other patterns in order to make a match work. Closes bug #1730389. Will be backported. ........ r55766 | hyeshik.chang | 2007-06-05 11:16:52 -0700 (Tue, 05 Jun 2007) | 4 lines Fix build on FreeBSD. Bluetooth HCI API in FreeBSD is quite different from Linux's. Just fix the build for now but the code doesn't support the complete capability of HCI on FreeBSD yet. ........ r55770 | hyeshik.chang | 2007-06-05 11:58:51 -0700 (Tue, 05 Jun 2007) | 4 lines Bug #1728403: Fix a bug that CJKCodecs StreamReader hangs when it reads a file that ends with incomplete sequence and sizehint argument for .read() is specified. ........ r55775 | hyeshik.chang | 2007-06-05 12:28:15 -0700 (Tue, 05 Jun 2007) | 2 lines Fix for Windows: close a temporary file before trying to delete it. ........ r55783 | guido.van.rossum | 2007-06-05 14:24:47 -0700 (Tue, 05 Jun 2007) | 2 lines Patch by Tim Delany (missing DECREF). SF #1731330. ........ r55785 | collin.winter | 2007-06-05 17:17:35 -0700 (Tue, 05 Jun 2007) | 3 lines Patch #1731049: make threading.py use a proper "raise" when checking internal state, rather than assert statements (which get stripped out by -O). ........ r55786 | facundo.batista | 2007-06-06 08:13:37 -0700 (Wed, 06 Jun 2007) | 4 lines FTP.ntransfercmd method now uses create_connection when passive, using the timeout received in connection time. ........ r55792 | facundo.batista | 2007-06-06 10:15:23 -0700 (Wed, 06 Jun 2007) | 7 lines Added an optional timeout parameter to function urllib2.urlopen, with tests in test_urllib2net.py (must have network resource enabled to execute them). Also modified test_urllib2.py because testing mock classes must take it into acount. Docs are also updated. ........ r55793 | thomas.heller | 2007-06-06 13:19:19 -0700 (Wed, 06 Jun 2007) | 1 line Build _ctypes and _ctypes_test in the ReleaseAMD64 configuration. ........ r55802 | georg.brandl | 2007-06-07 06:23:24 -0700 (Thu, 07 Jun 2007) | 3 lines Disallow function calls like foo(None=1). Backport from py3k rev. 55708 by Guido. ........ r55804 | georg.brandl | 2007-06-07 06:30:24 -0700 (Thu, 07 Jun 2007) | 2 lines Make reindent.py executable. ........ r55805 | georg.brandl | 2007-06-07 06:34:10 -0700 (Thu, 07 Jun 2007) | 2 lines Patch #1667860: Fix UnboundLocalError in urllib2. ........ r55821 | kristjan.jonsson | 2007-06-07 16:53:49 -0700 (Thu, 07 Jun 2007) | 1 line Fixing changes to getbuildinfo.c that broke linux builds ........ r55828 | thomas.heller | 2007-06-08 09:10:27 -0700 (Fri, 08 Jun 2007) | 1 line Make this test work with older Python releases where struct has no 't' format character. ........ r55829 | martin.v.loewis | 2007-06-08 10:29:20 -0700 (Fri, 08 Jun 2007) | 3 lines Bug #1733488: Fix compilation of bufferobject.c on AIX. Will backport to 2.5. ........ r55831 | thomas.heller | 2007-06-08 11:20:09 -0700 (Fri, 08 Jun 2007) | 2 lines [ 1715718 ] x64 clean compile patch for _ctypes, by Kristj?n Valur with small modifications. ........ r55832 | thomas.heller | 2007-06-08 12:01:06 -0700 (Fri, 08 Jun 2007) | 1 line Fix gcc warnings intruduced by passing Py_ssize_t to PyErr_Format calls. ........ r55833 | thomas.heller | 2007-06-08 12:08:31 -0700 (Fri, 08 Jun 2007) | 2 lines Fix wrong documentation, and correct the punktuation. Closes [1700455]. ........ r55834 | thomas.heller | 2007-06-08 12:14:23 -0700 (Fri, 08 Jun 2007) | 1 line Fix warnings by using proper function prototype. ........ r55839 | neal.norwitz | 2007-06-08 20:36:34 -0700 (Fri, 08 Jun 2007) | 7 lines Prevent expandtabs() on string and unicode objects from causing a segfault when a large width is passed on 32-bit platforms. Found by Google. It would be good for people to review this especially carefully and verify I don't have an off by one error and there is no other way to cause overflow. ........ r55841 | neal.norwitz | 2007-06-08 21:48:22 -0700 (Fri, 08 Jun 2007) | 1 line Use macro version of GET_SIZE to avoid Coverity warning (#150) about a possible error. ........ r55842 | martin.v.loewis | 2007-06-09 00:42:52 -0700 (Sat, 09 Jun 2007) | 3 lines Patch #1733960: Allow T_LONGLONG to accept ints. Will backport to 2.5. ........ r55843 | martin.v.loewis | 2007-06-09 00:58:05 -0700 (Sat, 09 Jun 2007) | 2 lines Fix Windows build. ........ r55845 | martin.v.loewis | 2007-06-09 03:10:26 -0700 (Sat, 09 Jun 2007) | 2 lines Provide LLONG_MAX for S390. ........ r55854 | thomas.heller | 2007-06-10 08:59:17 -0700 (Sun, 10 Jun 2007) | 4 lines First version of build scripts for Windows/AMD64 (no external components are built yet, and 'kill_python' is disabled). ........ r55855 | thomas.heller | 2007-06-10 10:55:51 -0700 (Sun, 10 Jun 2007) | 3 lines For now, disable the _bsddb, _sqlite3, _ssl, _testcapi, _tkinter modules in the ReleaseAMD64 configuration because they do not compile. ........ r55856 | thomas.heller | 2007-06-10 11:27:54 -0700 (Sun, 10 Jun 2007) | 1 line Need to set the environment variables, otherwise devenv.com is not found. ........ r55860 | thomas.heller | 2007-06-10 14:01:17 -0700 (Sun, 10 Jun 2007) | 1 line Revert commit 55855. ........ Modified: python/branches/p3yk/Doc/lib/libctypes.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libctypes.tex (original) +++ python/branches/p3yk/Doc/lib/libctypes.tex Mon Jun 11 03:31:49 2007 @@ -437,8 +437,8 @@ expecting pointers to mutable memory. If you need mutable memory blocks, ctypes has a \code{create{\_}string{\_}buffer} function which creates these in various ways. The current memory block contents can be -accessed (or changed) with the \code{raw} property, if you want to access -it as NUL terminated string, use the \code{string} property: +accessed (or changed) with the \code{raw} property; if you want to access +it as NUL terminated string, use the \code{value} property: \begin{verbatim} >>> from ctypes import * >>> p = create_string_buffer(3) # create a 3 byte buffer, initialized to NUL bytes Modified: python/branches/p3yk/Doc/lib/libthreading.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libthreading.tex (original) +++ python/branches/p3yk/Doc/lib/libthreading.tex Mon Jun 11 03:31:49 2007 @@ -174,11 +174,14 @@ unlocked, then the \method{acquire()} call resets it to locked and returns. The \method{release()} method should only be called in the locked state; it changes the state to unlocked and returns -immediately. When more than one thread is blocked in -\method{acquire()} waiting for the state to turn to unlocked, only one -thread proceeds when a \method{release()} call resets the state to -unlocked; which one of the waiting threads proceeds is not defined, -and may vary across implementations. +immediately. If an attempt is made to release an unlocked lock, a +\exception{RuntimeError} will be raised. + +When more than one thread is blocked in \method{acquire()} waiting for +the state to turn to unlocked, only one thread proceeds when a +\method{release()} call resets the state to unlocked; which one of the +waiting threads proceeds is not defined, and may vary across +implementations. All methods are executed atomically. @@ -257,8 +260,9 @@ decrement the recursion level is still nonzero, the lock remains locked and owned by the calling thread. -Only call this method when the calling thread owns the lock. -Do not call this method when the lock is unlocked. +Only call this method when the calling thread owns the lock. A +\exception{RuntimeError} is raised if this method is called when the +lock is unlocked. There is no return value. \end{methoddesc} @@ -275,7 +279,8 @@ methods that call the corresponding methods of the associated lock. It also has a \method{wait()} method, and \method{notify()} and \method{notifyAll()} methods. These three must only be called when -the calling thread has acquired the lock. +the calling thread has acquired the lock, otherwise a +\exception{RuntimeError} is raised. The \method{wait()} method releases the lock, and then blocks until it is awakened by a \method{notify()} or \method{notifyAll()} call for @@ -343,9 +348,9 @@ \end{methoddesc} \begin{methoddesc}{wait}{\optional{timeout}} -Wait until notified or until a timeout occurs. -This must only be called when the calling thread has acquired the -lock. +Wait until notified or until a timeout occurs. If the calling thread +has not acquired the lock when this method is called, a +\exception{RuntimeError} is raised. This method releases the underlying lock, and then blocks until it is awakened by a \method{notify()} or \method{notifyAll()} call for the @@ -367,9 +372,10 @@ \end{methoddesc} \begin{methoddesc}{notify}{} -Wake up a thread waiting on this condition, if any. -This must only be called when the calling thread has acquired the -lock. +Wake up a thread waiting on this condition, if any. Wait until +notified or until a timeout occurs. If the calling thread has not +acquired the lock when this method is called, a +\exception{RuntimeError} is raised. This method wakes up one of the threads waiting for the condition variable, if any are waiting; it is a no-op if no threads are waiting. @@ -386,7 +392,9 @@ \begin{methoddesc}{notifyAll}{} Wake up all threads waiting on this condition. This method acts like -\method{notify()}, but wakes up all waiting threads instead of one. +\method{notify()}, but wakes up all waiting threads instead of one. If +the calling thread has not acquired the lock when this method is +called, a \exception{RuntimeError} is raised. \end{methoddesc} @@ -404,8 +412,9 @@ calls \method{release()}. \begin{classdesc}{Semaphore}{\optional{value}} -The optional argument gives the initial value for the internal -counter; it defaults to \code{1}. +The optional argument gives the initial \var{value} for the internal +counter; it defaults to \code{1}. If the \var{value} given is less +than 0, \exception{ValueError} is raised. \end{classdesc} \begin{methoddesc}{acquire}{\optional{blocking}} @@ -586,9 +595,12 @@ \begin{methoddesc}{start}{} Start the thread's activity. -This must be called at most once per thread object. It -arranges for the object's \method{run()} method to be invoked in a -separate thread of control. +It must be called at most once per thread object. It arranges for the +object's \method{run()} method to be invoked in a separate thread of +control. + +This method will raise a \exception{RuntimeException} if called more +than once on the same thread object. \end{methoddesc} \begin{methoddesc}{run}{} @@ -618,11 +630,10 @@ A thread can be \method{join()}ed many times. -A thread cannot join itself because this would cause a -deadlock. - -It is an error to attempt to \method{join()} a thread before it has -been started. +\method{join()} may throw a \exception{RuntimeError}, if an attempt is +made to join the current thread as that would cause a deadlock. It is +also an error to \method{join()} a thread before it has been started +and attempts to do so raises same exception. \end{methoddesc} \begin{methoddesc}{getName}{} @@ -651,7 +662,8 @@ \begin{methoddesc}{setDaemon}{daemonic} Set the thread's daemon flag to the Boolean value \var{daemonic}. -This must be called before \method{start()} is called. +This must be called before \method{start()} is called, otherwise +\exception{RuntimeError} is raised. The initial value is inherited from the creating thread. Modified: python/branches/p3yk/Doc/lib/liburllib2.tex ============================================================================== --- python/branches/p3yk/Doc/lib/liburllib2.tex (original) +++ python/branches/p3yk/Doc/lib/liburllib2.tex Mon Jun 11 03:31:49 2007 @@ -14,7 +14,7 @@ The \module{urllib2} module defines the following functions: -\begin{funcdesc}{urlopen}{url\optional{, data}} +\begin{funcdesc}{urlopen}{url\optional{, data}\optional{, timeout}} Open the URL \var{url}, which can be either a string or a \class{Request} object. @@ -27,6 +27,11 @@ \function{urllib.urlencode()} function takes a mapping or sequence of 2-tuples and returns a string in this format. +The optional \var{timeout} parameter specifies a timeout in seconds for the +connection attempt (if not specified, or passed as None, the global default +timeout setting will be used). This actually only work for HTTP, HTTPS, FTP +and FTPS connections. + This function returns a file-like object with two additional methods: \begin{itemize} @@ -351,12 +356,17 @@ \end{itemize} \end{methoddesc} -\begin{methoddesc}[OpenerDirector]{open}{url\optional{, data}} +\begin{methoddesc}[OpenerDirector]{open}{url\optional{, data}{\optional{, timeout}}} Open the given \var{url} (which can be a request object or a string), optionally passing the given \var{data}. Arguments, return values and exceptions raised are the same as those of \function{urlopen()} (which simply calls the \method{open()} method -on the currently installed global \class{OpenerDirector}). +on the currently installed global \class{OpenerDirector}). The optional +\var{timeout} parameter specifies a timeout in seconds for the connection +attempt (if not specified, or passed as None, the global default timeout +setting will be used; this actually only work for HTTP, HTTPS, FTP +and FTPS connections). + \end{methoddesc} \begin{methoddesc}[OpenerDirector]{error}{proto\optional{, Modified: python/branches/p3yk/Doc/whatsnew/whatsnew26.tex ============================================================================== --- python/branches/p3yk/Doc/whatsnew/whatsnew26.tex (original) +++ python/branches/p3yk/Doc/whatsnew/whatsnew26.tex Mon Jun 11 03:31:49 2007 @@ -53,7 +53,7 @@ \tableofcontents 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 late 2007. +for Python 2.6 has been set; it will probably be released in mid 2008. % Compare with previous release in 2 - 3 sentences here. Modified: python/branches/p3yk/Include/pyport.h ============================================================================== --- python/branches/p3yk/Include/pyport.h (original) +++ python/branches/p3yk/Include/pyport.h Mon Jun 11 03:31:49 2007 @@ -50,6 +50,16 @@ #ifdef HAVE_LONG_LONG #ifndef PY_LONG_LONG #define PY_LONG_LONG long long +#if defined(LLONG_MAX) +#define PY_LLONG_MIN LLONG_MIN +#define PY_LLONG_MAX LLONG_MAX +#define PY_ULLONG_MAX ULLONG_MAX +#elif defined(__s390__) +/* Apparently, S390 Linux has long long, but no LLONG_MAX */ +#define PY_LLONG_MAX 9223372036854775807LL +#define PY_LLONG_MIN (-PY_LLONG_MAX-1) +#define PY_ULLONG_MAX 18446744073709551615ULL +#endif /* LLONG_MAX */ #endif #endif /* HAVE_LONG_LONG */ Modified: python/branches/p3yk/Lib/_strptime.py ============================================================================== --- python/branches/p3yk/Lib/_strptime.py (original) +++ python/branches/p3yk/Lib/_strptime.py Mon Jun 11 03:31:49 2007 @@ -250,7 +250,7 @@ regex_chars = re_compile(r"([\\.^$*+?\(\){}\[\]|])") format = regex_chars.sub(r"\\\1", format) whitespace_replacement = re_compile('\s+') - format = whitespace_replacement.sub('\s*', format) + format = whitespace_replacement.sub('\s+', format) while '%' in format: directive_index = format.index('%')+1 processed_format = "%s%s%s" % (processed_format, Modified: python/branches/p3yk/Lib/ctypes/test/test_numbers.py ============================================================================== --- python/branches/p3yk/Lib/ctypes/test/test_numbers.py (original) +++ python/branches/p3yk/Lib/ctypes/test/test_numbers.py Mon Jun 11 03:31:49 2007 @@ -117,7 +117,10 @@ def test_sizes(self): for t in signed_types + unsigned_types + float_types + bool_types: - size = struct.calcsize(t._type_) + try: + size = struct.calcsize(t._type_) + except struct.error: + continue # sizeof of the type... self.failUnlessEqual(sizeof(t), size) # and sizeof of an instance Modified: python/branches/p3yk/Lib/distutils/command/build_py.py ============================================================================== --- python/branches/p3yk/Lib/distutils/command/build_py.py (original) +++ python/branches/p3yk/Lib/distutils/command/build_py.py Mon Jun 11 03:31:49 2007 @@ -114,7 +114,9 @@ build_dir = os.path.join(*([self.build_lib] + package.split('.'))) # Length of path to strip from found files - plen = len(src_dir)+1 + plen = 0 + if src_dir: + plen = len(src_dir)+1 # Strip directory from globbed filenames filenames = [ Modified: python/branches/p3yk/Lib/distutils/tests/test_build_py.py ============================================================================== --- python/branches/p3yk/Lib/distutils/tests/test_build_py.py (original) +++ python/branches/p3yk/Lib/distutils/tests/test_build_py.py Mon Jun 11 03:31:49 2007 @@ -1,10 +1,13 @@ """Tests for distutils.command.build_py.""" import os +import sys +import StringIO import unittest from distutils.command.build_py import build_py from distutils.core import Distribution +from distutils.errors import DistutilsFileError from distutils.tests import support @@ -53,6 +56,38 @@ self.assert_("__init__.pyc" in files) self.assert_("README.txt" in files) + def test_empty_package_dir (self): + # See SF 1668596/1720897. + cwd = os.getcwd() + + # create the distribution files. + sources = self.mkdtemp() + open(os.path.join(sources, "__init__.py"), "w").close() + + testdir = os.path.join(sources, "doc") + os.mkdir(testdir) + open(os.path.join(testdir, "testfile"), "w").close() + + os.chdir(sources) + sys.stdout = StringIO.StringIO() + + try: + dist = Distribution({"packages": ["pkg"], + "package_dir": {"pkg": ""}, + "package_data": {"pkg": ["doc/*"]}}) + # script_name need not exist, it just need to be initialized + dist.script_name = os.path.join(sources, "setup.py") + dist.script_args = ["build"] + dist.parse_command_line() + + try: + dist.run_commands() + except DistutilsFileError: + self.fail("failed package_data test when package_dir is ''") + finally: + # Restore state. + os.chdir(cwd) + sys.stdout = sys.__stdout__ def test_suite(): return unittest.makeSuite(BuildPyTestCase) Modified: python/branches/p3yk/Lib/ftplib.py ============================================================================== --- python/branches/p3yk/Lib/ftplib.py (original) +++ python/branches/p3yk/Lib/ftplib.py Mon Jun 11 03:31:49 2007 @@ -319,9 +319,7 @@ size = None if self.passiveserver: host, port = self.makepasv() - af, socktype, proto, canon, sa = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM)[0] - conn = socket.socket(af, socktype, proto) - conn.connect(sa) + conn = socket.create_connection((host, port), self.timeout) if rest is not None: self.sendcmd("REST %s" % rest) resp = self.sendcmd(cmd) Modified: python/branches/p3yk/Lib/test/test_compile.py ============================================================================== --- python/branches/p3yk/Lib/test/test_compile.py (original) +++ python/branches/p3yk/Lib/test/test_compile.py Mon Jun 11 03:31:49 2007 @@ -36,6 +36,9 @@ def test_syntax_error(self): self.assertRaises(SyntaxError, compile, "1+*3", "filename", "exec") + def test_none_keyword_arg(self): + self.assertRaises(SyntaxError, compile, "f(None=1)", "", "exec") + def test_duplicate_global_local(self): try: exec('def f(a): global a; a = 1') Modified: python/branches/p3yk/Lib/test/test_multibytecodec.py ============================================================================== --- python/branches/p3yk/Lib/test/test_multibytecodec.py (original) +++ python/branches/p3yk/Lib/test/test_multibytecodec.py Mon Jun 11 03:31:49 2007 @@ -136,11 +136,21 @@ self.assertRaises(UnicodeDecodeError, decoder.decode, '', True) self.assertEqual(decoder.decode('B@$'), u'\u4e16') +class Test_StreamReader(unittest.TestCase): + def test_bug1728403(self): + try: + open(TESTFN, 'w').write('\xa1') + f = codecs.open(TESTFN, encoding='cp949') + self.assertRaises(UnicodeDecodeError, f.read, 2) + finally: + try: f.close() + except: pass + os.unlink(TESTFN) class Test_StreamWriter(unittest.TestCase): if len(u'\U00012345') == 2: # UCS2 def test_gb18030(self): - s= StringIO.StringIO() + s = StringIO.StringIO() c = codecs.getwriter('gb18030')(s) c.write(u'123') self.assertEqual(s.getvalue(), '123') Modified: python/branches/p3yk/Lib/test/test_str.py ============================================================================== --- python/branches/p3yk/Lib/test/test_str.py (original) +++ python/branches/p3yk/Lib/test/test_str.py Mon Jun 11 03:31:49 2007 @@ -1,4 +1,6 @@ + import unittest +import sys from test import test_support, string_tests @@ -90,6 +92,15 @@ self.assertEqual(str(Foo9("foo")), "string") self.assertEqual(unicode(Foo9("foo")), u"not unicode") + def test_expandtabs_overflows_gracefully(self): + # 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): + return + self.assertRaises(OverflowError, 't\tt\t'.expandtabs, sys.maxint) + + def test_main(): test_support.run_unittest(StrTest) Modified: python/branches/p3yk/Lib/test/test_strptime.py ============================================================================== --- python/branches/p3yk/Lib/test/test_strptime.py (original) +++ python/branches/p3yk/Lib/test/test_strptime.py Mon Jun 11 03:31:49 2007 @@ -190,6 +190,15 @@ "locale data that contains regex metacharacters is not" " properly escaped") + def test_whitespace_substitution(self): + # When pattern contains whitespace, make sure it is taken into account + # so as to not allow to subpatterns to end up next to each other and + # "steal" characters from each other. + pattern = self.time_re.pattern('%j %H') + self.failUnless(not re.match(pattern, "180")) + self.failUnless(re.match(pattern, "18 0")) + + class StrptimeTests(unittest.TestCase): """Tests for _strptime.strptime.""" Modified: python/branches/p3yk/Lib/test/test_structmembers.py ============================================================================== --- python/branches/p3yk/Lib/test/test_structmembers.py (original) +++ python/branches/p3yk/Lib/test/test_structmembers.py Mon Jun 11 03:31:49 2007 @@ -2,7 +2,8 @@ CHAR_MAX, CHAR_MIN, UCHAR_MAX, \ SHRT_MAX, SHRT_MIN, USHRT_MAX, \ INT_MAX, INT_MIN, UINT_MAX, \ - LONG_MAX, LONG_MIN, ULONG_MAX + LONG_MAX, LONG_MIN, ULONG_MAX, \ + LLONG_MAX, LLONG_MIN, ULLONG_MAX import warnings, unittest from test import test_support @@ -39,6 +40,23 @@ ts.T_ULONG=ULONG_MAX self.assertEquals(ts.T_ULONG, ULONG_MAX) + ## T_LONGLONG and T_ULONGLONG may not be present on some platforms + if hasattr(ts, 'T_LONGLONG'): + ts.T_LONGLONG=LLONG_MAX + self.assertEquals(ts.T_LONGLONG, LLONG_MAX) + ts.T_LONGLONG=LLONG_MIN + self.assertEquals(ts.T_LONGLONG, LLONG_MIN) + + ts.T_ULONGLONG=ULLONG_MAX + self.assertEquals(ts.T_ULONGLONG, ULLONG_MAX) + + ## make sure these will accept a plain int as well as a long + ts.T_LONGLONG=3 + self.assertEquals(ts.T_LONGLONG, 3) + ts.T_ULONGLONG=4 + self.assertEquals(ts.T_ULONGLONG, 4) + + class TestWarnings(unittest.TestCase): def has_warned(self, w): self.assert_(w.category is RuntimeWarning) Modified: python/branches/p3yk/Lib/test/test_threading.py ============================================================================== --- python/branches/p3yk/Lib/test/test_threading.py (original) +++ python/branches/p3yk/Lib/test/test_threading.py Mon Jun 11 03:31:49 2007 @@ -3,6 +3,7 @@ import test.test_support from test.test_support import verbose import random +import sys import threading import thread import time @@ -201,8 +202,47 @@ t.join() # else the thread is still running, and we have no way to kill it +class ThreadingExceptionTests(unittest.TestCase): + # A RuntimeError should be raised if Thread.start() is called + # multiple times. + def test_start_thread_again(self): + thread = threading.Thread() + thread.start() + self.assertRaises(RuntimeError, thread.start) + + def test_releasing_unacquired_rlock(self): + rlock = threading.RLock() + self.assertRaises(RuntimeError, rlock.release) + + def test_waiting_on_unacquired_condition(self): + cond = threading.Condition() + self.assertRaises(RuntimeError, cond.wait) + + def test_notify_on_unacquired_condition(self): + cond = threading.Condition() + self.assertRaises(RuntimeError, cond.notify) + + def test_semaphore_with_negative_value(self): + self.assertRaises(ValueError, threading.Semaphore, value = -1) + self.assertRaises(ValueError, threading.Semaphore, value = -sys.maxint) + + def test_joining_current_thread(self): + currentThread = threading.currentThread() + self.assertRaises(RuntimeError, currentThread.join); + + def test_joining_inactive_thread(self): + thread = threading.Thread() + self.assertRaises(RuntimeError, thread.join) + + def test_daemonize_active_thread(self): + thread = threading.Thread() + thread.start() + self.assertRaises(RuntimeError, thread.setDaemon, True) + + def test_main(): - test.test_support.run_unittest(ThreadTests) + test.test_support.run_unittest(ThreadTests, + ThreadingExceptionTests) if __name__ == "__main__": test_main() Modified: python/branches/p3yk/Lib/test/test_unicode.py ============================================================================== --- python/branches/p3yk/Lib/test/test_unicode.py (original) +++ python/branches/p3yk/Lib/test/test_unicode.py Mon Jun 11 03:31:49 2007 @@ -825,8 +825,13 @@ self.assertEqual(repr(s1()), '\\n') self.assertEqual(repr(s2()), '\\n') - - + def test_expandtabs_overflows_gracefully(self): + # 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): + return + self.assertRaises(OverflowError, u't\tt\t'.expandtabs, sys.maxint) def test_main(): Modified: python/branches/p3yk/Lib/test/test_urllib2.py ============================================================================== --- python/branches/p3yk/Lib/test/test_urllib2.py (original) +++ python/branches/p3yk/Lib/test/test_urllib2.py Mon Jun 11 03:31:49 2007 @@ -544,7 +544,7 @@ class NullFTPHandler(urllib2.FTPHandler): def __init__(self, data): self.data = data - def connect_ftp(self, user, passwd, host, port, dirs): + def connect_ftp(self, user, passwd, host, port, dirs, timeout=None): self.user, self.passwd = user, passwd self.host, self.port = host, port self.dirs = dirs @@ -567,7 +567,9 @@ "localhost", ftplib.FTP_PORT, "A", [], "baz.gif", None), # XXX really this should guess image/gif ]: - r = h.ftp_open(Request(url)) + req = Request(url) + req.timeout = None + r = h.ftp_open(req) # ftp authentication not yet implemented by FTPHandler self.assert_(h.user == h.passwd == "") self.assertEqual(h.host, socket.gethostbyname(host)) @@ -682,8 +684,9 @@ self.req_headers = [] self.data = None self.raise_on_endheaders = False - def __call__(self, host): + def __call__(self, host, timeout=None): self.host = host + self.timeout = timeout return self def set_debuglevel(self, level): self.level = level @@ -706,6 +709,7 @@ url = "http://example.com/" for method, data in [("GET", None), ("POST", "blah")]: req = Request(url, data, {"Foo": "bar"}) + req.timeout = None req.add_unredirected_header("Spam", "eggs") http = MockHTTPClass() r = h.do_open(http, req) Copied: python/branches/p3yk/Lib/test/test_urllib2_localnet.py (from r55860, python/trunk/Lib/test/test_urllib2_localnet.py) ============================================================================== --- python/trunk/Lib/test/test_urllib2_localnet.py (original) +++ python/branches/p3yk/Lib/test/test_urllib2_localnet.py Mon Jun 11 03:31:49 2007 @@ -160,13 +160,13 @@ if len(self._users) == 0: return True - if not request_handler.headers.has_key('Proxy-Authorization'): + if 'Proxy-Authorization' not in request_handler.headers: return self._return_auth_challenge(request_handler) else: auth_dict = self._create_auth_dict( request_handler.headers['Proxy-Authorization'] ) - if self._users.has_key(auth_dict["username"]): + if auth_dict["username"] in self._users: password = self._users[ auth_dict["username"] ] else: return self._return_auth_challenge(request_handler) Modified: python/branches/p3yk/Lib/test/test_urllib2net.py ============================================================================== --- python/branches/p3yk/Lib/test/test_urllib2net.py (original) +++ python/branches/p3yk/Lib/test/test_urllib2net.py Mon Jun 11 03:31:49 2007 @@ -267,6 +267,49 @@ return handlers +class TimeoutTest(unittest.TestCase): + def test_http_basic(self): + u = urllib2.urlopen("http://www.python.org") + self.assertTrue(u.fp._sock.fp._sock.gettimeout() is None) + + def test_http_NoneWithdefault(self): + prev = socket.getdefaulttimeout() + socket.setdefaulttimeout(60) + try: + u = urllib2.urlopen("http://www.python.org", timeout=None) + self.assertEqual(u.fp._sock.fp._sock.gettimeout(), 60) + finally: + socket.setdefaulttimeout(prev) + + def test_http_Value(self): + u = urllib2.urlopen("http://www.python.org", timeout=120) + self.assertEqual(u.fp._sock.fp._sock.gettimeout(), 120) + + def test_http_NoneNodefault(self): + u = urllib2.urlopen("http://www.python.org", timeout=None) + self.assertTrue(u.fp._sock.fp._sock.gettimeout() is None) + + def test_ftp_basic(self): + u = urllib2.urlopen("ftp://ftp.mirror.nl/pub/mirror/gnu/") + self.assertTrue(u.fp.fp._sock.gettimeout() is None) + + def test_ftp_NoneWithdefault(self): + prev = socket.getdefaulttimeout() + socket.setdefaulttimeout(60) + try: + u = urllib2.urlopen("ftp://ftp.mirror.nl/pub/mirror/gnu/", timeout=None) + self.assertEqual(u.fp.fp._sock.gettimeout(), 60) + finally: + socket.setdefaulttimeout(prev) + + def test_ftp_NoneNodefault(self): + u = urllib2.urlopen("ftp://ftp.mirror.nl/pub/mirror/gnu/", timeout=None) + self.assertTrue(u.fp.fp._sock.gettimeout() is None) + + def test_ftp_Value(self): + u = urllib2.urlopen("ftp://ftp.mirror.nl/pub/mirror/gnu/", timeout=60) + self.assertEqual(u.fp.fp._sock.gettimeout(), 60) + def test_main(): test_support.requires("network") @@ -275,6 +318,7 @@ AuthTests, OtherNetworkTests, CloseSocketTest, + TimeoutTest, ) if __name__ == "__main__": Modified: python/branches/p3yk/Lib/threading.py ============================================================================== --- python/branches/p3yk/Lib/threading.py (original) +++ python/branches/p3yk/Lib/threading.py Mon Jun 11 03:31:49 2007 @@ -111,8 +111,8 @@ __enter__ = acquire def release(self): - me = currentThread() - assert self.__owner is me, "release() of un-acquire()d lock" + if self.__owner is not currentThread(): + raise RuntimeError("cannot release un-aquired lock") self.__count = count = self.__count - 1 if not count: self.__owner = None @@ -203,7 +203,8 @@ return True def wait(self, timeout=None): - assert self._is_owned(), "wait() of un-acquire()d lock" + if not self._is_owned(): + raise RuntimeError("cannot wait on un-aquired lock") waiter = _allocate_lock() waiter.acquire() self.__waiters.append(waiter) @@ -244,7 +245,8 @@ self._acquire_restore(saved_state) def notify(self, n=1): - assert self._is_owned(), "notify() of un-acquire()d lock" + if not self._is_owned(): + raise RuntimeError("cannot notify on un-aquired lock") __waiters = self.__waiters waiters = __waiters[:n] if not waiters: @@ -272,7 +274,8 @@ # After Tim Peters' semaphore class, but not quite the same (no maximum) def __init__(self, value=1, verbose=None): - assert value >= 0, "Semaphore initial value must be >= 0" + if value < 0: + raise ValueError("semaphore initial value must be >= 0") _Verbose.__init__(self, verbose) self.__cond = Condition(Lock()) self.__value = value @@ -423,8 +426,10 @@ return "<%s(%s, %s)>" % (self.__class__.__name__, self.__name, status) def start(self): - assert self.__initialized, "Thread.__init__() not called" - assert not self.__started, "thread already started" + if not self.__initialized: + raise RuntimeError("thread.__init__() not called") + if self.__started: + raise RuntimeError("thread already started") if __debug__: self._note("%s.start(): starting thread", self) _active_limbo_lock.acquire() @@ -544,9 +549,13 @@ _active_limbo_lock.release() def join(self, timeout=None): - assert self.__initialized, "Thread.__init__() not called" - assert self.__started, "cannot join thread before it is started" - assert self is not currentThread(), "cannot join current thread" + if not self.__initialized: + raise RuntimeError("Thread.__init__() not called") + if not self.__started: + raise RuntimeError("cannot join thread before it is started") + if self is currentThread(): + raise RuntimeError("cannot join current thread") + if __debug__: if not self.__stopped: self._note("%s.join(): waiting until thread stops", self) @@ -589,8 +598,10 @@ return self.__daemonic def setDaemon(self, daemonic): - assert self.__initialized, "Thread.__init__() not called" - assert not self.__started, "cannot set daemon status of active thread" + if not self.__initialized: + raise RuntimeError("Thread.__init__() not called") + if self.__started: + raise RuntimeError("cannot set daemon status of active thread"); self.__daemonic = daemonic # The timer class was contributed by Itamar Shtull-Trauring Modified: python/branches/p3yk/Lib/urllib2.py ============================================================================== --- python/branches/p3yk/Lib/urllib2.py (original) +++ python/branches/p3yk/Lib/urllib2.py Mon Jun 11 03:31:49 2007 @@ -117,11 +117,11 @@ __version__ = sys.version[:3] _opener = None -def urlopen(url, data=None): +def urlopen(url, data=None, timeout=None): global _opener if _opener is None: _opener = build_opener() - return _opener.open(url, data) + return _opener.open(url, data, timeout) def install_opener(opener): global _opener @@ -355,7 +355,7 @@ if result is not None: return result - def open(self, fullurl, data=None): + def open(self, fullurl, data=None, timeout=None): # accept a URL or a Request object if isinstance(fullurl, basestring): req = Request(fullurl, data) @@ -364,6 +364,7 @@ if data is not None: req.add_data(data) + req.timeout = timeout protocol = req.get_type() # pre-process request @@ -947,7 +948,7 @@ respdig = KD(H(A1), "%s:%s" % (nonce, H(A2))) else: # XXX handle auth-int. - pass + raise URLError("qop '%s' is not supported." % qop) # XXX should the partial digests be encoded too? @@ -1056,7 +1057,7 @@ if not host: raise URLError('no host given') - h = http_class(host) # will parse host:port + h = http_class(host, timeout=req.timeout) # will parse host:port h.set_debuglevel(self._debuglevel) headers = dict(req.headers) @@ -1268,7 +1269,7 @@ if dirs and not dirs[0]: dirs = dirs[1:] try: - fw = self.connect_ftp(user, passwd, host, port, dirs) + fw = self.connect_ftp(user, passwd, host, port, dirs, req.timeout) type = file and 'I' or 'D' for attr in attrs: attr, value = splitvalue(attr) @@ -1288,8 +1289,8 @@ except ftplib.all_errors as msg: raise IOError, ('ftp error', msg), sys.exc_info()[2] - def connect_ftp(self, user, passwd, host, port, dirs): - fw = ftpwrapper(user, passwd, host, port, dirs) + def connect_ftp(self, user, passwd, host, port, dirs, timeout): + fw = ftpwrapper(user, passwd, host, port, dirs, timeout) ## fw.ftp.set_debuglevel(1) return fw @@ -1309,12 +1310,12 @@ def setMaxConns(self, m): self.max_conns = m - def connect_ftp(self, user, passwd, host, port, dirs): - key = user, host, port, '/'.join(dirs) + def connect_ftp(self, user, passwd, host, port, dirs, timeout): + key = user, host, port, '/'.join(dirs), timeout if key in self.cache: self.timeout[key] = time.time() + self.delay else: - self.cache[key] = ftpwrapper(user, passwd, host, port, dirs) + self.cache[key] = ftpwrapper(user, passwd, host, port, dirs, timeout) self.timeout[key] = time.time() + self.delay self.check_cache() return self.cache[key] Modified: python/branches/p3yk/Misc/ACKS ============================================================================== --- python/branches/p3yk/Misc/ACKS (original) +++ python/branches/p3yk/Misc/ACKS Mon Jun 11 03:31:49 2007 @@ -159,6 +159,7 @@ Vincent Delft Erik Demaine Roger Dev +Raghuram Devarakonda Toby Dickenson Mark Dickinson Yves Dionne Modified: python/branches/p3yk/Modules/_bsddb.c ============================================================================== --- python/branches/p3yk/Modules/_bsddb.c (original) +++ python/branches/p3yk/Modules/_bsddb.c Mon Jun 11 03:31:49 2007 @@ -1713,6 +1713,7 @@ PyObject* dataobj; PyObject* retval = NULL; DBT key, data; + void *orig_data; DB_TXN *txn = NULL; static char* kwnames[] = { "key", "data", "txn", "flags", NULL }; @@ -1724,7 +1725,6 @@ CHECK_DB_NOT_CLOSED(self); if (!make_key_dbt(self, keyobj, &key, NULL)) return NULL; - CLEAR_DBT(data); if ( !make_dbt(dataobj, &data) || !checkTxnObj(txnobj, &txn) ) { @@ -1733,13 +1733,12 @@ } flags |= DB_GET_BOTH; + orig_data = data.data; if (CHECK_DBFLAG(self, DB_THREAD)) { /* Tell BerkeleyDB to malloc the return value (thread safe) */ + /* XXX(nnorwitz): At least 4.4.20 and 4.5.20 require this flag. */ data.flags = DB_DBT_MALLOC; - /* TODO: Is this flag needed? We're passing a data object that should - match what's in the DB, so there should be no need to malloc. - We run the risk of freeing something twice! Check this. */ } MYDB_BEGIN_ALLOW_THREADS; @@ -1753,8 +1752,13 @@ retval = Py_None; } else if (!err) { + /* XXX(nnorwitz): can we do: retval = dataobj; Py_INCREF(retval); */ retval = PyString_FromStringAndSize((char*)data.data, data.size); - FREE_DBT(data); /* Only if retrieval was successful */ + + /* Even though the flags require DB_DBT_MALLOC, data is not always + allocated. 4.4: allocated, 4.5: *not* allocated. :-( */ + if (data.data != orig_data) + FREE_DBT(data); } FREE_DBT(key); Modified: python/branches/p3yk/Modules/_ctypes/_ctypes.c ============================================================================== --- python/branches/p3yk/Modules/_ctypes/_ctypes.c (original) +++ python/branches/p3yk/Modules/_ctypes/_ctypes.c Mon Jun 11 03:31:49 2007 @@ -789,7 +789,7 @@ CharArray_set_value(CDataObject *self, PyObject *value) { char *ptr; - int size; + Py_ssize_t size; if (PyUnicode_Check(value)) { value = PyUnicode_AsEncodedString(value, @@ -844,7 +844,7 @@ static int WCharArray_set_value(CDataObject *self, PyObject *value) { - int result = 0; + Py_ssize_t result = 0; if (PyString_Check(value)) { value = PyUnicode_FromEncodedObject(value, @@ -868,14 +868,12 @@ result = PyUnicode_AsWideChar((PyUnicodeObject *)value, (wchar_t *)self->b_ptr, self->b_size/sizeof(wchar_t)); - if (result >= 0 && (unsigned)result < self->b_size/sizeof(wchar_t)) + if (result >= 0 && (size_t)result < self->b_size/sizeof(wchar_t)) ((wchar_t *)self->b_ptr)[result] = (wchar_t)0; - if (result > 0) - result = 0; done: Py_DECREF(value); - return result; + return result >= 0 ? 0 : -1; } static PyGetSetDef WCharArray_getsets[] = { @@ -966,7 +964,7 @@ PyObject *typedict; int length; - int itemsize, itemalign; + Py_ssize_t itemsize, itemalign; typedict = PyTuple_GetItem(args, 2); if (!typedict) @@ -1737,8 +1735,8 @@ converters_from_argtypes(PyObject *ob) { PyObject *converters; - int i; - int nArgs; + Py_ssize_t i; + Py_ssize_t nArgs; ob = PySequence_Tuple(ob); /* new reference */ if (!ob) { @@ -1771,7 +1769,12 @@ Py_XDECREF(converters); Py_DECREF(ob); PyErr_Format(PyExc_TypeError, - "item %d in _argtypes_ has no from_param method", i+1); +#if (PY_VERSION_HEX < 0x02050000) + "item %d in _argtypes_ has no from_param method", +#else + "item %zd in _argtypes_ has no from_param method", +#endif + i+1); return NULL; } @@ -2591,18 +2594,18 @@ #ifdef MS_WIN32 static PPROC FindAddress(void *handle, char *name, PyObject *type) { +#ifdef MS_WIN64 + /* win64 has no stdcall calling conv, so it should + also not have the name mangling of it. + */ + return (PPROC)GetProcAddress(handle, name); +#else PPROC address; char *mangled_name; int i; StgDictObject *dict; address = (PPROC)GetProcAddress(handle, name); -#ifdef _WIN64 - /* win64 has no stdcall calling conv, so it should - also not have the name mangling of it. - */ - return address; -#else if (address) return address; if (((size_t)name & ~0xFFFF) == 0) { @@ -2634,7 +2637,7 @@ /* Return 1 if usable, 0 else and exception set. */ static int -_check_outarg_type(PyObject *arg, int index) +_check_outarg_type(PyObject *arg, Py_ssize_t index) { StgDictObject *dict; @@ -2655,7 +2658,7 @@ PyErr_Format(PyExc_TypeError, "'out' parameter %d must be a pointer type, not %s", - index, + Py_SAFE_DOWNCAST(index, Py_ssize_t, int), PyType_Check(arg) ? ((PyTypeObject *)arg)->tp_name : arg->ob_type->tp_name); @@ -2666,7 +2669,7 @@ static int _validate_paramflags(PyTypeObject *type, PyObject *paramflags) { - int i, len; + Py_ssize_t i, len; StgDictObject *dict; PyObject *argtypes; @@ -3051,12 +3054,12 @@ PyObject *paramflags = self->paramflags; PyObject *callargs; StgDictObject *dict; - int i, len; + Py_ssize_t i, len; int inargs_index = 0; /* It's a little bit difficult to determine how many arguments the function call requires/accepts. For simplicity, we count the consumed args and compare this to the number of supplied args. */ - int actual_args; + Py_ssize_t actual_args; *poutmask = 0; *pinoutmask = 0; @@ -3093,7 +3096,7 @@ /* This way seems to be ~2 us faster than the PyArg_ParseTuple calls below. */ /* We HAVE already checked that the tuple can be parsed with "i|zO", so... */ - int tsize = PyTuple_GET_SIZE(item); + Py_ssize_t tsize = PyTuple_GET_SIZE(item); flag = PyInt_AS_LONG(PyTuple_GET_ITEM(item, 0)); name = tsize > 1 ? PyString_AS_STRING(PyTuple_GET_ITEM(item, 1)) : NULL; defval = tsize > 2 ? PyTuple_GET_ITEM(item, 2) : NULL; @@ -3193,7 +3196,11 @@ message is misleading. See unittests/test_paramflags.py */ PyErr_Format(PyExc_TypeError, +#if (PY_VERSION_HEX < 0x02050000) "call takes exactly %d arguments (%d given)", +#else + "call takes exactly %d arguments (%zd given)", +#endif inargs_index, actual_args); goto error; } @@ -3339,8 +3346,10 @@ return NULL; if (converters) { - int required = PyTuple_GET_SIZE(converters); - int actual = PyTuple_GET_SIZE(callargs); + int required = Py_SAFE_DOWNCAST(PyTuple_GET_SIZE(converters), + Py_ssize_t, int); + int actual = Py_SAFE_DOWNCAST(PyTuple_GET_SIZE(callargs), + Py_ssize_t, int); if ((dict->flags & FUNCFLAG_CDECL) == FUNCFLAG_CDECL) { /* For cdecl functions, we allow more actual arguments @@ -3679,8 +3688,8 @@ static int Array_init(CDataObject *self, PyObject *args, PyObject *kw) { - int i; - int n; + Py_ssize_t i; + Py_ssize_t n; if (!PyTuple_Check(args)) { PyErr_SetString(PyExc_TypeError, @@ -3701,7 +3710,7 @@ Array_item(PyObject *_self, Py_ssize_t index) { CDataObject *self = (CDataObject *)_self; - int offset, size; + Py_ssize_t offset, size; StgDictObject *stgdict; @@ -3773,7 +3782,7 @@ Array_ass_item(PyObject *_self, Py_ssize_t index, PyObject *value) { CDataObject *self = (CDataObject *)_self; - int size, offset; + Py_ssize_t size, offset; StgDictObject *stgdict; char *ptr; @@ -3802,7 +3811,7 @@ Array_ass_slice(PyObject *_self, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *value) { CDataObject *self = (CDataObject *)_self; - int i, len; + Py_ssize_t i, len; if (value == NULL) { PyErr_SetString(PyExc_TypeError, @@ -4163,7 +4172,7 @@ Pointer_item(PyObject *_self, Py_ssize_t index) { CDataObject *self = (CDataObject *)_self; - int size; + Py_ssize_t size; Py_ssize_t offset; StgDictObject *stgdict, *itemdict; PyObject *proto; @@ -4194,7 +4203,7 @@ Pointer_ass_item(PyObject *_self, Py_ssize_t index, PyObject *value) { CDataObject *self = (CDataObject *)_self; - int size; + Py_ssize_t size; Py_ssize_t offset; StgDictObject *stgdict, *itemdict; PyObject *proto; @@ -4627,9 +4636,10 @@ static PyObject * wstring_at(const wchar_t *ptr, int size) { - if (size == -1) - size = wcslen(ptr); - return PyUnicode_FromWideChar(ptr, size); + Py_ssize_t ssize = size; + if (ssize == -1) + ssize = wcslen(ptr); + return PyUnicode_FromWideChar(ptr, ssize); } #endif @@ -4829,7 +4839,7 @@ return (PyObject *)unicode; } -int My_PyUnicode_AsWideChar(PyUnicodeObject *unicode, +Py_ssize_t My_PyUnicode_AsWideChar(PyUnicodeObject *unicode, register wchar_t *w, Py_ssize_t size) { Modified: python/branches/p3yk/Modules/_ctypes/callbacks.c ============================================================================== --- python/branches/p3yk/Modules/_ctypes/callbacks.c (original) +++ python/branches/p3yk/Modules/_ctypes/callbacks.c Mon Jun 11 03:31:49 2007 @@ -124,10 +124,10 @@ PyObject *converters, void **pArgs) { - int i; + Py_ssize_t i; PyObject *result; PyObject *arglist = NULL; - int nArgs; + Py_ssize_t nArgs; #ifdef WITH_THREAD PyGILState_STATE state = PyGILState_Ensure(); #endif @@ -265,7 +265,7 @@ { int result; ffi_info *p; - int nArgs, i; + Py_ssize_t nArgs, i; ffi_abi cc; nArgs = PySequence_Size(converters); @@ -308,7 +308,8 @@ if (is_cdecl == 0) cc = FFI_STDCALL; #endif - result = ffi_prep_cif(&p->cif, cc, nArgs, + result = ffi_prep_cif(&p->cif, cc, + Py_SAFE_DOWNCAST(nArgs, Py_ssize_t, int), GetType(restype), &p->atypes[0]); if (result != FFI_OK) { Modified: python/branches/p3yk/Modules/_ctypes/callproc.c ============================================================================== --- python/branches/p3yk/Modules/_ctypes/callproc.c (original) +++ python/branches/p3yk/Modules/_ctypes/callproc.c Mon Jun 11 03:31:49 2007 @@ -361,13 +361,13 @@ case 'z': case 'Z': case 'P': - sprintf(buffer, "", - self->tag, (long)self->value.p); + sprintf(buffer, "", + self->tag, self->value.p); break; default: - sprintf(buffer, "", - self->tag, (long)self); + sprintf(buffer, "", + self->tag, self); break; } return PyString_FromString(buffer); @@ -464,7 +464,7 @@ /* * Convert a single Python object into a PyCArgObject and return it. */ -static int ConvParam(PyObject *obj, int index, struct argument *pa) +static int ConvParam(PyObject *obj, Py_ssize_t index, struct argument *pa) { StgDictObject *dict; pa->keep = NULL; /* so we cannot forget it later */ @@ -566,7 +566,8 @@ return result; } PyErr_Format(PyExc_TypeError, - "Don't know how to convert parameter %d", index); + "Don't know how to convert parameter %d", + Py_SAFE_DOWNCAST(index, Py_ssize_t, int)); return -1; } } @@ -906,7 +907,7 @@ PyObject *restype, PyObject *checker) { - int i, n, argcount, argtype_count; + Py_ssize_t i, n, argcount, argtype_count; void *resbuf; struct argument *args, *pa; ffi_type **atypes; @@ -996,7 +997,10 @@ } if (-1 == _call_function_pointer(flags, pProc, avalues, atypes, - rtype, resbuf, argcount)) + rtype, resbuf, + Py_SAFE_DOWNCAST(argcount, + Py_ssize_t, + int))) goto cleanup; #ifdef WORDS_BIGENDIAN @@ -1352,10 +1356,10 @@ dict = PyType_stgdict(obj); if (dict) - return PyInt_FromLong(dict->size); + return PyInt_FromSsize_t(dict->size); if (CDataObject_Check(obj)) - return PyInt_FromLong(((CDataObject *)obj)->b_size); + return PyInt_FromSsize_t(((CDataObject *)obj)->b_size); PyErr_SetString(PyExc_TypeError, "this type has no size"); return NULL; @@ -1373,11 +1377,11 @@ dict = PyType_stgdict(obj); if (dict) - return PyInt_FromLong(dict->align); + return PyInt_FromSsize_t(dict->align); dict = PyObject_stgdict(obj); if (dict) - return PyInt_FromLong(dict->align); + return PyInt_FromSsize_t(dict->align); PyErr_SetString(PyExc_TypeError, "no alignment info"); Modified: python/branches/p3yk/Modules/_ctypes/cfield.c ============================================================================== --- python/branches/p3yk/Modules/_ctypes/cfield.c (original) +++ python/branches/p3yk/Modules/_ctypes/cfield.c Mon Jun 11 03:31:49 2007 @@ -35,14 +35,14 @@ * prev_desc points to the type of the previous bitfield, if any. */ PyObject * -CField_FromDesc(PyObject *desc, int index, - int *pfield_size, int bitsize, int *pbitofs, - int *psize, int *poffset, int *palign, +CField_FromDesc(PyObject *desc, Py_ssize_t index, + Py_ssize_t *pfield_size, int bitsize, int *pbitofs, + Py_ssize_t *psize, Py_ssize_t *poffset, Py_ssize_t *palign, int pack, int big_endian) { CFieldObject *self; PyObject *proto; - int size, align, length; + Py_ssize_t size, align, length; SETFUNC setfunc = NULL; GETFUNC getfunc = NULL; StgDictObject *dict; @@ -147,7 +147,7 @@ else align = dict->align; if (align && *poffset % align) { - int delta = align - (*poffset % align); + Py_ssize_t delta = align - (*poffset % align); *psize += delta; *poffset += delta; } @@ -220,21 +220,13 @@ static PyObject * CField_get_offset(PyObject *self, void *data) { -#if (PY_VERSION_HEX < 0x02050000) - return PyInt_FromLong(((CFieldObject *)self)->offset); -#else return PyInt_FromSsize_t(((CFieldObject *)self)->offset); -#endif } static PyObject * CField_get_size(PyObject *self, void *data) { -#if (PY_VERSION_HEX < 0x02050000) - return PyInt_FromLong(((CFieldObject *)self)->size); -#else return PyInt_FromSsize_t(((CFieldObject *)self)->size); -#endif } static PyGetSetDef CField_getset[] = { @@ -268,8 +260,8 @@ CField_repr(CFieldObject *self) { PyObject *result; - int bits = self->size >> 16; - int size = self->size & 0xFFFF; + Py_ssize_t bits = self->size >> 16; + Py_ssize_t size = self->size & 0xFFFF; const char *name; name = ((PyTypeObject *)self->proto)->tp_name; @@ -279,7 +271,7 @@ #if (PY_VERSION_HEX < 0x02050000) "", #else - "", + "", #endif name, self->offset, size, bits); else @@ -287,7 +279,7 @@ #if (PY_VERSION_HEX < 0x02050000) "", #else - "", + "", #endif name, self->offset, size); return result; @@ -519,7 +511,7 @@ */ static PyObject * -b_set(void *ptr, PyObject *value, unsigned size) +b_set(void *ptr, PyObject *value, Py_ssize_t size) { long val; if (get_long(value, &val) < 0) @@ -530,7 +522,7 @@ static PyObject * -b_get(void *ptr, unsigned size) +b_get(void *ptr, Py_ssize_t size) { signed char val = *(signed char *)ptr; GET_BITFIELD(val, size); @@ -538,7 +530,7 @@ } static PyObject * -B_set(void *ptr, PyObject *value, unsigned size) +B_set(void *ptr, PyObject *value, Py_ssize_t size) { unsigned long val; if (get_ulong(value, &val) < 0) @@ -550,7 +542,7 @@ static PyObject * -B_get(void *ptr, unsigned size) +B_get(void *ptr, Py_ssize_t size) { unsigned char val = *(unsigned char *)ptr; GET_BITFIELD(val, size); @@ -558,7 +550,7 @@ } static PyObject * -h_set(void *ptr, PyObject *value, unsigned size) +h_set(void *ptr, PyObject *value, Py_ssize_t size) { long val; short x; @@ -572,7 +564,7 @@ static PyObject * -h_set_sw(void *ptr, PyObject *value, unsigned size) +h_set_sw(void *ptr, PyObject *value, Py_ssize_t size) { long val; short field; @@ -587,7 +579,7 @@ } static PyObject * -h_get(void *ptr, unsigned size) +h_get(void *ptr, Py_ssize_t size) { short val; memcpy(&val, ptr, sizeof(val)); @@ -596,7 +588,7 @@ } static PyObject * -h_get_sw(void *ptr, unsigned size) +h_get_sw(void *ptr, Py_ssize_t size) { short val; memcpy(&val, ptr, sizeof(val)); @@ -606,7 +598,7 @@ } static PyObject * -H_set(void *ptr, PyObject *value, unsigned size) +H_set(void *ptr, PyObject *value, Py_ssize_t size) { unsigned long val; unsigned short x; @@ -619,7 +611,7 @@ } static PyObject * -H_set_sw(void *ptr, PyObject *value, unsigned size) +H_set_sw(void *ptr, PyObject *value, Py_ssize_t size) { unsigned long val; unsigned short field; @@ -635,7 +627,7 @@ static PyObject * -H_get(void *ptr, unsigned size) +H_get(void *ptr, Py_ssize_t size) { unsigned short val; memcpy(&val, ptr, sizeof(val)); @@ -644,7 +636,7 @@ } static PyObject * -H_get_sw(void *ptr, unsigned size) +H_get_sw(void *ptr, Py_ssize_t size) { unsigned short val; memcpy(&val, ptr, sizeof(val)); @@ -654,7 +646,7 @@ } static PyObject * -i_set(void *ptr, PyObject *value, unsigned size) +i_set(void *ptr, PyObject *value, Py_ssize_t size) { long val; int x; @@ -667,7 +659,7 @@ } static PyObject * -i_set_sw(void *ptr, PyObject *value, unsigned size) +i_set_sw(void *ptr, PyObject *value, Py_ssize_t size) { long val; int field; @@ -683,7 +675,7 @@ static PyObject * -i_get(void *ptr, unsigned size) +i_get(void *ptr, Py_ssize_t size) { int val; memcpy(&val, ptr, sizeof(val)); @@ -692,7 +684,7 @@ } static PyObject * -i_get_sw(void *ptr, unsigned size) +i_get_sw(void *ptr, Py_ssize_t size) { int val; memcpy(&val, ptr, sizeof(val)); @@ -704,7 +696,7 @@ #ifdef MS_WIN32 /* short BOOL - VARIANT_BOOL */ static PyObject * -vBOOL_set(void *ptr, PyObject *value, unsigned size) +vBOOL_set(void *ptr, PyObject *value, Py_ssize_t size) { switch (PyObject_IsTrue(value)) { case -1: @@ -719,7 +711,7 @@ } static PyObject * -vBOOL_get(void *ptr, unsigned size) +vBOOL_get(void *ptr, Py_ssize_t size) { return PyBool_FromLong((long)*(short int *)ptr); } @@ -734,7 +726,7 @@ #endif static PyObject * -t_set(void *ptr, PyObject *value, unsigned size) +t_set(void *ptr, PyObject *value, Py_ssize_t size) { switch (PyObject_IsTrue(value)) { case -1: @@ -749,13 +741,13 @@ } static PyObject * -t_get(void *ptr, unsigned size) +t_get(void *ptr, Py_ssize_t size) { return PyBool_FromLong((long)*(BOOL_TYPE *)ptr); } static PyObject * -I_set(void *ptr, PyObject *value, unsigned size) +I_set(void *ptr, PyObject *value, Py_ssize_t size) { unsigned long val; unsigned int x; @@ -768,7 +760,7 @@ } static PyObject * -I_set_sw(void *ptr, PyObject *value, unsigned size) +I_set_sw(void *ptr, PyObject *value, Py_ssize_t size) { unsigned long val; unsigned int field; @@ -783,7 +775,7 @@ static PyObject * -I_get(void *ptr, unsigned size) +I_get(void *ptr, Py_ssize_t size) { unsigned int val; memcpy(&val, ptr, sizeof(val)); @@ -792,7 +784,7 @@ } static PyObject * -I_get_sw(void *ptr, unsigned size) +I_get_sw(void *ptr, Py_ssize_t size) { unsigned int val; memcpy(&val, ptr, sizeof(val)); @@ -802,7 +794,7 @@ } static PyObject * -l_set(void *ptr, PyObject *value, unsigned size) +l_set(void *ptr, PyObject *value, Py_ssize_t size) { long val; long x; @@ -815,7 +807,7 @@ } static PyObject * -l_set_sw(void *ptr, PyObject *value, unsigned size) +l_set_sw(void *ptr, PyObject *value, Py_ssize_t size) { long val; long field; @@ -831,7 +823,7 @@ static PyObject * -l_get(void *ptr, unsigned size) +l_get(void *ptr, Py_ssize_t size) { long val; memcpy(&val, ptr, sizeof(val)); @@ -840,7 +832,7 @@ } static PyObject * -l_get_sw(void *ptr, unsigned size) +l_get_sw(void *ptr, Py_ssize_t size) { long val; memcpy(&val, ptr, sizeof(val)); @@ -850,7 +842,7 @@ } static PyObject * -L_set(void *ptr, PyObject *value, unsigned size) +L_set(void *ptr, PyObject *value, Py_ssize_t size) { unsigned long val; unsigned long x; @@ -863,7 +855,7 @@ } static PyObject * -L_set_sw(void *ptr, PyObject *value, unsigned size) +L_set_sw(void *ptr, PyObject *value, Py_ssize_t size) { unsigned long val; unsigned long field; @@ -879,7 +871,7 @@ static PyObject * -L_get(void *ptr, unsigned size) +L_get(void *ptr, Py_ssize_t size) { unsigned long val; memcpy(&val, ptr, sizeof(val)); @@ -888,7 +880,7 @@ } static PyObject * -L_get_sw(void *ptr, unsigned size) +L_get_sw(void *ptr, Py_ssize_t size) { unsigned long val; memcpy(&val, ptr, sizeof(val)); @@ -899,7 +891,7 @@ #ifdef HAVE_LONG_LONG static PyObject * -q_set(void *ptr, PyObject *value, unsigned size) +q_set(void *ptr, PyObject *value, Py_ssize_t size) { PY_LONG_LONG val; PY_LONG_LONG x; @@ -912,7 +904,7 @@ } static PyObject * -q_set_sw(void *ptr, PyObject *value, unsigned size) +q_set_sw(void *ptr, PyObject *value, Py_ssize_t size) { PY_LONG_LONG val; PY_LONG_LONG field; @@ -927,7 +919,7 @@ } static PyObject * -q_get(void *ptr, unsigned size) +q_get(void *ptr, Py_ssize_t size) { PY_LONG_LONG val; memcpy(&val, ptr, sizeof(val)); @@ -936,7 +928,7 @@ } static PyObject * -q_get_sw(void *ptr, unsigned size) +q_get_sw(void *ptr, Py_ssize_t size) { PY_LONG_LONG val; memcpy(&val, ptr, sizeof(val)); @@ -946,7 +938,7 @@ } static PyObject * -Q_set(void *ptr, PyObject *value, unsigned size) +Q_set(void *ptr, PyObject *value, Py_ssize_t size) { unsigned PY_LONG_LONG val; unsigned PY_LONG_LONG x; @@ -959,7 +951,7 @@ } static PyObject * -Q_set_sw(void *ptr, PyObject *value, unsigned size) +Q_set_sw(void *ptr, PyObject *value, Py_ssize_t size) { unsigned PY_LONG_LONG val; unsigned PY_LONG_LONG field; @@ -974,7 +966,7 @@ } static PyObject * -Q_get(void *ptr, unsigned size) +Q_get(void *ptr, Py_ssize_t size) { unsigned PY_LONG_LONG val; memcpy(&val, ptr, sizeof(val)); @@ -983,7 +975,7 @@ } static PyObject * -Q_get_sw(void *ptr, unsigned size) +Q_get_sw(void *ptr, Py_ssize_t size) { unsigned PY_LONG_LONG val; memcpy(&val, ptr, sizeof(val)); @@ -1000,7 +992,7 @@ static PyObject * -d_set(void *ptr, PyObject *value, unsigned size) +d_set(void *ptr, PyObject *value, Py_ssize_t size) { double x; @@ -1016,7 +1008,7 @@ } static PyObject * -d_get(void *ptr, unsigned size) +d_get(void *ptr, Py_ssize_t size) { double val; memcpy(&val, ptr, sizeof(val)); @@ -1024,7 +1016,7 @@ } static PyObject * -d_set_sw(void *ptr, PyObject *value, unsigned size) +d_set_sw(void *ptr, PyObject *value, Py_ssize_t size) { double x; @@ -1046,7 +1038,7 @@ } static PyObject * -d_get_sw(void *ptr, unsigned size) +d_get_sw(void *ptr, Py_ssize_t size) { #ifdef WORDS_BIGENDIAN return PyFloat_FromDouble(_PyFloat_Unpack8(ptr, 1)); @@ -1056,7 +1048,7 @@ } static PyObject * -f_set(void *ptr, PyObject *value, unsigned size) +f_set(void *ptr, PyObject *value, Py_ssize_t size) { float x; @@ -1072,7 +1064,7 @@ } static PyObject * -f_get(void *ptr, unsigned size) +f_get(void *ptr, Py_ssize_t size) { float val; memcpy(&val, ptr, sizeof(val)); @@ -1080,7 +1072,7 @@ } static PyObject * -f_set_sw(void *ptr, PyObject *value, unsigned size) +f_set_sw(void *ptr, PyObject *value, Py_ssize_t size) { float x; @@ -1102,7 +1094,7 @@ } static PyObject * -f_get_sw(void *ptr, unsigned size) +f_get_sw(void *ptr, Py_ssize_t size) { #ifdef WORDS_BIGENDIAN return PyFloat_FromDouble(_PyFloat_Unpack4(ptr, 1)); @@ -1122,7 +1114,7 @@ Py_DECREF on destruction. Maybe only when b_needsfree is non-zero. */ static PyObject * -O_get(void *ptr, unsigned size) +O_get(void *ptr, Py_ssize_t size) { PyObject *ob = *(PyObject **)ptr; if (ob == NULL) { @@ -1137,7 +1129,7 @@ } static PyObject * -O_set(void *ptr, PyObject *value, unsigned size) +O_set(void *ptr, PyObject *value, Py_ssize_t size) { /* Hm, does the memory block need it's own refcount or not? */ *(PyObject **)ptr = value; @@ -1147,7 +1139,7 @@ static PyObject * -c_set(void *ptr, PyObject *value, unsigned size) +c_set(void *ptr, PyObject *value, Py_ssize_t size) { if (!PyString_Check(value) || (1 != PyString_Size(value))) { PyErr_Format(PyExc_TypeError, @@ -1160,7 +1152,7 @@ static PyObject * -c_get(void *ptr, unsigned size) +c_get(void *ptr, Py_ssize_t size) { return PyString_FromStringAndSize((char *)ptr, 1); } @@ -1168,9 +1160,9 @@ #ifdef CTYPES_UNICODE /* u - a single wchar_t character */ static PyObject * -u_set(void *ptr, PyObject *value, unsigned size) +u_set(void *ptr, PyObject *value, Py_ssize_t size) { - int len; + Py_ssize_t len; if (PyString_Check(value)) { value = PyUnicode_FromEncodedObject(value, @@ -1202,17 +1194,17 @@ static PyObject * -u_get(void *ptr, unsigned size) +u_get(void *ptr, Py_ssize_t size) { return PyUnicode_FromWideChar((wchar_t *)ptr, 1); } /* U - a unicode string */ static PyObject * -U_get(void *ptr, unsigned size) +U_get(void *ptr, Py_ssize_t size) { PyObject *result; - unsigned int len; + Py_ssize_t len; Py_UNICODE *p; size /= sizeof(wchar_t); /* we count character units here, not bytes */ @@ -1240,9 +1232,9 @@ } static PyObject * -U_set(void *ptr, PyObject *value, unsigned length) +U_set(void *ptr, PyObject *value, Py_ssize_t length) { - unsigned int size; + Py_ssize_t size; /* It's easier to calculate in characters than in bytes */ length /= sizeof(wchar_t); @@ -1263,7 +1255,11 @@ size = PyUnicode_GET_SIZE(value); if (size > length) { PyErr_Format(PyExc_ValueError, +#if (PY_VERSION_HEX < 0x02050000) "string too long (%d, maximum length %d)", +#else + "string too long (%zd, maximum length %zd)", +#endif size, length); Py_DECREF(value); return NULL; @@ -1277,9 +1273,10 @@ #endif static PyObject * -s_get(void *ptr, unsigned size) +s_get(void *ptr, Py_ssize_t size) { PyObject *result; + size_t slen; result = PyString_FromString((char *)ptr); if (!result) @@ -1287,7 +1284,8 @@ /* chop off at the first NUL character, if any. * On error, result will be deallocated and set to NULL. */ - size = min(size, strlen(PyString_AS_STRING(result))); + slen = strlen(PyString_AS_STRING(result)); + size = min(size, (Py_ssize_t)slen); if (result->ob_refcnt == 1) { /* shorten the result */ _PyString_Resize(&result, size); @@ -1298,10 +1296,10 @@ } static PyObject * -s_set(void *ptr, PyObject *value, unsigned length) +s_set(void *ptr, PyObject *value, Py_ssize_t length) { char *data; - unsigned size; + Py_ssize_t size; data = PyString_AsString(value); if (!data) @@ -1314,7 +1312,11 @@ ++size; } else if (size > length) { PyErr_Format(PyExc_ValueError, +#if (PY_VERSION_HEX < 0x02050000) "string too long (%d, maximum length %d)", +#else + "string too long (%zd, maximum length %zd)", +#endif size, length); return NULL; } @@ -1324,7 +1326,7 @@ } static PyObject * -z_set(void *ptr, PyObject *value, unsigned size) +z_set(void *ptr, PyObject *value, Py_ssize_t size) { if (value == Py_None) { *(char **)ptr = NULL; @@ -1358,7 +1360,7 @@ } static PyObject * -z_get(void *ptr, unsigned size) +z_get(void *ptr, Py_ssize_t size) { /* XXX What about invalid pointers ??? */ if (*(void **)ptr) { @@ -1379,7 +1381,7 @@ #ifdef CTYPES_UNICODE static PyObject * -Z_set(void *ptr, PyObject *value, unsigned size) +Z_set(void *ptr, PyObject *value, Py_ssize_t size) { if (value == Py_None) { *(wchar_t **)ptr = NULL; @@ -1447,7 +1449,7 @@ } static PyObject * -Z_get(void *ptr, unsigned size) +Z_get(void *ptr, Py_ssize_t size) { wchar_t *p; p = *(wchar_t **)ptr; @@ -1470,7 +1472,7 @@ #ifdef MS_WIN32 static PyObject * -BSTR_set(void *ptr, PyObject *value, unsigned size) +BSTR_set(void *ptr, PyObject *value, Py_ssize_t size) { BSTR bstr; @@ -1494,8 +1496,13 @@ /* create a BSTR from value */ if (value) { + Py_ssize_t size = PyUnicode_GET_SIZE(value); + if ((unsigned) size != size) { + PyErr_SetString(PyExc_ValueError, "String too long for BSTR"); + return NULL; + } bstr = SysAllocStringLen(PyUnicode_AS_UNICODE(value), - PyUnicode_GET_SIZE(value)); + (unsigned)size); Py_DECREF(value); } else bstr = NULL; @@ -1513,7 +1520,7 @@ static PyObject * -BSTR_get(void *ptr, unsigned size) +BSTR_get(void *ptr, Py_ssize_t size) { BSTR p; p = *(BSTR *)ptr; @@ -1530,7 +1537,7 @@ #endif static PyObject * -P_set(void *ptr, PyObject *value, unsigned size) +P_set(void *ptr, PyObject *value, Py_ssize_t size) { void *v; if (value == Py_None) { @@ -1563,7 +1570,7 @@ } static PyObject * -P_get(void *ptr, unsigned size) +P_get(void *ptr, Py_ssize_t size) { if (*(void **)ptr == NULL) { Py_INCREF(Py_None); Modified: python/branches/p3yk/Modules/_ctypes/ctypes.h ============================================================================== --- python/branches/p3yk/Modules/_ctypes/ctypes.h (original) +++ python/branches/p3yk/Modules/_ctypes/ctypes.h Mon Jun 11 03:31:49 2007 @@ -4,6 +4,7 @@ #if (PY_VERSION_HEX < 0x02050000) typedef int Py_ssize_t; +#define PyInt_FromSsize_t PyInt_FromLong #endif #ifndef MS_WIN32 @@ -31,8 +32,8 @@ typedef struct tagPyCArgObject PyCArgObject; typedef struct tagCDataObject CDataObject; -typedef PyObject *(* GETFUNC)(void *, unsigned size); -typedef PyObject *(* SETFUNC)(void *, PyObject *value, unsigned size); +typedef PyObject *(* GETFUNC)(void *, Py_ssize_t size); +typedef PyObject *(* SETFUNC)(void *, PyObject *value, Py_ssize_t size); typedef PyCArgObject *(* PARAMFUNC)(CDataObject *obj); /* A default buffer in CDataObject, which can be used for small C types. If @@ -137,9 +138,9 @@ extern PyObject * -CField_FromDesc(PyObject *desc, int index, - int *pfield_size, int bitsize, int *pbitofs, - int *psize, int *poffset, int *palign, +CField_FromDesc(PyObject *desc, Py_ssize_t index, + Py_ssize_t *pfield_size, int bitsize, int *pbitofs, + Py_ssize_t *psize, Py_ssize_t *poffset, Py_ssize_t *palign, int pack, int is_big_endian); extern PyObject *CData_AtAddress(PyObject *type, void *buf); @@ -310,7 +311,7 @@ void *p; } value; PyObject *obj; - int size; /* for the 'V' tag */ + Py_ssize_t size; /* for the 'V' tag */ }; extern PyTypeObject PyCArg_Type; @@ -387,7 +388,7 @@ # define PyUnicode_AsWideChar My_PyUnicode_AsWideChar extern PyObject *My_PyUnicode_FromWideChar(const wchar_t *, Py_ssize_t); -extern int My_PyUnicode_AsWideChar(PyUnicodeObject *, wchar_t *, Py_ssize_t); +extern Py_ssize_t My_PyUnicode_AsWideChar(PyUnicodeObject *, wchar_t *, Py_ssize_t); #endif Modified: python/branches/p3yk/Modules/_ctypes/libffi/src/x86/ffi.c ============================================================================== --- python/branches/p3yk/Modules/_ctypes/libffi/src/x86/ffi.c (original) +++ python/branches/p3yk/Modules/_ctypes/libffi/src/x86/ffi.c Mon Jun 11 03:31:49 2007 @@ -174,7 +174,7 @@ /*@out@*/ extended_cif *, unsigned, unsigned, /*@out@*/ unsigned *, - void (*fn)()); + void (*fn)(void)); /*@=declundef@*/ /*@=exportheader@*/ @@ -185,13 +185,13 @@ /*@out@*/ extended_cif *, unsigned, unsigned, /*@out@*/ unsigned *, - void (*fn)()); + void (*fn)(void)); /*@=declundef@*/ /*@=exportheader@*/ #endif /* X86_WIN32 */ void ffi_call(/*@dependent@*/ ffi_cif *cif, - void (*fn)(), + void (*fn)(void), /*@out@*/ void *rvalue, /*@dependent@*/ void **avalue) { @@ -405,7 +405,7 @@ /*@out@*/ extended_cif *, unsigned, unsigned, /*@out@*/ unsigned *, - void (*fn)()); + void (*fn)(void)); #ifdef X86_WIN32 extern void @@ -413,12 +413,12 @@ /*@out@*/ extended_cif *, unsigned, unsigned, /*@out@*/ unsigned *, - void (*fn)()); + void (*fn)(void)); #endif /* X86_WIN32 */ void ffi_raw_call(/*@dependent@*/ ffi_cif *cif, - void (*fn)(), + void (*fn)(void), /*@out@*/ void *rvalue, /*@dependent@*/ ffi_raw *fake_avalue) { Modified: python/branches/p3yk/Modules/_ctypes/libffi/src/x86/ffi64.c ============================================================================== --- python/branches/p3yk/Modules/_ctypes/libffi/src/x86/ffi64.c (original) +++ python/branches/p3yk/Modules/_ctypes/libffi/src/x86/ffi64.c Mon Jun 11 03:31:49 2007 @@ -42,7 +42,7 @@ }; extern void ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags, - void *raddr, void (*fnaddr)(), unsigned ssecount); + void *raddr, void (*fnaddr)(void), unsigned ssecount); /* All reference to register classes here is identical to the code in gcc/config/i386/i386.c. Do *not* change one without the other. */ @@ -339,7 +339,7 @@ } void -ffi_call (ffi_cif *cif, void (*fn)(), void *rvalue, void **avalue) +ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) { enum x86_64_reg_class classes[MAX_CLASSES]; char *stack, *argp; Modified: python/branches/p3yk/Modules/_ctypes/stgdict.c ============================================================================== --- python/branches/p3yk/Modules/_ctypes/stgdict.c (original) +++ python/branches/p3yk/Modules/_ctypes/stgdict.c Mon Jun 11 03:31:49 2007 @@ -50,7 +50,7 @@ StgDict_clone(StgDictObject *dst, StgDictObject *src) { char *d, *s; - int size; + Py_ssize_t size; StgDict_clear(dst); PyMem_Free(dst->ffi_type_pointer.elements); @@ -285,13 +285,13 @@ StructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct) { StgDictObject *stgdict, *basedict; - int len, offset, size, align, i; - int union_size, total_align; - int field_size = 0; + Py_ssize_t len, offset, size, align, i; + Py_ssize_t union_size, total_align; + Py_ssize_t field_size = 0; int bitofs; PyObject *isPacked; int pack = 0; - int ffi_ofs; + Py_ssize_t ffi_ofs; int big_endian; /* HACK Alert: I cannot be bothered to fix ctypes.com, so there has to @@ -402,7 +402,11 @@ if (dict == NULL) { Py_DECREF(pair); PyErr_Format(PyExc_TypeError, +#if (PY_VERSION_HEX < 0x02050000) "second item in _fields_ tuple (index %d) must be a C type", +#else + "second item in _fields_ tuple (index %zd) must be a C type", +#endif i); return -1; } @@ -480,7 +484,9 @@ /* Adjust the size according to the alignment requirements */ size = ((size + total_align - 1) / total_align) * total_align; - stgdict->ffi_type_pointer.alignment = total_align; + stgdict->ffi_type_pointer.alignment = Py_SAFE_DOWNCAST(total_align, + Py_ssize_t, + unsigned short); stgdict->ffi_type_pointer.size = size; stgdict->size = size; Modified: python/branches/p3yk/Modules/_sqlite/cache.c ============================================================================== --- python/branches/p3yk/Modules/_sqlite/cache.c (original) +++ python/branches/p3yk/Modules/_sqlite/cache.c Mon Jun 11 03:31:49 2007 @@ -243,6 +243,7 @@ } template = PyString_FromString("%s <- %s ->%s\n"); if (!template) { + Py_DECREF(fmt_args); return NULL; } display_str = PyString_Format(template, fmt_args); Modified: python/branches/p3yk/Modules/_testcapimodule.c ============================================================================== --- python/branches/p3yk/Modules/_testcapimodule.c (original) +++ python/branches/p3yk/Modules/_testcapimodule.c Mon Jun 11 03:31:49 2007 @@ -888,6 +888,10 @@ unsigned long ulong_member; float float_member; double double_member; +#ifdef HAVE_LONG_LONG + PY_LONG_LONG longlong_member; + unsigned PY_LONG_LONG ulonglong_member; +#endif } all_structmembers; typedef struct { @@ -906,23 +910,40 @@ {"T_ULONG", T_ULONG, offsetof(test_structmembers, structmembers.ulong_member), 0, NULL}, {"T_FLOAT", T_FLOAT, offsetof(test_structmembers, structmembers.float_member), 0, NULL}, {"T_DOUBLE", T_DOUBLE, offsetof(test_structmembers, structmembers.double_member), 0, NULL}, +#ifdef HAVE_LONG_LONG + {"T_LONGLONG", T_LONGLONG, offsetof(test_structmembers, structmembers.longlong_member), 0, NULL}, + {"T_ULONGLONG", T_ULONGLONG, offsetof(test_structmembers, structmembers.ulonglong_member), 0, NULL}, +#endif {NULL} }; static PyObject *test_structmembers_new(PyTypeObject *type, PyObject *args, PyObject *kwargs){ static char *keywords[]={"T_BYTE", "T_UBYTE", "T_SHORT", "T_USHORT", "T_INT", "T_UINT", - "T_LONG", "T_ULONG", "T_FLOAT", "T_DOUBLE", NULL}; + "T_LONG", "T_ULONG", "T_FLOAT", "T_DOUBLE", + #ifdef HAVE_LONG_LONG + "T_LONGLONG", "T_ULONGLONG", + #endif + NULL}; + static char *fmt="|bBhHiIlkfd" + #ifdef HAVE_LONG_LONG + "LK" + #endif + ; test_structmembers *ob=PyObject_New(test_structmembers, type); if (ob==NULL) return NULL; memset(&ob->structmembers, 0, sizeof(all_structmembers)); - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|bBhHiIlkfd", keywords, + if (!PyArg_ParseTupleAndKeywords(args, kwargs, fmt, keywords, &ob->structmembers.byte_member, &ob->structmembers.ubyte_member, &ob->structmembers.short_member, &ob->structmembers.ushort_member, &ob->structmembers.int_member, &ob->structmembers.uint_member, &ob->structmembers.long_member, &ob->structmembers.ulong_member, - &ob->structmembers.float_member, &ob->structmembers.double_member)){ + &ob->structmembers.float_member, &ob->structmembers.double_member + #ifdef HAVE_LONG_LONG + ,&ob->structmembers.longlong_member, &ob->structmembers.ulonglong_member + #endif + )){ Py_DECREF(ob); return NULL; } @@ -1005,6 +1026,9 @@ PyModule_AddObject(m, "FLT_MIN", PyFloat_FromDouble(FLT_MIN)); PyModule_AddObject(m, "DBL_MAX", PyFloat_FromDouble(DBL_MAX)); PyModule_AddObject(m, "DBL_MIN", PyFloat_FromDouble(DBL_MIN)); + 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)); Modified: python/branches/p3yk/Modules/cjkcodecs/multibytecodec.c ============================================================================== --- python/branches/p3yk/Modules/cjkcodecs/multibytecodec.c (original) +++ python/branches/p3yk/Modules/cjkcodecs/multibytecodec.c Mon Jun 11 03:31:49 2007 @@ -1214,6 +1214,8 @@ cres = NULL; for (;;) { + int endoffile; + if (sizehint < 0) cres = PyObject_CallMethod(self->stream, (char *)method, NULL); @@ -1230,6 +1232,8 @@ goto errorexit; } + endoffile = (PyString_GET_SIZE(cres) == 0); + if (self->pendingsize > 0) { PyObject *ctr; char *ctrdata; @@ -1257,7 +1261,7 @@ (MultibyteStatefulDecoderContext *)self, &buf)) goto errorexit; - if (rsize == 0 || sizehint < 0) { /* end of file */ + if (endoffile || sizehint < 0) { if (buf.inbuf < buf.inbuf_end && multibytecodec_decerror(self->codec, &self->state, &buf, self->errors, MBERR_TOOFEW)) Modified: python/branches/p3yk/Modules/getbuildinfo.c ============================================================================== --- python/branches/p3yk/Modules/getbuildinfo.c (original) +++ python/branches/p3yk/Modules/getbuildinfo.c Mon Jun 11 03:31:49 2007 @@ -20,7 +20,14 @@ #endif #endif +/* on unix, SVNVERSION is passed on the command line. + * on Windows, the string is interpolated using + * subwcrev.exe + */ +#ifndef SVNVERSION #define SVNVERSION "$WCRANGE$$WCMODS?M:$" +#endif + const char * Py_GetBuildInfo(void) { @@ -39,7 +46,7 @@ { /* the following string can be modified by subwcrev.exe */ static const char svnversion[] = SVNVERSION; - if (!strstr(svnversion, "$")) - return svnversion; /* it was interpolated */ + if (svnversion[0] != '$') + return svnversion; /* it was interpolated, or passed on command line */ return "exported"; } Modified: python/branches/p3yk/Modules/socketmodule.c ============================================================================== --- python/branches/p3yk/Modules/socketmodule.c (original) +++ python/branches/p3yk/Modules/socketmodule.c Mon Jun 11 03:31:49 2007 @@ -363,8 +363,11 @@ #define BTPROTO_L2CAP BLUETOOTH_PROTO_L2CAP #define BTPROTO_RFCOMM BLUETOOTH_PROTO_RFCOMM #define BTPROTO_HCI BLUETOOTH_PROTO_HCI +#define SOL_HCI SOL_HCI_RAW +#define HCI_FILTER SO_HCI_RAW_FILTER #define sockaddr_l2 sockaddr_l2cap #define sockaddr_rc sockaddr_rfcomm +#define hci_dev hci_node #define _BT_L2_MEMB(sa, memb) ((sa)->l2cap_##memb) #define _BT_RC_MEMB(sa, memb) ((sa)->rfcomm_##memb) #define _BT_HCI_MEMB(sa, memb) ((sa)->hci_##memb) @@ -4447,10 +4450,10 @@ PyModule_AddIntConstant(m, "BTPROTO_L2CAP", BTPROTO_L2CAP); PyModule_AddIntConstant(m, "BTPROTO_HCI", BTPROTO_HCI); PyModule_AddIntConstant(m, "SOL_HCI", SOL_HCI); - PyModule_AddIntConstant(m, "HCI_TIME_STAMP", HCI_TIME_STAMP); - PyModule_AddIntConstant(m, "HCI_DATA_DIR", HCI_DATA_DIR); PyModule_AddIntConstant(m, "HCI_FILTER", HCI_FILTER); #if !defined(__FreeBSD__) + PyModule_AddIntConstant(m, "HCI_TIME_STAMP", HCI_TIME_STAMP); + PyModule_AddIntConstant(m, "HCI_DATA_DIR", HCI_DATA_DIR); PyModule_AddIntConstant(m, "BTPROTO_SCO", BTPROTO_SCO); #endif PyModule_AddIntConstant(m, "BTPROTO_RFCOMM", BTPROTO_RFCOMM); Modified: python/branches/p3yk/Objects/bufferobject.c ============================================================================== --- python/branches/p3yk/Objects/bufferobject.c (original) +++ python/branches/p3yk/Objects/bufferobject.c Mon Jun 11 03:31:49 2007 @@ -19,7 +19,7 @@ READ_BUFFER, WRITE_BUFFER, CHAR_BUFFER, - ANY_BUFFER, + ANY_BUFFER }; static int Modified: python/branches/p3yk/Objects/stringobject.c ============================================================================== --- python/branches/p3yk/Objects/stringobject.c (original) +++ python/branches/p3yk/Objects/stringobject.c Mon Jun 11 03:31:49 2007 @@ -3309,7 +3309,7 @@ { const char *e, *p; char *q; - Py_ssize_t i, j; + Py_ssize_t i, j, old_j; PyObject *u; int tabsize = 8; @@ -3317,12 +3317,18 @@ return NULL; /* First pass: determine size of output string */ - i = j = 0; + i = j = old_j = 0; e = PyString_AS_STRING(self) + PyString_GET_SIZE(self); for (p = PyString_AS_STRING(self); p < e; p++) if (*p == '\t') { - if (tabsize > 0) + if (tabsize > 0) { j += tabsize - (j % tabsize); + if (old_j > j) { + PyErr_SetString(PyExc_OverflowError, "new string is too long"); + return NULL; + } + old_j = j; + } } else { j++; @@ -3332,6 +3338,11 @@ } } + if ((i + j) < 0) { + PyErr_SetString(PyExc_OverflowError, "new string is too long"); + return NULL; + } + /* Second pass: create output string and fill it */ u = PyString_FromStringAndSize(NULL, i + j); if (!u) Modified: python/branches/p3yk/Objects/unicodeobject.c ============================================================================== --- python/branches/p3yk/Objects/unicodeobject.c (original) +++ python/branches/p3yk/Objects/unicodeobject.c Mon Jun 11 03:31:49 2007 @@ -5693,7 +5693,7 @@ Py_UNICODE *e; Py_UNICODE *p; Py_UNICODE *q; - Py_ssize_t i, j; + Py_ssize_t i, j, old_j; PyUnicodeObject *u; int tabsize = 8; @@ -5701,12 +5701,18 @@ return NULL; /* First pass: determine size of output string */ - i = j = 0; + i = j = old_j = 0; e = self->str + self->length; for (p = self->str; p < e; p++) if (*p == '\t') { - if (tabsize > 0) + if (tabsize > 0) { j += tabsize - (j % tabsize); + if (old_j > j) { + PyErr_SetString(PyExc_OverflowError, "new string is too long"); + return NULL; + } + old_j = j; + } } else { j++; @@ -5716,6 +5722,11 @@ } } + if ((i + j) < 0) { + PyErr_SetString(PyExc_OverflowError, "new string is too long"); + return NULL; + } + /* Second pass: create output string and fill it */ u = _PyUnicode_New(i + j); if (!u) Modified: python/branches/p3yk/PC/pyconfig.h ============================================================================== --- python/branches/p3yk/PC/pyconfig.h (original) +++ python/branches/p3yk/PC/pyconfig.h Mon Jun 11 03:31:49 2007 @@ -247,6 +247,9 @@ #define COMPILER "[gcc]" #define hypot _hypot #define PY_LONG_LONG long long +#define PY_LLONG_MIN LLONG_MIN +#define PY_LLONG_MAX LLONG_MAX +#define PY_ULLONG_MAX ULLONG_MAX #endif /* GNUC */ /* ------------------------------------------------------------------------*/ @@ -272,6 +275,9 @@ #define HAVE_LONG_LONG 1 #ifndef PY_LONG_LONG # define PY_LONG_LONG __int64 +# define PY_LLONG_MAX LLONG_MAX +# define PY_LLONG_MIN LLONG_MIN +# define PY_ULLONG_MAX ULLONG_MAX #endif /* For Windows the Python core is in a DLL by default. Test Modified: python/branches/p3yk/PCbuild/pcbuild.sln ============================================================================== --- python/branches/p3yk/PCbuild/pcbuild.sln (original) +++ python/branches/p3yk/PCbuild/pcbuild.sln Mon Jun 11 03:31:49 2007 @@ -259,12 +259,14 @@ {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Release.ActiveCfg = Release|Win32 {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Release.Build.0 = Release|Win32 {F22F40F4-D318-40DC-96B3-88DC81CE0894}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 {F22F40F4-D318-40DC-96B3-88DC81CE0894}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Debug.ActiveCfg = Debug|Win32 {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Debug.Build.0 = Debug|Win32 {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Release.ActiveCfg = Release|Win32 {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Release.Build.0 = Release|Win32 {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 {2FF0A312-22F9-4C34-B070-842916DE27A9}.Debug.ActiveCfg = Debug|Win32 {2FF0A312-22F9-4C34-B070-842916DE27A9}.Debug.Build.0 = Debug|Win32 Modified: python/branches/p3yk/Python/ast.c ============================================================================== --- python/branches/p3yk/Python/ast.c (original) +++ python/branches/p3yk/Python/ast.c Mon Jun 11 03:31:49 2007 @@ -1922,6 +1922,10 @@ return NULL; } key = e->v.Name.id; + if (!strcmp(PyString_AS_STRING(key), "None")) { + ast_error(CHILD(ch, 0), "assignment to None"); + return NULL; + } e = ast_for_expr(c, CHILD(ch, 2)); if (!e) return NULL; Modified: python/branches/p3yk/Python/compile.c ============================================================================== --- python/branches/p3yk/Python/compile.c (original) +++ python/branches/p3yk/Python/compile.c Mon Jun 11 03:31:49 2007 @@ -1125,7 +1125,8 @@ if (!asdl_seq_LEN(stmts)) return 1; st = (stmt_ty)asdl_seq_GET(stmts, 0); - if (compiler_isdocstring(st)) { + if (compiler_isdocstring(st) && Py_OptimizeFlag < 2) { + /* don't generate docstrings if -OO */ i = 1; VISIT(c, expr, st->v.Expr.value); if (!compiler_nameop(c, __doc__, Store)) Modified: python/branches/p3yk/Python/peephole.c ============================================================================== --- python/branches/p3yk/Python/peephole.c (original) +++ python/branches/p3yk/Python/peephole.c Mon Jun 11 03:31:49 2007 @@ -302,7 +302,7 @@ /* Avoid situations where jump retargeting could overflow */ assert(PyString_Check(code)); - codelen = PyString_Size(code); + codelen = PyString_GET_SIZE(code); if (codelen > 32700) goto exitUnchanged; Modified: python/branches/p3yk/Python/structmember.c ============================================================================== --- python/branches/p3yk/Python/structmember.c (original) +++ python/branches/p3yk/Python/structmember.c Mon Jun 11 03:31:49 2007 @@ -289,31 +289,25 @@ } break; #ifdef HAVE_LONG_LONG - case T_LONGLONG: - if (!PyLong_Check(v)) { - PyErr_BadArgument(); + case T_LONGLONG:{ + PY_LONG_LONG value; + *(PY_LONG_LONG*)addr = value = PyLong_AsLongLong(v); + if ((value == -1) && PyErr_Occurred()) return -1; - } else { - PY_LONG_LONG value; - *(PY_LONG_LONG*)addr = value = PyLong_AsLongLong(v); - if ((value == -1) && PyErr_Occurred()) { - return -1; - } - } - break; - case T_ULONGLONG: - if (!PyLong_Check(v)) { - PyErr_BadArgument(); - return -1; - } else { - unsigned PY_LONG_LONG value; - *(unsigned PY_LONG_LONG*)addr = value = PyLong_AsUnsignedLongLong(v); - if ((value == (unsigned PY_LONG_LONG)-1) && - PyErr_Occurred()) { - return -1; - } - } - break; + break; + } + case T_ULONGLONG:{ + unsigned PY_LONG_LONG value; + /* ??? PyLong_AsLongLong accepts an int, but PyLong_AsUnsignedLongLong + doesn't ??? */ + if (PyLong_Check(v)) + *(unsigned PY_LONG_LONG*)addr = value = PyLong_AsUnsignedLongLong(v); + else + *(unsigned PY_LONG_LONG*)addr = value = PyInt_AsLong(v); + if ((value == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred()) + return -1; + break; + } #endif /* HAVE_LONG_LONG */ default: PyErr_Format(PyExc_SystemError, Modified: python/branches/p3yk/README ============================================================================== --- python/branches/p3yk/README (original) +++ python/branches/p3yk/README Mon Jun 11 03:31:49 2007 @@ -666,7 +666,11 @@ News regarding these platforms with more recent Cygwin versions would be appreciated! -AtheOS: From Octavian Cerna : +AtheOS: Official support has been stopped as of Python 2.6. All code will be + removed in Python 2.7 unless a maintainer steps forward for this + platform. + + From Octavian Cerna : Before building: Modified: python/branches/p3yk/configure ============================================================================== --- python/branches/p3yk/configure (original) +++ python/branches/p3yk/configure Mon Jun 11 03:31:49 2007 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 53610 . +# From configure.in Revision: 54283 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 3.0. # @@ -3753,7 +3753,7 @@ # Check for unsupported systems case $ac_sys_system/$ac_sys_release in -Linux*/1*) +atheos*|Linux*/1*) echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported. echo See README for details. exit 1;; Modified: python/branches/p3yk/configure.in ============================================================================== --- python/branches/p3yk/configure.in (original) +++ python/branches/p3yk/configure.in Mon Jun 11 03:31:49 2007 @@ -450,7 +450,7 @@ # Check for unsupported systems case $ac_sys_system/$ac_sys_release in -Linux*/1*) +atheos*|Linux*/1*) echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported. echo See README for details. exit 1;; From python-3000-checkins at python.org Mon Jun 11 06:19:18 2007 From: python-3000-checkins at python.org (martin.v.loewis) Date: Mon, 11 Jun 2007 06:19:18 +0200 (CEST) Subject: [Python-3000-checkins] r55876 - python/branches/py3k-struni/Python/codecs.c Message-ID: <20070611041918.1D2791E4002@bag.python.org> Author: martin.v.loewis Date: Mon Jun 11 06:19:13 2007 New Revision: 55876 Modified: python/branches/py3k-struni/Python/codecs.c Log: Short-cut lookup of utf-8 codec, to make import work on OSX. Modified: python/branches/py3k-struni/Python/codecs.c ============================================================================== --- python/branches/py3k-struni/Python/codecs.c (original) +++ python/branches/py3k-struni/Python/codecs.c Mon Jun 11 06:19:13 2007 @@ -319,6 +319,23 @@ PyObject *args = NULL, *result = NULL; PyObject *v; + /* XXX short-cut a few common file system + encodings for now, as otherwise the import + code can't load the codec registry. */ + if (strcmp(encoding, "utf-8") == 0 && PyUnicode_Check(object)) { + return PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(object), + PyUnicode_GET_SIZE(object), + errors); + } +#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) + if (strcmp(encoding, "mbcs") == 0 && PyUnicode_Check(object)) { + return PyUnicode_EncodeMBCS(PyUnicode_AS_UNICODE(object), + PyUnicode_GET_SIZE(object), + errors); + } +#endif + + encoder = PyCodec_Encoder(encoding); if (encoder == NULL) goto onError; From python-3000-checkins at python.org Mon Jun 11 07:07:41 2007 From: python-3000-checkins at python.org (neal.norwitz) Date: Mon, 11 Jun 2007 07:07:41 +0200 (CEST) Subject: [Python-3000-checkins] r55880 - python/branches/p3yk/Lib/test/regrtest.py Message-ID: <20070611050741.6213B1E4002@bag.python.org> Author: neal.norwitz Date: Mon Jun 11 07:07:36 2007 New Revision: 55880 Modified: python/branches/p3yk/Lib/test/regrtest.py Log: Fix the refleak counter on test_collections. The ABC metaclass creates a registry which must be cleared on each run. Otherwise, there *seem* to be refleaks when there really aren't any. (The class is held within the registry even though it's no longer needed.) Modified: python/branches/p3yk/Lib/test/regrtest.py ============================================================================== --- python/branches/p3yk/Lib/test/regrtest.py (original) +++ python/branches/p3yk/Lib/test/regrtest.py Mon Jun 11 07:07:36 2007 @@ -697,7 +697,7 @@ import gc, copy_reg import _strptime, linecache, dircache import urlparse, urllib, urllib2, mimetypes, doctest - import struct, filecmp + import struct, filecmp, collections from distutils.dir_util import _path_created # Restore some original values. @@ -707,6 +707,10 @@ sys.path_importer_cache.clear() sys.path_importer_cache.update(pic) + # Clear ABC registries. + for obj in [collections.Hashable, collections.Iterable]: + obj._ABCMeta__registry.clear() + # Clear assorted module caches. _path_created.clear() re.purge() From python-3000-checkins at python.org Mon Jun 11 07:46:38 2007 From: python-3000-checkins at python.org (neal.norwitz) Date: Mon, 11 Jun 2007 07:46:38 +0200 (CEST) Subject: [Python-3000-checkins] r55884 - python/branches/p3yk/Misc/build.sh Message-ID: <20070611054638.8FED91E4002@bag.python.org> Author: neal.norwitz Date: Mon Jun 11 07:46:33 2007 New Revision: 55884 Modified: python/branches/p3yk/Misc/build.sh Log: These tests have been removed, so they are no longer needed here Modified: python/branches/p3yk/Misc/build.sh ============================================================================== --- python/branches/p3yk/Misc/build.sh (original) +++ python/branches/p3yk/Misc/build.sh Mon Jun 11 07:46:33 2007 @@ -70,7 +70,7 @@ LEAKY_TESTS="test_(cmd_line|socket)" # These tests always fail, so skip them so we don't get false positives. -_ALWAYS_SKIP="test_compiler test_transformer" +_ALWAYS_SKIP="" ALWAYS_SKIP="-x $_ALWAYS_SKIP" # Skip these tests altogether when looking for leaks. These tests From python-3000-checkins at python.org Mon Jun 11 09:26:41 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Mon, 11 Jun 2007 09:26:41 +0200 (CEST) Subject: [Python-3000-checkins] r55886 - in python/branches/p3yk: Lib/test/test_peepholer.py Python/compile.c Python/peephole.c Message-ID: <20070611072641.15B611E4002@bag.python.org> Author: georg.brandl Date: Mon Jun 11 09:26:37 2007 New Revision: 55886 Modified: python/branches/p3yk/Lib/test/test_peepholer.py python/branches/p3yk/Python/compile.c python/branches/p3yk/Python/peephole.c Log: Optimize access to True and False in the compiler (if True) and the peepholer (LOAD_NAME True). Modified: python/branches/p3yk/Lib/test/test_peepholer.py ============================================================================== --- python/branches/p3yk/Lib/test/test_peepholer.py (original) +++ python/branches/p3yk/Lib/test/test_peepholer.py Mon Jun 11 09:26:37 2007 @@ -39,16 +39,24 @@ asm = dis_single(line) self.assert_(elem in asm) - def test_none_as_constant(self): - # LOAD_GLOBAL None --> LOAD_CONST None + def test_global_as_constant(self): + # LOAD_GLOBAL None/True/False --> LOAD_CONST None/True/False def f(x): None + None return x - asm = disassemble(f) - for elem in ('LOAD_GLOBAL',): - self.assert_(elem not in asm) - for elem in ('LOAD_CONST', '(None)'): - self.assert_(elem in asm) + def g(x): + True + return x + def h(x): + False + return x + for func, name in ((f, 'None'), (g, 'True'), (h, 'False')): + asm = disassemble(func) + for elem in ('LOAD_GLOBAL',): + self.assert_(elem not in asm) + for elem in ('LOAD_CONST', '('+name+')'): + self.assert_(elem in asm) def f(): 'Adding a docstring made this test fail in Py2.5.0' return None Modified: python/branches/p3yk/Python/compile.c ============================================================================== --- python/branches/p3yk/Python/compile.c (original) +++ python/branches/p3yk/Python/compile.c Mon Jun 11 09:26:37 2007 @@ -2948,6 +2948,7 @@ static int expr_constant(expr_ty e) { + char *id; switch (e->kind) { case Ellipsis_kind: return 1; @@ -2956,11 +2957,13 @@ case Str_kind: return PyObject_IsTrue(e->v.Str.s); case Name_kind: - /* __debug__ is not assignable, so we can optimize - * it away in if and while statements */ - if (strcmp(PyString_AS_STRING(e->v.Name.id), - "__debug__") == 0) - return ! Py_OptimizeFlag; + /* optimize away names that can't be reassigned */ + id = PyString_AS_STRING(e->v.Name.id); + if (strcmp(id, "True") == 0) return 1; + if (strcmp(id, "False") == 0) return 0; + if (strcmp(id, "None") == 0) return 0; + if (strcmp(id, "__debug__") == 0) + return ! Py_OptimizeFlag; /* fall through */ default: return -1; Modified: python/branches/p3yk/Python/peephole.c ============================================================================== --- python/branches/p3yk/Python/peephole.c (original) +++ python/branches/p3yk/Python/peephole.c Mon Jun 11 09:26:37 2007 @@ -257,6 +257,37 @@ return blocks; } +/* Helper to replace LOAD_NAME None/True/False with LOAD_CONST + Returns: 0 if no change, 1 if change, -1 if error */ +static int +load_global(unsigned char *codestr, Py_ssize_t i, char *name, PyObject *consts) +{ + Py_ssize_t j; + PyObject *obj; + if (name == NULL) + return 0; + if (strcmp(name, "None") == 0) + obj = Py_None; + else if (strcmp(name, "True") == 0) + obj = Py_True; + else if (strcmp(name, "False") == 0) + obj = Py_False; + else + return 0; + for (j = 0; j < PyList_GET_SIZE(consts); j++) { + if (PyList_GET_ITEM(consts, j) == obj) + break; + } + if (j == PyList_GET_SIZE(consts)) { + if (PyList_Append(consts, obj) < 0) + return -1; + } + assert(PyList_GET_ITEM(consts, j) == obj); + codestr[i] = LOAD_CONST; + SETARG(codestr, i, j); + return 1; +} + /* Perform basic peephole optimizations to components of a code object. The consts object should still be in list form to allow new constants to be appended. @@ -371,25 +402,17 @@ codestr[i+3] = NOP; break; - /* Replace LOAD_GLOBAL/LOAD_NAME None - with LOAD_CONST None */ + /* Replace LOAD_GLOBAL/LOAD_NAME None/True/False + with LOAD_CONST None/True/False */ case LOAD_NAME: case LOAD_GLOBAL: j = GETARG(codestr, i); name = PyString_AsString(PyTuple_GET_ITEM(names, j)); - if (name == NULL || strcmp(name, "None") != 0) + h = load_global(codestr, i, name, consts); + if (h < 0) + goto exitUnchanged; + else if (h == 0) continue; - for (j=0 ; j < PyList_GET_SIZE(consts) ; j++) { - if (PyList_GET_ITEM(consts, j) == Py_None) - break; - } - if (j == PyList_GET_SIZE(consts)) { - if (PyList_Append(consts, Py_None) == -1) - goto exitUnchanged; - } - assert(PyList_GET_ITEM(consts, j) == Py_None); - codestr[i] = LOAD_CONST; - SETARG(codestr, i, j); cumlc = lastlc + 1; break; From nnorwitz at gmail.com Mon Jun 11 14:47:39 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Mon, 11 Jun 2007 08:47:39 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures basics (1) Message-ID: <20070611124739.GA3598@python.psfb.org> test_grammar test_opcodes test_dict test_builtin test_exceptions test test_exceptions failed -- Traceback (most recent call last): File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 186, in testSettingException test_capi1() File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 155, in test_capi1 import _testcapi ImportError: No module named _testcapi test_types test_unittest test_doctest test_doctest2 test_StringIO test___all__ test___future__ test__locale test_abc test_aepack test_aepack skipped -- No module named aepack test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_buffer test_bufio test_bytes test_bz2 test_cProfile test_calendar test_call test_capi test_capi skipped -- No module named _testcapi test_cfgparser test_cgi test_charmapcodec test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_cn skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_hk test_codecmaps_hk skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_jp test_codecmaps_jp skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_kr test_codecmaps_kr skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_tw test_codecmaps_tw skipped -- Use of the `urlfetch' resource not enabled test_codecs test_codecs skipped -- No module named _testcapi test_codeop test_coding test_collections test_colorsys test_commands test_compare test_compile test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictviews test_difflib test_dircache test_dis test_distutils test_dl test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_ftplib test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getargs2 skipped -- No module named _testcapi test_getopt test_gettext test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imaplib test_imp test_import test_importhooks test_index test_inspect test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_keywordonlyarg test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_listcomps test_locale test_logging test_long test_long_future test_longexp test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_metaclass test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_normalization test_normalization skipped -- Use of the `urlfetch' resource not enabled test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [10547 refs] [10547 refs] [10547 refs] test_poplib test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [11431 refs] [11431 refs] test_random test_re test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sgmllib test_shelve test_shlex test_shutil test_signal test_site test_slice test_smtplib test_socket test_socket_ssl test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strptime test_struct test_structmembers test_structmembers skipped -- No module named _testcapi test_structseq test_subprocess [10541 refs] [10539 refs] [10541 refs] [10541 refs] [10541 refs] [10541 refs] [10541 refs] [10541 refs] [10541 refs] [10541 refs] [10539 refs] [13818 refs] [10757 refs] [10542 refs] [10542 refs] [10541 refs] [10541 refs] [10541 refs] [10541 refs] . [10541 refs] [10541 refs] this bit of output is from a test of stdout in a different process ... [10541 refs] [10541 refs] [10757 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [10541 refs] [10541 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [10543 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test test_tokenize crashed -- : new string is too long test_trace test_traceback test_tuple test_typechecks test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_unpack test_unpack_ex test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmlrpc test_xpickle test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zlib 283 tests OK. 2 tests failed: test_exceptions test_tokenize 32 tests skipped: test_aepack test_applesingle test_bsddb3 test_capi test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_curses test_getargs2 test_ioctl test_linuxaudiodev test_macostools test_normalization test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socketserver test_startfile test_structmembers test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_getargs2 test_capi test_tcl test_ioctl test_structmembers test_codecs [605301 refs] From nnorwitz at gmail.com Mon Jun 11 14:53:26 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Mon, 11 Jun 2007 08:53:26 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures opt (1) Message-ID: <20070611125326.GA4306@python.psfb.org> test_grammar test_opcodes test_dict test_builtin test_exceptions test test_exceptions failed -- Traceback (most recent call last): File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 186, in testSettingException test_capi1() File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 155, in test_capi1 import _testcapi ImportError: No module named _testcapi test_types test_unittest test_doctest test_doctest2 test_StringIO test___all__ test___future__ test__locale test_abc test_aepack test_aepack skipped -- No module named aepack test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_buffer test_bufio test_bytes test_bz2 test_cProfile test_calendar test_call test_capi test_capi skipped -- No module named _testcapi test_cfgparser test_cgi test_charmapcodec test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_cn skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_hk test_codecmaps_hk skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_jp test_codecmaps_jp skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_kr test_codecmaps_kr skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_tw test_codecmaps_tw skipped -- Use of the `urlfetch' resource not enabled test_codecs test_codecs skipped -- No module named _testcapi test_codeop test_coding test_collections test_colorsys test_commands test_compare test_compile test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictviews test_difflib test_dircache test_dis test_distutils [13986 refs] test_dl test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_ftplib test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getargs2 skipped -- No module named _testcapi test_getopt test_gettext test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imaplib test_imp test_import test_importhooks test_index test_inspect test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_keywordonlyarg test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_listcomps test_locale test_logging test_long test_long_future test_longexp test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_metaclass test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_normalization test_normalization skipped -- Use of the `urlfetch' resource not enabled test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [10547 refs] [10547 refs] [10547 refs] test_poplib test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [11431 refs] [11431 refs] test_random test_re test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sgmllib test_shelve test_shlex test_shutil test_signal test_site test_slice test_smtplib test_socket test_socket_ssl test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strptime test_struct test_structmembers test_structmembers skipped -- No module named _testcapi test_structseq test_subprocess [10541 refs] [10539 refs] [10541 refs] [10541 refs] [10541 refs] [10541 refs] [10541 refs] [10541 refs] [10541 refs] [10541 refs] [10539 refs] [13818 refs] [10757 refs] [10542 refs] [10542 refs] [10541 refs] [10541 refs] [10541 refs] [10541 refs] . [10541 refs] [10541 refs] this bit of output is from a test of stdout in a different process ... [10541 refs] [10541 refs] [10757 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [10541 refs] [10541 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [10543 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test test_tokenize crashed -- : new string is too long test_trace test_traceback test_tuple test_typechecks test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_unpack test_unpack_ex test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmlrpc test_xpickle test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zlib 283 tests OK. 2 tests failed: test_exceptions test_tokenize 32 tests skipped: test_aepack test_applesingle test_bsddb3 test_capi test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_curses test_getargs2 test_ioctl test_linuxaudiodev test_macostools test_normalization test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socketserver test_startfile test_structmembers test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_getargs2 test_capi test_tcl test_ioctl test_structmembers test_codecs [604528 refs] From nnorwitz at gmail.com Mon Jun 11 15:51:26 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Mon, 11 Jun 2007 09:51:26 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures refleak (1) Message-ID: <20070611135126.GA9822@python.psfb.org> test_threading_local leaked [-91, 91, 0] references, sum=0 test_urllib2_localnet leaked [3, 3, 3] references, sum=9 From python-3000-checkins at python.org Mon Jun 11 16:03:54 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Mon, 11 Jun 2007 16:03:54 +0200 (CEST) Subject: [Python-3000-checkins] r55891 - python/branches/py3k-struni/Objects/typeobject.c Message-ID: <20070611140354.DCCBD1E4002@bag.python.org> Author: walter.doerwald Date: Mon Jun 11 16:03:45 2007 New Revision: 55891 Modified: python/branches/py3k-struni/Objects/typeobject.c Log: __module__ is a unicode string now: use PyUnicode_CompareWithASCIIString() instead of strcmp(). Simplify repr formatting. Modified: python/branches/py3k-struni/Objects/typeobject.c ============================================================================== --- python/branches/py3k-struni/Objects/typeobject.c (original) +++ python/branches/py3k-struni/Objects/typeobject.c Mon Jun 11 16:03:45 2007 @@ -2479,11 +2479,8 @@ name = type_name(type, NULL); if (name == NULL) return NULL; - if (mod != NULL && strcmp(PyString_AS_STRING(mod), "__builtin__")) - rtn = PyUnicode_FromFormat("<%s.%s object at %p>", - PyUnicode_AsString(mod), - PyUnicode_AsString(name), - self); + if (mod != NULL && PyUnicode_CompareWithASCIIString(mod, "__builtin__")) + rtn = PyUnicode_FromFormat("<%U.%U object at %p>", mod, name, self); else rtn = PyUnicode_FromFormat("<%s object at %p>", type->tp_name, self); From nnorwitz at gmail.com Mon Jun 11 16:02:34 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Mon, 11 Jun 2007 10:02:34 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures all (1) Message-ID: <20070611140234.GA11617@python.psfb.org> test_grammar test_opcodes test_dict test_builtin test_exceptions test test_exceptions failed -- Traceback (most recent call last): File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 186, in testSettingException test_capi1() File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 155, in test_capi1 import _testcapi ImportError: No module named _testcapi test_types test_unittest test_doctest test_doctest2 test_StringIO test___all__ test___future__ test__locale test_abc test_aepack test_aepack skipped -- No module named aepack test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb3 test_buffer test_bufio test_bytes test_bz2 test_cProfile test_calendar test_call test_capi test_capi skipped -- No module named _testcapi test_cfgparser test_cgi test_charmapcodec test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codecs skipped -- No module named _testcapi test_codeop test_coding test_collections test_colorsys test_commands test_compare test_compile test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictviews test_difflib test_dircache test_dis test_distutils test_dl test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_ftplib test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getargs2 skipped -- No module named _testcapi test_getopt test_gettext test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imaplib test_imp test_import test_importhooks test_index test_inspect test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_keywordonlyarg test_largefile test_list test_listcomps test_locale test_logging test_long test_long_future test_longexp test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_metaclass test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [10547 refs] [10547 refs] [10547 refs] test_poplib test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [11431 refs] [11431 refs] test_random test_re test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sgmllib test_shelve test_shlex test_shutil test_signal test_site test_slice test_smtplib test_socket test_socket_ssl test_socketserver test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strptime test_struct test_structmembers test_structmembers skipped -- No module named _testcapi test_structseq test_subprocess [10541 refs] [10539 refs] [10541 refs] [10541 refs] [10541 refs] [10541 refs] [10541 refs] [10541 refs] [10541 refs] [10541 refs] [10539 refs] [13818 refs] [10757 refs] [10542 refs] [10542 refs] [10541 refs] [10541 refs] [10541 refs] [10541 refs] . [10541 refs] [10541 refs] this bit of output is from a test of stdout in a different process ... [10541 refs] [10541 refs] [10757 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [10541 refs] [10541 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [10543 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_tokenize test test_tokenize crashed -- : new string is too long test_trace test_traceback test_tuple test_typechecks test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_unpack test_unpack_ex test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllibnet test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmlrpc test_xpickle test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zlib 294 tests OK. 2 tests failed: test_exceptions test_tokenize 18 tests skipped: test_aepack test_applesingle test_capi test_codecs test_getargs2 test_ioctl test_macostools test_pep277 test_plistlib test_scriptpackages test_startfile test_structmembers test_sunaudiodev test_tcl test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_getargs2 test_capi test_tcl test_ioctl test_structmembers test_codecs warning: DBTxn aborted in destructor. No prior commit() or abort(). [619286 refs] From python-3000-checkins at python.org Mon Jun 11 16:55:27 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Mon, 11 Jun 2007 16:55:27 +0200 (CEST) Subject: [Python-3000-checkins] r55892 - in python/branches/py3k-struni: Lib/test/test_descr.py Objects/typeobject.c Message-ID: <20070611145527.62F0F1E4009@bag.python.org> Author: walter.doerwald Date: Mon Jun 11 16:55:19 2007 New Revision: 55892 Modified: python/branches/py3k-struni/Lib/test/test_descr.py python/branches/py3k-struni/Objects/typeobject.c Log: Check unicode identifier directly instead of converting it to an 8bit string first. Modified: python/branches/py3k-struni/Lib/test/test_descr.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_descr.py (original) +++ python/branches/py3k-struni/Lib/test/test_descr.py Mon Jun 11 16:55:19 2007 @@ -1085,6 +1085,13 @@ raise TestFailed, "['foo\\0bar'] slots not caught" try: class C(object): + __slots__ = ["foo\u1234bar"] + except TypeError: + pass + else: + raise TestFailed, "['foo\\u1234bar'] slots not caught" + try: + class C(object): __slots__ = ["1"] except TypeError: pass Modified: python/branches/py3k-struni/Objects/typeobject.c ============================================================================== --- python/branches/py3k-struni/Objects/typeobject.c (original) +++ python/branches/py3k-struni/Objects/typeobject.c Mon Jun 11 16:55:19 2007 @@ -1561,7 +1561,7 @@ static int valid_identifier(PyObject *s) { - unsigned char *p; + Py_UNICODE *p; Py_ssize_t i, n; if (!PyUnicode_Check(s)) { @@ -1570,14 +1570,14 @@ s->ob_type->tp_name); return 0; } - p = (unsigned char *) PyUnicode_AsString(s); - n = strlen((char*)p)/*XXX PyString_GET_SIZE(s)*/; + p = PyUnicode_AS_UNICODE(s); + n = PyUnicode_GET_SIZE(s); /* We must reject an empty name. As a hack, we bump the length to 1 so that the loop will balk on the trailing \0. */ if (n == 0) n = 1; for (i = 0; i < n; i++, p++) { - if (!(i == 0 ? isalpha(*p) : isalnum(*p)) && *p != '_') { + if (i > 255 || (!(i == 0 ? isalpha(*p) : isalnum(*p)) && *p != '_')) { PyErr_SetString(PyExc_TypeError, "__slots__ must be identifiers"); return 0; From python-3000-checkins at python.org Mon Jun 11 17:00:27 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Mon, 11 Jun 2007 17:00:27 +0200 (CEST) Subject: [Python-3000-checkins] r55893 - python/branches/py3k-struni/Objects/funcobject.c Message-ID: <20070611150027.414A71E4002@bag.python.org> Author: walter.doerwald Date: Mon Jun 11 17:00:18 2007 New Revision: 55893 Modified: python/branches/py3k-struni/Objects/funcobject.c Log: Simplify error formatting (no default encoding required). Modified: python/branches/py3k-struni/Objects/funcobject.c ============================================================================== --- python/branches/py3k-struni/Objects/funcobject.c (original) +++ python/branches/py3k-struni/Objects/funcobject.c Mon Jun 11 17:00:18 2007 @@ -515,9 +515,8 @@ nclosure = closure == Py_None ? 0 : PyTuple_GET_SIZE(closure); if (nfree != nclosure) return PyErr_Format(PyExc_ValueError, - "%s requires closure of length %zd, not %zd", - PyUnicode_AsString(code->co_name), - nfree, nclosure); + "%U requires closure of length %zd, not %zd", + code->co_name, nfree, nclosure); if (nclosure) { Py_ssize_t i; for (i = 0; i < nclosure; i++) { From python-3000-checkins at python.org Mon Jun 11 17:37:26 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Mon, 11 Jun 2007 17:37:26 +0200 (CEST) Subject: [Python-3000-checkins] r55894 - python/branches/py3k-struni/Objects/object.c Message-ID: <20070611153726.A0E581E400B@bag.python.org> Author: walter.doerwald Date: Mon Jun 11 17:37:20 2007 New Revision: 55894 Modified: python/branches/py3k-struni/Objects/object.c Log: Simplify error formatting. Modified: python/branches/py3k-struni/Objects/object.c ============================================================================== --- python/branches/py3k-struni/Objects/object.c (original) +++ python/branches/py3k-struni/Objects/object.c Mon Jun 11 17:37:20 2007 @@ -904,8 +904,8 @@ if (tp->tp_getattr != NULL) return (*tp->tp_getattr)(v, PyUnicode_AsString(name)); PyErr_Format(PyExc_AttributeError, - "'%.50s' object has no attribute '%.400s'", - tp->tp_name, PyUnicode_AsString(name)); + "'%.50s' object has no attribute '%U'", + tp->tp_name, name); return NULL; } @@ -951,17 +951,17 @@ if (tp->tp_getattr == NULL && tp->tp_getattro == NULL) PyErr_Format(PyExc_TypeError, "'%.100s' object has no attributes " - "(%s .%.100s)", + "(%s .%U)", tp->tp_name, value==NULL ? "del" : "assign to", - PyUnicode_AsString(name)); + name); else PyErr_Format(PyExc_TypeError, "'%.100s' object has only read-only attributes " - "(%s .%.100s)", + "(%s .%U)", tp->tp_name, value==NULL ? "del" : "assign to", - PyUnicode_AsString(name)); + name); return -1; } @@ -1167,14 +1167,14 @@ if (descr == NULL) { PyErr_Format(PyExc_AttributeError, - "'%.100s' object has no attribute '%.200s'", - tp->tp_name, PyUnicode_AsString(name)); + "'%.100s' object has no attribute '%U'", + tp->tp_name, name); goto done; } PyErr_Format(PyExc_AttributeError, - "'%.50s' object attribute '%.400s' is read-only", - tp->tp_name, PyUnicode_AsString(name)); + "'%.50s' object attribute '%U' is read-only", + tp->tp_name, name); done: Py_DECREF(name); return res; From python-3000-checkins at python.org Mon Jun 11 17:47:21 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Mon, 11 Jun 2007 17:47:21 +0200 (CEST) Subject: [Python-3000-checkins] r55895 - python/branches/py3k-struni/Objects/typeobject.c Message-ID: <20070611154721.1F0E51E4002@bag.python.org> Author: walter.doerwald Date: Mon Jun 11 17:47:13 2007 New Revision: 55895 Modified: python/branches/py3k-struni/Objects/typeobject.c Log: Simplify error formatting and type_repr(). Modified: python/branches/py3k-struni/Objects/typeobject.c ============================================================================== --- python/branches/py3k-struni/Objects/typeobject.c (original) +++ python/branches/py3k-struni/Objects/typeobject.c Mon Jun 11 17:47:13 2007 @@ -384,12 +384,8 @@ else kind = "type"; - if (mod != NULL && strcmp(PyUnicode_AsString(mod), "__builtin__")) { - rtn = PyUnicode_FromFormat("<%s '%s.%s'>", - kind, - PyUnicode_AsString(mod), - PyUnicode_AsString(name)); - } + if (mod != NULL && PyUnicode_CompareWithASCIIString(mod, "__builtin__")) + rtn = PyUnicode_FromFormat("<%s '%U.%U'>", kind, mod, name); else rtn = PyUnicode_FromFormat("<%s '%s'>", kind, type->tp_name); @@ -2155,8 +2151,8 @@ /* Give up */ PyErr_Format(PyExc_AttributeError, - "type object '%.50s' has no attribute '%.400s'", - type->tp_name, PyUnicode_AsString(name)); + "type object '%.50s' has no attribute '%U'", + type->tp_name, name); return NULL; } From python-3000-checkins at python.org Mon Jun 11 18:03:26 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Mon, 11 Jun 2007 18:03:26 +0200 (CEST) Subject: [Python-3000-checkins] r55897 - python/branches/py3k-struni/Python/symtable.c Message-ID: <20070611160326.391F61E4002@bag.python.org> Author: walter.doerwald Date: Mon Jun 11 18:03:16 2007 New Revision: 55897 Modified: python/branches/py3k-struni/Python/symtable.c Log: Simplify ste_repr(). Modified: python/branches/py3k-struni/Python/symtable.c ============================================================================== --- python/branches/py3k-struni/Python/symtable.c (original) +++ python/branches/py3k-struni/Python/symtable.c Mon Jun 11 18:03:16 2007 @@ -88,13 +88,9 @@ static PyObject * ste_repr(PySTEntryObject *ste) { - char buf[256]; - - PyOS_snprintf(buf, sizeof(buf), - "", - PyUnicode_AsString(ste->ste_name), - PyInt_AS_LONG(ste->ste_id), ste->ste_lineno); - return PyUnicode_FromString(buf); + return PyUnicode_FromFormat("", + ste->ste_name, + PyInt_AS_LONG(ste->ste_id), ste->ste_lineno); } static void From python-3000-checkins at python.org Mon Jun 11 18:06:29 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Mon, 11 Jun 2007 18:06:29 +0200 (CEST) Subject: [Python-3000-checkins] r55898 - python/branches/py3k-struni/Python/symtable.c Message-ID: <20070611160629.0A6651E400F@bag.python.org> Author: walter.doerwald Date: Mon Jun 11 18:06:26 2007 New Revision: 55898 Modified: python/branches/py3k-struni/Python/symtable.c Log: Simplify error formatting. Fix error message in check_unoptimized(). Modified: python/branches/py3k-struni/Python/symtable.c ============================================================================== --- python/branches/py3k-struni/Python/symtable.c (original) +++ python/branches/py3k-struni/Python/symtable.c Mon Jun 11 18:06:26 2007 @@ -385,14 +385,14 @@ if (flags & DEF_GLOBAL) { if (flags & DEF_PARAM) { PyErr_Format(PyExc_SyntaxError, - "name '%s' is parameter and global", - PyUnicode_AsString(name)); + "name '%U' is parameter and global", + name); return 0; } if (flags & DEF_NONLOCAL) { PyErr_Format(PyExc_SyntaxError, - "name '%s' is nonlocal and global", - PyUnicode_AsString(name)); + "name '%U' is nonlocal and global", + name); return 0; } SET_SCOPE(scopes, name, GLOBAL_EXPLICIT); @@ -405,8 +405,8 @@ if (flags & DEF_NONLOCAL) { if (flags & DEF_PARAM) { PyErr_Format(PyExc_SyntaxError, - "name '%s' is parameter and nonlocal", - PyUnicode_AsString(name)); + "name '%U' is parameter and nonlocal", + name); return 0; } if (!bound) { @@ -416,8 +416,8 @@ } if (!PySet_Contains(bound, name)) { PyErr_Format(PyExc_SyntaxError, - "no binding for nonlocal '%s' found", - PyUnicode_AsString(name)); + "no binding for nonlocal '%U' found", + name); return 0; } @@ -517,10 +517,10 @@ case OPT_TOPLEVEL: /* import * at top-level is fine */ return 1; case OPT_IMPORT_STAR: - PyOS_snprintf(buf, sizeof(buf), - "import * is not allowed in function '%.100s' " - "because it is %s", - PyUnicode_AsString(ste->ste_name), trailer); + PyOS_snprintf(buf, sizeof(buf), + "import * is not allowed in function '%U' " + "because it %s", + ste->ste_name, trailer); break; } From python-3000-checkins at python.org Mon Jun 11 18:08:46 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Mon, 11 Jun 2007 18:08:46 +0200 (CEST) Subject: [Python-3000-checkins] r55899 - python/branches/py3k-struni/Python/symtable.c Message-ID: <20070611160846.D833A1E4002@bag.python.org> Author: walter.doerwald Date: Mon Jun 11 18:08:41 2007 New Revision: 55899 Modified: python/branches/py3k-struni/Python/symtable.c Log: Use PyErr_Format() directly instead of PyOS_snprintf()+PyErr_SetString(). Modified: python/branches/py3k-struni/Python/symtable.c ============================================================================== --- python/branches/py3k-struni/Python/symtable.c (original) +++ python/branches/py3k-struni/Python/symtable.c Mon Jun 11 18:08:41 2007 @@ -517,14 +517,12 @@ case OPT_TOPLEVEL: /* import * at top-level is fine */ return 1; case OPT_IMPORT_STAR: - PyOS_snprintf(buf, sizeof(buf), - "import * is not allowed in function '%U' " - "because it %s", - ste->ste_name, trailer); + PyErr_Format("import * is not allowed in function '%U' " + "because it %s", + ste->ste_name, trailer); break; } - PyErr_SetString(PyExc_SyntaxError, buf); PyErr_SyntaxLocation(ste->ste_table->st_filename, ste->ste_opt_lineno); return 0; From python-3000-checkins at python.org Mon Jun 11 18:12:11 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Mon, 11 Jun 2007 18:12:11 +0200 (CEST) Subject: [Python-3000-checkins] r55900 - python/branches/py3k-struni/Python/symtable.c Message-ID: <20070611161211.6E3E31E4002@bag.python.org> Author: walter.doerwald Date: Mon Jun 11 18:12:10 2007 New Revision: 55900 Modified: python/branches/py3k-struni/Python/symtable.c Log: Fix PyErr_Format() call (missing exception class). Remove unused variable. Modified: python/branches/py3k-struni/Python/symtable.c ============================================================================== --- python/branches/py3k-struni/Python/symtable.c (original) +++ python/branches/py3k-struni/Python/symtable.c Mon Jun 11 18:12:10 2007 @@ -502,7 +502,6 @@ /* Check for illegal statements in unoptimized namespaces */ static int check_unoptimized(const PySTEntryObject* ste) { - char buf[300]; const char* trailer; if (ste->ste_type != FunctionBlock || !ste->ste_unoptimized @@ -517,8 +516,8 @@ case OPT_TOPLEVEL: /* import * at top-level is fine */ return 1; case OPT_IMPORT_STAR: - PyErr_Format("import * is not allowed in function '%U' " - "because it %s", + PyErr_Format(PyExc_SyntaxError, + "import * is not allowed in function '%U' because it %s", ste->ste_name, trailer); break; } From python-3000-checkins at python.org Mon Jun 11 18:37:05 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Mon, 11 Jun 2007 18:37:05 +0200 (CEST) Subject: [Python-3000-checkins] r55902 - python/branches/py3k-struni/Objects/classobject.c python/branches/py3k-struni/Objects/descrobject.c python/branches/py3k-struni/Objects/unicodeobject.c Message-ID: <20070611163705.9285C1E4002@bag.python.org> Author: walter.doerwald Date: Mon Jun 11 18:36:59 2007 New Revision: 55902 Modified: python/branches/py3k-struni/Objects/classobject.c python/branches/py3k-struni/Objects/descrobject.c python/branches/py3k-struni/Objects/unicodeobject.c Log: Add a format specifier %V to PyUnicode_FromFormat(), that works similar to %U, but requires an additional char * that will be used if the unicode object is NULL. Use %V in descrobject.c and classobject.c. Modified: python/branches/py3k-struni/Objects/classobject.c ============================================================================== --- python/branches/py3k-struni/Objects/classobject.c (original) +++ python/branches/py3k-struni/Objects/classobject.c Mon Jun 11 18:36:59 2007 @@ -227,7 +227,7 @@ PyObject *func = a->im_func; PyObject *klass = a->im_class; PyObject *funcname = NULL, *klassname = NULL, *result = NULL; - char *sfuncname = "?", *sklassname = "?"; + char *defname = "?"; funcname = PyObject_GetAttrString(func, "__name__"); if (funcname == NULL) { @@ -239,8 +239,6 @@ Py_DECREF(funcname); funcname = NULL; } - else - sfuncname = PyUnicode_AsString(funcname); if (klass == NULL) klassname = NULL; else { @@ -254,16 +252,16 @@ Py_DECREF(klassname); klassname = NULL; } - else - sklassname = PyUnicode_AsString(klassname); } if (self == NULL) - result = PyUnicode_FromFormat("", - sklassname, sfuncname); + result = PyUnicode_FromFormat("", + klassname, defname, + funcname, defname); else { /* XXX Shouldn't use repr()/%R here! */ - result = PyUnicode_FromFormat("", - sklassname, sfuncname, self); + result = PyUnicode_FromFormat("", + klassname, defname, + funcname, defname, self); } Py_XDECREF(funcname); Py_XDECREF(klassname); Modified: python/branches/py3k-struni/Objects/descrobject.c ============================================================================== --- python/branches/py3k-struni/Objects/descrobject.c (original) +++ python/branches/py3k-struni/Objects/descrobject.c Mon Jun 11 18:36:59 2007 @@ -12,51 +12,50 @@ PyObject_GC_Del(descr); } -static char * +static PyObject * descr_name(PyDescrObject *descr) { if (descr->d_name != NULL && PyUnicode_Check(descr->d_name)) - return PyUnicode_AsString(descr->d_name); - else if (descr->d_name != NULL && PyString_Check(descr->d_name)) - /* XXX this should not happen */ - return PyString_AS_STRING(descr->d_name); - else - return "?"; + return descr->d_name; + return NULL; } static PyObject * descr_repr(PyDescrObject *descr, char *format) { - return PyUnicode_FromFormat(format, descr_name(descr), - descr->d_type->tp_name); + PyObject *name = NULL; + if (descr->d_name != NULL && PyUnicode_Check(descr->d_name)) + name = descr->d_name; + + return PyUnicode_FromFormat(format, name, "?", descr->d_type->tp_name); } static PyObject * method_repr(PyMethodDescrObject *descr) { return descr_repr((PyDescrObject *)descr, - ""); + ""); } static PyObject * member_repr(PyMemberDescrObject *descr) { return descr_repr((PyDescrObject *)descr, - ""); + ""); } static PyObject * getset_repr(PyGetSetDescrObject *descr) { return descr_repr((PyDescrObject *)descr, - ""); + ""); } static PyObject * wrapperdescr_repr(PyWrapperDescrObject *descr) { return descr_repr((PyDescrObject *)descr, - ""); + ""); } static int @@ -69,9 +68,9 @@ } if (!PyObject_TypeCheck(obj, descr->d_type)) { PyErr_Format(PyExc_TypeError, - "descriptor '%s' for '%s' objects " + "descriptor '%V' for '%s' objects " "doesn't apply to '%s' object", - descr_name((PyDescrObject *)descr), + descr_name((PyDescrObject *)descr), "?", descr->d_type->tp_name, obj->ob_type->tp_name); *pres = NULL; @@ -90,27 +89,27 @@ else { /* Wot - no type?! */ PyErr_Format(PyExc_TypeError, - "descriptor '%s' for type '%s' " + "descriptor '%V' for type '%s' " "needs either an object or a type", - descr_name((PyDescrObject *)descr), + descr_name((PyDescrObject *)descr), "?", descr->d_type->tp_name); return NULL; } } if (!PyType_Check(type)) { PyErr_Format(PyExc_TypeError, - "descriptor '%s' for type '%s' " + "descriptor '%V' for type '%s' " "needs a type, not a '%s' as arg 2", - descr_name((PyDescrObject *)descr), + descr_name((PyDescrObject *)descr), "?", descr->d_type->tp_name, type->ob_type->tp_name); return NULL; } if (!PyType_IsSubtype((PyTypeObject *)type, descr->d_type)) { PyErr_Format(PyExc_TypeError, - "descriptor '%s' for type '%s' " + "descriptor '%V' for type '%s' " "doesn't apply to type '%s'", - descr_name((PyDescrObject *)descr), + descr_name((PyDescrObject *)descr), "?", descr->d_type->tp_name, ((PyTypeObject *)type)->tp_name); return NULL; @@ -148,8 +147,8 @@ if (descr->d_getset->get != NULL) return descr->d_getset->get(obj, descr->d_getset->closure); PyErr_Format(PyExc_AttributeError, - "attribute '%.300s' of '%.100s' objects is not readable", - descr_name((PyDescrObject *)descr), + "attribute '%V' of '%.100s' objects is not readable", + descr_name((PyDescrObject *)descr), "?", descr->d_type->tp_name); return NULL; } @@ -171,9 +170,9 @@ assert(obj != NULL); if (!PyObject_IsInstance(obj, (PyObject *)(descr->d_type))) { PyErr_Format(PyExc_TypeError, - "descriptor '%.200s' for '%.100s' objects " + "descriptor '%V' for '%.100s' objects " "doesn't apply to '%.100s' object", - descr_name(descr), + descr_name(descr), "?", descr->d_type->tp_name, obj->ob_type->tp_name); *pres = -1; @@ -203,8 +202,8 @@ return descr->d_getset->set(obj, value, descr->d_getset->closure); PyErr_Format(PyExc_AttributeError, - "attribute '%.300s' of '%.100s' objects is not writable", - descr_name((PyDescrObject *)descr), + "attribute '%V' of '%.100s' objects is not writable", + descr_name((PyDescrObject *)descr), "?", descr->d_type->tp_name); return -1; } @@ -220,19 +219,19 @@ argc = PyTuple_GET_SIZE(args); if (argc < 1) { PyErr_Format(PyExc_TypeError, - "descriptor '%.300s' of '%.100s' " + "descriptor '%V' of '%.100s' " "object needs an argument", - descr_name((PyDescrObject *)descr), + descr_name((PyDescrObject *)descr), "?", descr->d_type->tp_name); return NULL; } self = PyTuple_GET_ITEM(args, 0); if (!PyObject_IsInstance(self, (PyObject *)(descr->d_type))) { PyErr_Format(PyExc_TypeError, - "descriptor '%.200s' " + "descriptor '%V' " "requires a '%.100s' object " "but received a '%.100s'", - descr_name((PyDescrObject *)descr), + descr_name((PyDescrObject *)descr), "?", descr->d_type->tp_name, self->ob_type->tp_name); return NULL; @@ -278,19 +277,19 @@ argc = PyTuple_GET_SIZE(args); if (argc < 1) { PyErr_Format(PyExc_TypeError, - "descriptor '%.300s' of '%.100s' " + "descriptor '%V' of '%.100s' " "object needs an argument", - descr_name((PyDescrObject *)descr), + descr_name((PyDescrObject *)descr), "?", descr->d_type->tp_name); return NULL; } self = PyTuple_GET_ITEM(args, 0); if (!PyObject_IsInstance(self, (PyObject *)(descr->d_type))) { PyErr_Format(PyExc_TypeError, - "descriptor '%.200s' " + "descriptor '%V' " "requires a '%.100s' object " "but received a '%.100s'", - descr_name((PyDescrObject *)descr), + descr_name((PyDescrObject *)descr), "?", descr->d_type->tp_name, self->ob_type->tp_name); return NULL; Modified: python/branches/py3k-struni/Objects/unicodeobject.c ============================================================================== --- python/branches/py3k-struni/Objects/unicodeobject.c (original) +++ python/branches/py3k-struni/Objects/unicodeobject.c Mon Jun 11 18:36:59 2007 @@ -631,6 +631,18 @@ n += PyUnicode_GET_SIZE(obj); break; } + case 'V': + { + PyObject *obj = va_arg(count, PyObject *); + const char *str = va_arg(count, const char *); + assert(obj || str); + assert(!obj || PyUnicode_Check(obj)); + if (obj) + n += PyUnicode_GET_SIZE(obj); + else + n += strlen(str); + break; + } case 'S': { PyObject *obj = va_arg(count, PyObject *); @@ -775,6 +787,19 @@ s += size; break; } + case 'V': + { + PyObject *obj = va_arg(vargs, PyObject *); + const char *str = va_arg(vargs, const char *); + if (obj) { + Py_ssize_t size = PyUnicode_GET_SIZE(obj); + Py_UNICODE_COPY(s, PyUnicode_AS_UNICODE(obj), size); + s += size; + } else { + appendstring(str); + } + break; + } case 'S': case 'R': { From python-3000-checkins at python.org Mon Jun 11 18:43:22 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Mon, 11 Jun 2007 18:43:22 +0200 (CEST) Subject: [Python-3000-checkins] r55903 - python/branches/py3k-struni/Doc/api/concrete.tex Message-ID: <20070611164322.48BB81E4002@bag.python.org> Author: walter.doerwald Date: Mon Jun 11 18:43:18 2007 New Revision: 55903 Modified: python/branches/py3k-struni/Doc/api/concrete.tex Log: Document PyUnicode_FromFormat(). Modified: python/branches/py3k-struni/Doc/api/concrete.tex ============================================================================== --- python/branches/py3k-struni/Doc/api/concrete.tex (original) +++ python/branches/py3k-struni/Doc/api/concrete.tex Mon Jun 11 18:43:18 2007 @@ -1006,6 +1006,55 @@ when \var{u} is \NULL{}. \end{cfuncdesc} +\begin{cfuncdesc}{PyObject*}{PyUnicode_FromFormat}{const char *format, ...} + Take a C \cfunction{printf()}-style \var{format} string and a + variable number of arguments, calculate the size of the resulting + Python unicode string and return a string with the values formatted into + it. The variable arguments must be C types and must correspond + exactly to the format characters in the \var{format} string. The + following format characters are allowed: + + % The descriptions for %zd and %zu are wrong, but the truth is complicated + % because not all compilers support the %z width modifier -- we fake it + % when necessary via interpolating PY_FORMAT_SIZE_T. + + % %u, %lu, %zu should have "new in Python 2.5" blurbs. + + \begin{tableiii}{l|l|l}{member}{Format Characters}{Type}{Comment} + \lineiii{\%\%}{\emph{n/a}}{The literal \% character.} + \lineiii{\%c}{int}{A single character, represented as an C int.} + \lineiii{\%d}{int}{Exactly equivalent to \code{printf("\%d")}.} + \lineiii{\%u}{unsigned int}{Exactly equivalent to \code{printf("\%u")}.} + \lineiii{\%ld}{long}{Exactly equivalent to \code{printf("\%ld")}.} + \lineiii{\%lu}{unsigned long}{Exactly equivalent to \code{printf("\%lu")}.} + \lineiii{\%zd}{Py_ssize_t}{Exactly equivalent to \code{printf("\%zd")}.} + \lineiii{\%zu}{size_t}{Exactly equivalent to \code{printf("\%zu")}.} + \lineiii{\%i}{int}{Exactly equivalent to \code{printf("\%i")}.} + \lineiii{\%x}{int}{Exactly equivalent to \code{printf("\%x")}.} + \lineiii{\%s}{char*}{A null-terminated C character array.} + \lineiii{\%p}{void*}{The hex representation of a C pointer. + Mostly equivalent to \code{printf("\%p")} except that it is + guaranteed to start with the literal \code{0x} regardless of + what the platform's \code{printf} yields.} + \lineiii{\%U}{PyObject*}{A unicode object.} + \lineiii{\%V}{PyObject*, char *}{A unicode object (which may be \NULL{}) + and a null-terminated C character array as a second parameter (which + will be used, if the first parameter is \NULL{}).} + \lineiii{\%S}{PyObject*}{The result of calling \function{PyObject_Unicode()}.} + \lineiii{\%R}{PyObject*}{The result of calling \function{PyObject_Repr()}.} + \end{tableiii} + + An unrecognized format character causes all the rest of the format + string to be copied as-is to the result string, and any extra + arguments discarded. +\end{cfuncdesc} + +\begin{cfuncdesc}{PyObject*}{PyUnicode_FromFormatV}{const char *format, + va_list vargs} + Identical to \function{PyUnicode_FromFormat()} except that it takes + exactly two arguments. +\end{cfuncdesc} + \begin{cfuncdesc}{Py_UNICODE*}{PyUnicode_AsUnicode}{PyObject *unicode} Return a read-only pointer to the Unicode object's internal \ctype{Py_UNICODE} buffer, \NULL{} if \var{unicode} is not a Unicode From python-3000-checkins at python.org Mon Jun 11 18:44:51 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Mon, 11 Jun 2007 18:44:51 +0200 (CEST) Subject: [Python-3000-checkins] r55904 - python/branches/py3k-struni/Doc/api/concrete.tex Message-ID: <20070611164451.D24EE1E4002@bag.python.org> Author: walter.doerwald Date: Mon Jun 11 18:44:48 2007 New Revision: 55904 Modified: python/branches/py3k-struni/Doc/api/concrete.tex Log: Add versionadded notes to PyUnicode_FromString(), PyUnicode_FromFormat() and PyUnicode_FromFormatV(). Modified: python/branches/py3k-struni/Doc/api/concrete.tex ============================================================================== --- python/branches/py3k-struni/Doc/api/concrete.tex (original) +++ python/branches/py3k-struni/Doc/api/concrete.tex Mon Jun 11 18:44:48 2007 @@ -1004,6 +1004,7 @@ If the buffer is not \NULL{}, the return value might be a shared object. Therefore, modification of the resulting Unicode object is only allowed when \var{u} is \NULL{}. + \versionadded{3.0} \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PyUnicode_FromFormat}{const char *format, ...} @@ -1018,8 +1019,6 @@ % because not all compilers support the %z width modifier -- we fake it % when necessary via interpolating PY_FORMAT_SIZE_T. - % %u, %lu, %zu should have "new in Python 2.5" blurbs. - \begin{tableiii}{l|l|l}{member}{Format Characters}{Type}{Comment} \lineiii{\%\%}{\emph{n/a}}{The literal \% character.} \lineiii{\%c}{int}{A single character, represented as an C int.} @@ -1047,12 +1046,14 @@ An unrecognized format character causes all the rest of the format string to be copied as-is to the result string, and any extra arguments discarded. + \versionadded{3.0} \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PyUnicode_FromFormatV}{const char *format, va_list vargs} Identical to \function{PyUnicode_FromFormat()} except that it takes exactly two arguments. + \versionadded{3.0} \end{cfuncdesc} \begin{cfuncdesc}{Py_UNICODE*}{PyUnicode_AsUnicode}{PyObject *unicode} From python-3000-checkins at python.org Mon Jun 11 19:02:46 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Mon, 11 Jun 2007 19:02:46 +0200 (CEST) Subject: [Python-3000-checkins] r55905 - in python/branches/p3yk: Doc/lib/libfuncs.tex Doc/ref/ref3.tex Include/abstract.h Include/longobject.h Lib/test/output/test_class Lib/test/test_class.py Lib/test/test_format.py Misc/NEWS Objects/abstract.c Objects/intobject.c Objects/longobject.c Objects/stringobject.c Objects/typeobject.c Python/bltinmodule.c Message-ID: <20070611170246.3AB9A1E4002@bag.python.org> Author: georg.brandl Date: Mon Jun 11 19:02:26 2007 New Revision: 55905 Modified: python/branches/p3yk/Doc/lib/libfuncs.tex python/branches/p3yk/Doc/ref/ref3.tex python/branches/p3yk/Include/abstract.h python/branches/p3yk/Include/longobject.h python/branches/p3yk/Lib/test/output/test_class python/branches/p3yk/Lib/test/test_class.py python/branches/p3yk/Lib/test/test_format.py python/branches/p3yk/Misc/NEWS python/branches/p3yk/Objects/abstract.c python/branches/p3yk/Objects/intobject.c python/branches/p3yk/Objects/longobject.c python/branches/p3yk/Objects/stringobject.c python/branches/p3yk/Objects/typeobject.c python/branches/p3yk/Python/bltinmodule.c Log: Remove __oct__ and __hex__ and use __index__ for converting non-ints before formatting in a base. Add a bin() builtin. Modified: python/branches/p3yk/Doc/lib/libfuncs.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libfuncs.tex (original) +++ python/branches/p3yk/Doc/lib/libfuncs.tex Mon Jun 11 19:02:26 2007 @@ -104,6 +104,14 @@ \versionadded{2.3} \end{funcdesc} +\begin{funcdesc}{bin}{x} + Convert an integer number to a binary string. + The result is a valid Python expression. If \var{x} is not a Python + \class{int} object, it has to define an \method{__index__} method + that returns an integer. + \versionadded{3.0} +\end{funcdesc} + \begin{funcdesc}{bool}{\optional{x}} Convert a value to a Boolean, using the standard truth testing procedure. If \var{x} is false or omitted, this returns @@ -540,8 +548,10 @@ \end{funcdesc} \begin{funcdesc}{hex}{x} - Convert an integer number (of any size) to a hexadecimal string. - The result is a valid Python expression. + Convert an integer number to a hexadecimal string. + The result is a valid Python expression. If \var{x} is not a Python + \class{int} object, it has to define an \method{__index__} method + that returns an integer. \versionchanged[Formerly only returned an unsigned literal]{2.4} \end{funcdesc} @@ -707,8 +717,10 @@ \end{funcdesc} \begin{funcdesc}{oct}{x} - Convert an integer number (of any size) to an octal string. The - result is a valid Python expression. + Convert an integer number to an octal string. The + result is a valid Python expression. If \var{x} is not a Python + \class{int} object, it has to define an \method{__index__} method + that returns an integer. \versionchanged[Formerly only returned an unsigned literal]{2.4} \end{funcdesc} Modified: python/branches/p3yk/Doc/ref/ref3.tex ============================================================================== --- python/branches/p3yk/Doc/ref/ref3.tex (original) +++ python/branches/p3yk/Doc/ref/ref3.tex Mon Jun 11 19:02:26 2007 @@ -2033,17 +2033,11 @@ the appropriate type. \end{methoddesc} -\begin{methoddesc}[numeric object]{__oct__}{self} -\methodline[numeric object]{__hex__}{self} -Called to implement the built-in functions -\function{oct()}\bifuncindex{oct} and -\function{hex()}\bifuncindex{hex}. Should return a string value. -\end{methoddesc} - \begin{methoddesc}[numeric object]{__index__}{self} Called to implement \function{operator.index()}. Also called whenever -Python needs an integer object (such as in slicing). Must return an -integer (int or long). +Python needs an integer object (such as in slicing, or in the built-in +\function{bin()}, \function{hex()} and \function{oct()} functions). +Must return an integer (int or long). \versionadded{2.5} \end{methoddesc} Modified: python/branches/p3yk/Include/abstract.h ============================================================================== --- python/branches/p3yk/Include/abstract.h (original) +++ python/branches/p3yk/Include/abstract.h Mon Jun 11 19:02:26 2007 @@ -851,6 +851,14 @@ expression: o1 |= o2. */ + PyAPI_FUNC(PyObject *) PyNumber_ToBase(PyObject *n, int base); + + /* + Returns the integer n converted to a string with a base, with a base + marker of 0b, 0o or 0x prefixed if applicable. + If n is not an int object, it is converted with PyNumber_Index first. + */ + /* Sequence protocol:*/ Modified: python/branches/p3yk/Include/longobject.h ============================================================================== --- python/branches/p3yk/Include/longobject.h (original) +++ python/branches/p3yk/Include/longobject.h Mon Jun 11 19:02:26 2007 @@ -111,6 +111,11 @@ unsigned char* bytes, size_t n, int little_endian, int is_signed); + +/* _PyLong_Format: Convert the long to a string object with given base, + appending a base prefix of 0[box] if base is 2, 8 or 16. */ +PyAPI_FUNC(PyObject *) _PyLong_Format(PyObject *aa, int base); + #ifdef __cplusplus } #endif Modified: python/branches/p3yk/Lib/test/output/test_class ============================================================================== --- python/branches/p3yk/Lib/test/output/test_class (original) +++ python/branches/p3yk/Lib/test/output/test_class Mon Jun 11 19:02:26 2007 @@ -46,8 +46,7 @@ __int__: () __int__: () __float__: () -__oct__: () -__hex__: () +__index__: () __hash__: () __repr__: () __str__: () Modified: python/branches/p3yk/Lib/test/test_class.py ============================================================================== --- python/branches/p3yk/Lib/test/test_class.py (original) +++ python/branches/p3yk/Lib/test/test_class.py Mon Jun 11 19:02:26 2007 @@ -80,18 +80,14 @@ print("__int__:", args) return 1 + def __index__(self, *args): + print("__index__:", args) + return 1 + def __float__(self, *args): print("__float__:", args) return 1.0 - def __oct__(self, *args): - print("__oct__:", args) - return '01' - - def __hex__(self, *args): - print("__hex__:", args) - return '0x1' - def __cmp__(self, *args): print("__cmp__:", args) return 0 @@ -237,7 +233,6 @@ int(testme) float(testme) oct(testme) -hex(testme) # And the rest... @@ -287,8 +282,6 @@ __float__ = __int__ __str__ = __int__ __repr__ = __int__ - __oct__ = __int__ - __hex__ = __int__ def check_exc(stmt, exception): """Raise TestFailed if executing 'stmt' does not raise 'exception' Modified: python/branches/p3yk/Lib/test/test_format.py ============================================================================== --- python/branches/p3yk/Lib/test/test_format.py (original) +++ python/branches/p3yk/Lib/test/test_format.py Mon Jun 11 19:02:26 2007 @@ -233,14 +233,6 @@ test_exc(u'no format', u'1', TypeError, "not all arguments converted during string formatting") -class Foobar(int): - def __oct__(self): - # Returning a non-string should not blow up. - return self + 1 - -test_exc('%o', Foobar(), TypeError, - "expected string or Unicode object, int found") - if maxsize == 2**31-1: # crashes 2.2.1 and earlier: try: Modified: python/branches/p3yk/Misc/NEWS ============================================================================== --- python/branches/p3yk/Misc/NEWS (original) +++ python/branches/p3yk/Misc/NEWS Mon Jun 11 19:02:26 2007 @@ -26,6 +26,9 @@ Core and Builtins ----------------- +- Removed the __oct__ and __hex__ special methods and added a bin() + builtin function. + - PEP 3127: octal literals now start with "0o". Old-style octal literals are invalid. There are binary literals with a prefix of "0b". This also affects int(x, 0). Modified: python/branches/p3yk/Objects/abstract.c ============================================================================== --- python/branches/p3yk/Objects/abstract.c (original) +++ python/branches/p3yk/Objects/abstract.c Mon Jun 11 19:02:26 2007 @@ -971,6 +971,22 @@ return PyFloat_FromString(o); } + +PyObject * +PyNumber_ToBase(PyObject *n, int base) +{ + PyObject *res; + PyObject *index = PyNumber_Index(n); + + if (!index) + return NULL; + assert(PyLong_Check(index)); + res = _PyLong_Format(index, base); + Py_DECREF(index); + return res; +} + + /* Operations on sequences */ int Modified: python/branches/p3yk/Objects/intobject.c ============================================================================== --- python/branches/p3yk/Objects/intobject.c (original) +++ python/branches/p3yk/Objects/intobject.c Mon Jun 11 19:02:26 2007 @@ -922,30 +922,6 @@ } static PyObject * -int_oct(PyIntObject *v) -{ - char buf[100]; - long x = v -> ob_ival; - if (x < 0) - PyOS_snprintf(buf, sizeof(buf), "-0o%lo", -x); - else - PyOS_snprintf(buf, sizeof(buf), "0o%lo", x); - return PyString_FromString(buf); -} - -static PyObject * -int_hex(PyIntObject *v) -{ - char buf[100]; - long x = v -> ob_ival; - if (x < 0) - PyOS_snprintf(buf, sizeof(buf), "-0x%lx", -x); - else - PyOS_snprintf(buf, sizeof(buf), "0x%lx", x); - return PyString_FromString(buf); -} - -static PyObject * int_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds); static PyObject * @@ -1072,8 +1048,8 @@ (unaryfunc)int_int, /*nb_int*/ (unaryfunc)int_long, /*nb_long*/ (unaryfunc)int_float, /*nb_float*/ - (unaryfunc)int_oct, /*nb_oct*/ - (unaryfunc)int_hex, /*nb_hex*/ + 0, /*nb_oct*/ /* not in use */ + 0, /*nb_hex*/ /* not in use */ 0, /*nb_inplace_add*/ 0, /*nb_inplace_subtract*/ 0, /*nb_inplace_multiply*/ Modified: python/branches/p3yk/Objects/longobject.c ============================================================================== --- python/branches/p3yk/Objects/longobject.c (original) +++ python/branches/p3yk/Objects/longobject.c Mon Jun 11 19:02:26 2007 @@ -80,7 +80,6 @@ static PyLongObject *mul1(PyLongObject *, wdigit); static PyLongObject *muladd1(PyLongObject *, wdigit, wdigit); static PyLongObject *divrem1(PyLongObject *, digit, digit *); -static PyObject *long_format(PyObject *aa, int base); #define SIGCHECK(PyTryBlock) \ if (--_Py_Ticker < 0) { \ @@ -1384,7 +1383,7 @@ /* Divide long pin, w/ size digits, by non-zero digit n, storing quotient in pout, and returning the remainder. pin and pout point at the LSD. It's OK for pin == pout on entry, which saves oodles of mallocs/frees in - long_format, but that should be done with great care since longs are + _PyLong_Format, but that should be done with great care since longs are immutable. */ static digit @@ -1426,8 +1425,8 @@ Return a string object. If base is 2, 8 or 16, add the proper prefix '0b', '0o' or '0x'. */ -static PyObject * -long_format(PyObject *aa, int base) +PyObject * +_PyLong_Format(PyObject *aa, int base) { register PyLongObject *a = (PyLongObject *)aa; PyStringObject *str; @@ -2154,7 +2153,7 @@ static PyObject * long_repr(PyObject *v) { - return long_format(v, 10); + return _PyLong_Format(v, 10); } static int @@ -3513,18 +3512,6 @@ } static PyObject * -long_oct(PyObject *v) -{ - return long_format(v, 8); -} - -static PyObject * -long_hex(PyObject *v) -{ - return long_format(v, 16); -} - -static PyObject * long_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds); static PyObject * @@ -3648,8 +3635,8 @@ long_int, /*nb_int*/ long_long, /*nb_long*/ long_float, /*nb_float*/ - long_oct, /*nb_oct*/ - long_hex, /*nb_hex*/ + 0, /*nb_oct*/ /* not used */ + 0, /*nb_hex*/ /* not used */ 0, /* nb_inplace_add */ 0, /* nb_inplace_subtract */ 0, /* nb_inplace_multiply */ Modified: python/branches/p3yk/Objects/stringobject.c ============================================================================== --- python/branches/p3yk/Objects/stringobject.c (original) +++ python/branches/p3yk/Objects/stringobject.c Mon Jun 11 19:02:26 2007 @@ -4255,12 +4255,12 @@ break; case 'o': numnondigits = 2; - result = val->ob_type->tp_as_number->nb_oct(val); + result = PyNumber_ToBase(val, 8); break; case 'x': case 'X': numnondigits = 2; - result = val->ob_type->tp_as_number->nb_hex(val); + result = PyNumber_ToBase(val, 16); break; default: assert(!"'type' not in [duoxX]"); Modified: python/branches/p3yk/Objects/typeobject.c ============================================================================== --- python/branches/p3yk/Objects/typeobject.c (original) +++ python/branches/p3yk/Objects/typeobject.c Mon Jun 11 19:02:26 2007 @@ -3236,8 +3236,6 @@ COPYNUM(nb_int); COPYNUM(nb_long); COPYNUM(nb_float); - COPYNUM(nb_oct); - COPYNUM(nb_hex); COPYNUM(nb_inplace_add); COPYNUM(nb_inplace_subtract); COPYNUM(nb_inplace_multiply); @@ -4556,8 +4554,6 @@ SLOT0(slot_nb_int, "__int__") SLOT0(slot_nb_long, "__long__") SLOT0(slot_nb_float, "__float__") -SLOT0(slot_nb_oct, "__oct__") -SLOT0(slot_nb_hex, "__hex__") SLOT1(slot_nb_inplace_add, "__iadd__", PyObject *, "O") SLOT1(slot_nb_inplace_subtract, "__isub__", PyObject *, "O") SLOT1(slot_nb_inplace_multiply, "__imul__", PyObject *, "O") @@ -5208,10 +5204,6 @@ "long(x)"), UNSLOT("__float__", nb_float, slot_nb_float, wrap_unaryfunc, "float(x)"), - UNSLOT("__oct__", nb_oct, slot_nb_oct, wrap_unaryfunc, - "oct(x)"), - UNSLOT("__hex__", nb_hex, slot_nb_hex, wrap_unaryfunc, - "hex(x)"), NBSLOT("__index__", nb_index, slot_nb_index, wrap_unaryfunc, "x[y:z] <==> x[y.__index__():z.__index__()]"), IBSLOT("__iadd__", nb_inplace_add, slot_nb_inplace_add, Modified: python/branches/p3yk/Python/bltinmodule.c ============================================================================== --- python/branches/p3yk/Python/bltinmodule.c (original) +++ python/branches/p3yk/Python/bltinmodule.c Mon Jun 11 19:02:26 2007 @@ -247,6 +247,18 @@ static PyObject * +builtin_bin(PyObject *self, PyObject *v) +{ + return PyNumber_ToBase(v, 2); +} + +PyDoc_STRVAR(bin_doc, +"bin(number) -> string\n\ +\n\ +Return the binary representation of an integer or long integer."); + + +static PyObject * builtin_filter(PyObject *self, PyObject *args) { PyObject *func, *seq, *result, *it, *arg; @@ -1230,24 +1242,7 @@ static PyObject * builtin_hex(PyObject *self, PyObject *v) { - PyNumberMethods *nb; - PyObject *res; - - if ((nb = v->ob_type->tp_as_number) == NULL || - nb->nb_hex == NULL) { - PyErr_SetString(PyExc_TypeError, - "hex() argument can't be converted to hex"); - return NULL; - } - res = (*nb->nb_hex)(v); - if (res && !PyString_Check(res)) { - PyErr_Format(PyExc_TypeError, - "__hex__ returned non-string (type %.200s)", - res->ob_type->tp_name); - Py_DECREF(res); - return NULL; - } - return res; + return PyNumber_ToBase(v, 16); } PyDoc_STRVAR(hex_doc, @@ -1430,24 +1425,7 @@ static PyObject * builtin_oct(PyObject *self, PyObject *v) { - PyNumberMethods *nb; - PyObject *res; - - if (v == NULL || (nb = v->ob_type->tp_as_number) == NULL || - nb->nb_oct == NULL) { - PyErr_SetString(PyExc_TypeError, - "oct() argument can't be converted to oct"); - return NULL; - } - res = (*nb->nb_oct)(v); - if (res && !PyString_Check(res)) { - PyErr_Format(PyExc_TypeError, - "__oct__ returned non-string (type %.200s)", - res->ob_type->tp_name); - Py_DECREF(res); - return NULL; - } - return res; + return PyNumber_ToBase(v, 8); } PyDoc_STRVAR(oct_doc, @@ -1949,6 +1927,7 @@ {"abs", builtin_abs, METH_O, abs_doc}, {"all", builtin_all, METH_O, all_doc}, {"any", builtin_any, METH_O, any_doc}, + {"bin", builtin_bin, METH_O, bin_doc}, {"chr", builtin_chr, METH_VARARGS, chr_doc}, {"cmp", builtin_cmp, METH_VARARGS, cmp_doc}, {"compile", (PyCFunction)builtin_compile, METH_VARARGS | METH_KEYWORDS, compile_doc}, From python-3000-checkins at python.org Mon Jun 11 19:04:48 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Mon, 11 Jun 2007 19:04:48 +0200 (CEST) Subject: [Python-3000-checkins] r55906 - python/branches/p3yk/Doc/lib/libfuncs.tex Message-ID: <20070611170448.464801E4002@bag.python.org> Author: georg.brandl Date: Mon Jun 11 19:04:44 2007 New Revision: 55906 Modified: python/branches/p3yk/Doc/lib/libfuncs.tex Log: int(x, 0) does not "guess". Modified: python/branches/p3yk/Doc/lib/libfuncs.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libfuncs.tex (original) +++ python/branches/p3yk/Doc/lib/libfuncs.tex Mon Jun 11 19:04:44 2007 @@ -569,8 +569,7 @@ representable as a Python integer, possibly embedded in whitespace. The \var{radix} parameter gives the base for the conversion and may be any integer in the range [2, 36], or zero. If - \var{radix} is zero, the proper radix is guessed based on the - contents of string; the interpretation is the same as for integer + \var{radix} is zero, the interpretation is the same as for integer literals. If \var{radix} is specified and \var{x} is not a string, \exception{TypeError} is raised. Otherwise, the argument may be a plain or From python-3000-checkins at python.org Mon Jun 11 19:05:48 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Mon, 11 Jun 2007 19:05:48 +0200 (CEST) Subject: [Python-3000-checkins] r55907 - python/branches/p3yk/Include/object.h Message-ID: <20070611170548.EE8251E4002@bag.python.org> Author: georg.brandl Date: Mon Jun 11 19:05:47 2007 New Revision: 55907 Modified: python/branches/p3yk/Include/object.h Log: Add a comment to explain that nb_oct and nb_hex are nonfunctional. Modified: python/branches/p3yk/Include/object.h ============================================================================== --- python/branches/p3yk/Include/object.h (original) +++ python/branches/p3yk/Include/object.h Mon Jun 11 19:05:47 2007 @@ -171,6 +171,7 @@ unaryfunc nb_int; unaryfunc nb_long; unaryfunc nb_float; + /* NB: nb_oct and nb_hex are not used anymore. */ unaryfunc nb_oct; unaryfunc nb_hex; From guido at python.org Mon Jun 11 19:31:09 2007 From: guido at python.org (Guido van Rossum) Date: Mon, 11 Jun 2007 10:31:09 -0700 Subject: [Python-3000-checkins] r55871 - in python/branches/p3yk: Doc/lib/libctypes.tex Doc/lib/libthreading.tex Doc/lib/liburllib2.tex Doc/whatsnew/whatsnew26.tex Include/pyport.h Lib/_strptime.py Lib/ctypes/test/test_numbers.py Lib/distutils/command/bui Message-ID: As of this revision, I get a build error on my ubuntu desktop: building '_testcapi' extension gcc -pthread -fPIC -fno-strict-aliasing -g -Wall -Wstrict-prototypes -I. -I/usr/local/google/home/guido/python/py3k/./Include -I./Include -I. -I/usr/local/include -I/usr/local/google/home/guido/python/py3k/Include -I/usr/local/google/home/guido/python/py3k -c /usr/local/google/home/guido/python/py3k/Modules/_testcapimodule.c -o build/temp.linux-i686-3.0/usr/local/google/home/guido/python/py3k/Modules/_testcapimodule.o /usr/local/google/home/guido/python/py3k/Modules/_testcapimodule.c: In function 'print_delta': /usr/local/google/home/guido/python/py3k/Modules/_testcapimodule.c:731: warning: format '%06d' expects type 'int', but argument 4 has type '__suseconds_t' /usr/local/google/home/guido/python/py3k/Modules/_testcapimodule.c: In function 'init_testcapi': /usr/local/google/home/guido/python/py3k/Modules/_testcapimodule.c:1029: error: 'PY_LLONG_MAX' undeclared (first use in this function) /usr/local/google/home/guido/python/py3k/Modules/_testcapimodule.c:1029: error: (Each undeclared identifier is reported only once /usr/local/google/home/guido/python/py3k/Modules/_testcapimodule.c:1029: error: for each function it appears in.) /usr/local/google/home/guido/python/py3k/Modules/_testcapimodule.c:1030: error: 'PY_LLONG_MIN' undeclared (first use in this function) /usr/local/google/home/guido/python/py3k/Modules/_testcapimodule.c:1031: error: 'PY_ULLONG_MAX' undeclared (first use in this function) On 6/10/07, neal.norwitz wrote: > Author: neal.norwitz > Date: Mon Jun 11 03:31:49 2007 > New Revision: 55871 > > Added: > python/branches/p3yk/Lib/test/test_urllib2_localnet.py > - copied, changed from r55860, python/trunk/Lib/test/test_urllib2_localnet.py > python/branches/p3yk/Tools/buildbot/build-amd64.bat > - copied unchanged from r55860, python/trunk/Tools/buildbot/build-amd64.bat > python/branches/p3yk/Tools/buildbot/clean-amd64.bat > - copied unchanged from r55860, python/trunk/Tools/buildbot/clean-amd64.bat > python/branches/p3yk/Tools/buildbot/test-amd64.bat > - copied unchanged from r55860, python/trunk/Tools/buildbot/test-amd64.bat > Modified: > python/branches/p3yk/ (props changed) > python/branches/p3yk/Doc/lib/libctypes.tex > python/branches/p3yk/Doc/lib/libthreading.tex > python/branches/p3yk/Doc/lib/liburllib2.tex > python/branches/p3yk/Doc/whatsnew/whatsnew26.tex > python/branches/p3yk/Include/pyport.h > python/branches/p3yk/Lib/_strptime.py > python/branches/p3yk/Lib/ctypes/test/test_numbers.py > python/branches/p3yk/Lib/distutils/command/build_py.py > python/branches/p3yk/Lib/distutils/tests/test_build_py.py > python/branches/p3yk/Lib/ftplib.py > python/branches/p3yk/Lib/test/test_compile.py > python/branches/p3yk/Lib/test/test_multibytecodec.py > python/branches/p3yk/Lib/test/test_str.py > python/branches/p3yk/Lib/test/test_strptime.py > python/branches/p3yk/Lib/test/test_structmembers.py > python/branches/p3yk/Lib/test/test_threading.py > python/branches/p3yk/Lib/test/test_unicode.py > python/branches/p3yk/Lib/test/test_urllib2.py > python/branches/p3yk/Lib/test/test_urllib2net.py > python/branches/p3yk/Lib/threading.py > python/branches/p3yk/Lib/urllib2.py > python/branches/p3yk/Misc/ACKS > python/branches/p3yk/Modules/_bsddb.c > python/branches/p3yk/Modules/_ctypes/_ctypes.c > python/branches/p3yk/Modules/_ctypes/callbacks.c > python/branches/p3yk/Modules/_ctypes/callproc.c > python/branches/p3yk/Modules/_ctypes/cfield.c > python/branches/p3yk/Modules/_ctypes/ctypes.h > python/branches/p3yk/Modules/_ctypes/libffi/src/x86/ffi.c > python/branches/p3yk/Modules/_ctypes/libffi/src/x86/ffi64.c > python/branches/p3yk/Modules/_ctypes/stgdict.c > python/branches/p3yk/Modules/_sqlite/cache.c > python/branches/p3yk/Modules/_testcapimodule.c > python/branches/p3yk/Modules/cjkcodecs/multibytecodec.c > python/branches/p3yk/Modules/getbuildinfo.c > python/branches/p3yk/Modules/socketmodule.c > python/branches/p3yk/Objects/bufferobject.c > python/branches/p3yk/Objects/stringobject.c > python/branches/p3yk/Objects/unicodeobject.c > python/branches/p3yk/PC/pyconfig.h > python/branches/p3yk/PCbuild/pcbuild.sln > python/branches/p3yk/Python/ast.c > python/branches/p3yk/Python/compile.c > python/branches/p3yk/Python/peephole.c > python/branches/p3yk/Python/structmember.c > python/branches/p3yk/README > python/branches/p3yk/Tools/scripts/reindent.py (props changed) > python/branches/p3yk/configure > python/branches/p3yk/configure.in > Log: > Merged revisions 55729-55868 via svnmerge from > svn+ssh://pythondev at svn.python.org/python/trunk > > ........ -- --Guido van Rossum (home page: http://www.python.org/~guido/) From nnorwitz at gmail.com Mon Jun 11 19:43:48 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Mon, 11 Jun 2007 10:43:48 -0700 Subject: [Python-3000-checkins] r55871 - in python/branches/p3yk: Doc/lib/libctypes.tex Doc/lib/libthreading.tex Doc/lib/liburllib2.tex Doc/whatsnew/whatsnew26.tex Include/pyport.h Lib/_strptime.py Lib/ctypes/test/test_numbers.py Lib/distutils/command/bui In-Reply-To: References: Message-ID: This was due to a patch Martin applied for T_LONGLONG for structmember (or something like that). He said he would fix it soon. The same problem occurs on the trunk. n -- On 6/11/07, Guido van Rossum wrote: > As of this revision, I get a build error on my ubuntu desktop: > > building '_testcapi' extension > gcc -pthread -fPIC -fno-strict-aliasing -g -Wall -Wstrict-prototypes > -I. -I/usr/local/google/home/guido/python/py3k/./Include -I./Include > -I. -I/usr/local/include > -I/usr/local/google/home/guido/python/py3k/Include > -I/usr/local/google/home/guido/python/py3k -c > /usr/local/google/home/guido/python/py3k/Modules/_testcapimodule.c -o > build/temp.linux-i686-3.0/usr/local/google/home/guido/python/py3k/Modules/_testcapimodule.o > /usr/local/google/home/guido/python/py3k/Modules/_testcapimodule.c: In > function 'print_delta': > /usr/local/google/home/guido/python/py3k/Modules/_testcapimodule.c:731: > warning: format '%06d' expects type 'int', but argument 4 has type > '__suseconds_t' > /usr/local/google/home/guido/python/py3k/Modules/_testcapimodule.c: In > function 'init_testcapi': > /usr/local/google/home/guido/python/py3k/Modules/_testcapimodule.c:1029: > error: 'PY_LLONG_MAX' undeclared (first use in this function) > /usr/local/google/home/guido/python/py3k/Modules/_testcapimodule.c:1029: > error: (Each undeclared identifier is reported only once > /usr/local/google/home/guido/python/py3k/Modules/_testcapimodule.c:1029: > error: for each function it appears in.) > /usr/local/google/home/guido/python/py3k/Modules/_testcapimodule.c:1030: > error: 'PY_LLONG_MIN' undeclared (first use in this function) > /usr/local/google/home/guido/python/py3k/Modules/_testcapimodule.c:1031: > error: 'PY_ULLONG_MAX' undeclared (first use in this function) > > > On 6/10/07, neal.norwitz wrote: > > Author: neal.norwitz > > Date: Mon Jun 11 03:31:49 2007 > > New Revision: 55871 > > > > Added: > > python/branches/p3yk/Lib/test/test_urllib2_localnet.py > > - copied, changed from r55860, python/trunk/Lib/test/test_urllib2_localnet.py > > python/branches/p3yk/Tools/buildbot/build-amd64.bat > > - copied unchanged from r55860, python/trunk/Tools/buildbot/build-amd64.bat > > python/branches/p3yk/Tools/buildbot/clean-amd64.bat > > - copied unchanged from r55860, python/trunk/Tools/buildbot/clean-amd64.bat > > python/branches/p3yk/Tools/buildbot/test-amd64.bat > > - copied unchanged from r55860, python/trunk/Tools/buildbot/test-amd64.bat > > Modified: > > python/branches/p3yk/ (props changed) > > python/branches/p3yk/Doc/lib/libctypes.tex > > python/branches/p3yk/Doc/lib/libthreading.tex > > python/branches/p3yk/Doc/lib/liburllib2.tex > > python/branches/p3yk/Doc/whatsnew/whatsnew26.tex > > python/branches/p3yk/Include/pyport.h > > python/branches/p3yk/Lib/_strptime.py > > python/branches/p3yk/Lib/ctypes/test/test_numbers.py > > python/branches/p3yk/Lib/distutils/command/build_py.py > > python/branches/p3yk/Lib/distutils/tests/test_build_py.py > > python/branches/p3yk/Lib/ftplib.py > > python/branches/p3yk/Lib/test/test_compile.py > > python/branches/p3yk/Lib/test/test_multibytecodec.py > > python/branches/p3yk/Lib/test/test_str.py > > python/branches/p3yk/Lib/test/test_strptime.py > > python/branches/p3yk/Lib/test/test_structmembers.py > > python/branches/p3yk/Lib/test/test_threading.py > > python/branches/p3yk/Lib/test/test_unicode.py > > python/branches/p3yk/Lib/test/test_urllib2.py > > python/branches/p3yk/Lib/test/test_urllib2net.py > > python/branches/p3yk/Lib/threading.py > > python/branches/p3yk/Lib/urllib2.py > > python/branches/p3yk/Misc/ACKS > > python/branches/p3yk/Modules/_bsddb.c > > python/branches/p3yk/Modules/_ctypes/_ctypes.c > > python/branches/p3yk/Modules/_ctypes/callbacks.c > > python/branches/p3yk/Modules/_ctypes/callproc.c > > python/branches/p3yk/Modules/_ctypes/cfield.c > > python/branches/p3yk/Modules/_ctypes/ctypes.h > > python/branches/p3yk/Modules/_ctypes/libffi/src/x86/ffi.c > > python/branches/p3yk/Modules/_ctypes/libffi/src/x86/ffi64.c > > python/branches/p3yk/Modules/_ctypes/stgdict.c > > python/branches/p3yk/Modules/_sqlite/cache.c > > python/branches/p3yk/Modules/_testcapimodule.c > > python/branches/p3yk/Modules/cjkcodecs/multibytecodec.c > > python/branches/p3yk/Modules/getbuildinfo.c > > python/branches/p3yk/Modules/socketmodule.c > > python/branches/p3yk/Objects/bufferobject.c > > python/branches/p3yk/Objects/stringobject.c > > python/branches/p3yk/Objects/unicodeobject.c > > python/branches/p3yk/PC/pyconfig.h > > python/branches/p3yk/PCbuild/pcbuild.sln > > python/branches/p3yk/Python/ast.c > > python/branches/p3yk/Python/compile.c > > python/branches/p3yk/Python/peephole.c > > python/branches/p3yk/Python/structmember.c > > python/branches/p3yk/README > > python/branches/p3yk/Tools/scripts/reindent.py (props changed) > > python/branches/p3yk/configure > > python/branches/p3yk/configure.in > > Log: > > Merged revisions 55729-55868 via svnmerge from > > svn+ssh://pythondev at svn.python.org/python/trunk > > > > ........ > > -- > --Guido van Rossum (home page: http://www.python.org/~guido/) > _______________________________________________ > 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 Mon Jun 11 19:49:22 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Mon, 11 Jun 2007 19:49:22 +0200 (CEST) Subject: [Python-3000-checkins] r55908 - python/branches/p3yk/Lib/abc.py Message-ID: <20070611174922.B8DC91E4002@bag.python.org> Author: guido.van.rossum Date: Mon Jun 11 19:49:18 2007 New Revision: 55908 Modified: python/branches/p3yk/Lib/abc.py Log: Get rid of unused imports and comment. Modified: python/branches/p3yk/Lib/abc.py ============================================================================== --- python/branches/p3yk/Lib/abc.py (original) +++ python/branches/p3yk/Lib/abc.py Mon Jun 11 19:49:18 2007 @@ -3,13 +3,6 @@ """Abstract Base Classes (ABCs) according to PEP 3119.""" -import sys -import inspect -import itertools - - -### ABC SUPPORT FRAMEWORK ### - def abstractmethod(funcobj): """A decorator indicating abstract methods. @@ -129,8 +122,6 @@ def _dump_registry(cls, file=None): """Debug helper to print the ABC registry.""" - if file is None: - file = sys.stdout print("Class: %s.%s" % (cls.__module__, cls.__name__), file=file) print("Inv.counter: %s" % ABCMeta.__invalidation_counter, file=file) for name in sorted(cls.__dict__.keys()): From python-3000-checkins at python.org Mon Jun 11 22:05:21 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Mon, 11 Jun 2007 22:05:21 +0200 (CEST) Subject: [Python-3000-checkins] r55910 - python/branches/p3yk/Lib/abc.py Message-ID: <20070611200521.541451E4002@bag.python.org> Author: guido.van.rossum Date: Mon Jun 11 22:05:17 2007 New Revision: 55910 Modified: python/branches/p3yk/Lib/abc.py Log: _Abstract.__new__ now requires either no arguments or __init__ overridden. Modified: python/branches/p3yk/Lib/abc.py ============================================================================== --- python/branches/p3yk/Lib/abc.py (original) +++ python/branches/p3yk/Lib/abc.py Mon Jun 11 22:05:17 2007 @@ -29,15 +29,20 @@ """Helper class inserted into the bases by ABCMeta (using _fix_bases()). You should never need to explicitly subclass this class. + + There should never be a base class between _Abstract and object. """ def __new__(cls, *args, **kwds): am = cls.__dict__.get("__abstractmethods__") if am: - raise TypeError("can't instantiate abstract class %s " + raise TypeError("Can't instantiate abstract class %s " "with abstract methods %s" % (cls.__name__, ", ".join(sorted(am)))) - return super(_Abstract, cls).__new__(cls, *args, **kwds) + if (args or kwds) and cls.__init__ is object.__init__: + raise TypeError("Can't pass arguments to __new__ " + "without overriding __init__") + return object.__new__(cls) @classmethod def __subclasshook__(cls, subclass): From python-3000-checkins at python.org Mon Jun 11 22:07:58 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Mon, 11 Jun 2007 22:07:58 +0200 (CEST) Subject: [Python-3000-checkins] r55911 - in python/branches/p3yk/Lib: _abcoll.py collections.py test/test_collections.py Message-ID: <20070611200758.87CB01E4002@bag.python.org> Author: guido.van.rossum Date: Mon Jun 11 22:07:49 2007 New Revision: 55911 Added: python/branches/p3yk/Lib/_abcoll.py (contents, props changed) Modified: python/branches/p3yk/Lib/collections.py python/branches/p3yk/Lib/test/test_collections.py Log: Move the collections ABCs to a separate file, _abcoll.py, in order to avoid needing to import _collections.so during the bootstrap (this will become apparent in the next submit of os.py). Add (plain and mutable) ABCs for Set, Mapping, Sequence. Added: python/branches/p3yk/Lib/_abcoll.py ============================================================================== --- (empty file) +++ python/branches/p3yk/Lib/_abcoll.py Mon Jun 11 22:07:49 2007 @@ -0,0 +1,535 @@ +# Copyright 2007 Google, Inc. All Rights Reserved. +# Licensed to PSF under a Contributor Agreement. + +"""Abstract Base Classes (ABCs) for collections, according to PEP 3119. + +DON'T USE THIS MODULE DIRECTLY! The classes here should be imported +via collections; they are defined here only to alleviate ceratin +bootstrapping issues. Unit tests are in test_collections. +""" + +from abc import ABCMeta, abstractmethod + +__all__ = ["Hashable", "Iterable", "Iterator", + "Sized", "Container", "Callable", + "Set", "MutableSet", + "Mapping", "MutableMapping", + "MappingView", "KeysView", "ItemsView", "ValuesView", + "Sequence", "MutableSequence", + ] + +### ONE-TRICK PONIES ### + +class Hashable(metaclass=ABCMeta): + + @abstractmethod + def __hash__(self): + return 0 + + @classmethod + def __subclasshook__(cls, C): + if cls is Hashable: + for B in C.__mro__: + if "__hash__" in B.__dict__: + if B.__dict__["__hash__"]: + return True + break + return NotImplemented + + +class Iterable(metaclass=ABCMeta): + + @abstractmethod + def __iter__(self): + while False: + yield None + + @classmethod + def __subclasshook__(cls, C): + if cls is Iterable: + if any("__iter__" in B.__dict__ for B in C.__mro__): + return True + return NotImplemented + +Iterable.register(bytes) + + +class Iterator(metaclass=ABCMeta): + + @abstractmethod + def __next__(self): + raise StopIteration + + def __iter__(self): + return self + + @classmethod + def __subclasshook__(cls, C): + if cls is Iterator: + if any("__next__" in B.__dict__ for B in C.__mro__): + return True + return NotImplemented + + +class Sized(metaclass=ABCMeta): + + @abstractmethod + def __len__(self): + return 0 + + @classmethod + def __subclasshook__(cls, C): + if cls is Sized: + if any("__len__" in B.__dict__ for B in C.__mro__): + return True + return NotImplemented + + +class Container(metaclass=ABCMeta): + + @abstractmethod + def __contains__(self, x): + return False + + @classmethod + def __subclasshook__(cls, C): + if cls is Container: + if any("__contains__" in B.__dict__ for B in C.__mro__): + return True + return NotImplemented + + +class Callable(metaclass=ABCMeta): + + @abstractmethod + def __contains__(self, x): + return False + + @classmethod + def __subclasshook__(cls, C): + if cls is Callable: + if any("__call__" in B.__dict__ for B in C.__mro__): + return True + return NotImplemented + + +### SETS ### + + +class Set(metaclass=ABCMeta): + + """A set is a finite, iterable container. + + This class provides concrete generic implementations of all + methods except for __contains__, __iter__ and __len__. + + To override the comparisons (presumably for speed, as the + semantics are fixed), all you have to do is redefine __le__ and + then the other operations will automatically follow suit. + """ + + @abstractmethod + def __contains__(self, value): + return False + + @abstractmethod + def __iter__(self): + while False: + yield None + + @abstractmethod + def __len__(self): + return 0 + + def __le__(self, other): + if not isinstance(other, Set): + return NotImplemented + if len(self) > len(other): + return False + for elem in self: + if elem not in other: + return False + return True + + def __lt__(self, other): + if not isinstance(other, Set): + return NotImplemented + return len(self) < len(other) and self.__le__(other) + + def __eq__(self, other): + if not isinstance(other, Set): + return NotImplemented + return len(self) == len(other) and self.__le__(other) + + @classmethod + def _from_iterable(cls, it): + return frozenset(it) + + def __and__(self, other): + if not isinstance(other, Iterable): + return NotImplemented + return self._from_iterable(value for value in other if value in self) + + def __or__(self, other): + if not isinstance(other, Iterable): + return NotImplemented + return self._from_iterable(itertools.chain(self, other)) + + def __sub__(self, other): + if not isinstance(other, Set): + if not isinstance(other, Iterable): + return NotImplemented + other = self._from_iterable(other) + return self._from_iterable(value for value in self + if value not in other) + + def __xor__(self, other): + if not isinstance(other, Set): + if not isinstance(other, Iterable): + return NotImplemented + other = self._from_iterable(other) + return (self - other) | (other - self) + + def _hash(self): + """Compute the hash value of a set. + + Note that we don't define __hash__: not all sets are hashable. + But if you define a hashable set type, its __hash__ should + call this function. + + This must be compatible __eq__. + + All sets ought to compare equal if they contain the same + elements, regardless of how they are implemented, and + regardless of the order of the elements; so there's not much + freedom for __eq__ or __hash__. We match the algorithm used + by the built-in frozenset type. + """ + MAX = sys.maxint + MASK = 2 * MAX + 1 + n = len(self) + h = 1927868237 * (n + 1) + h &= MASK + for x in self: + hx = hash(x) + h ^= (hx ^ (hx << 16) ^ 89869747) * 3644798167 + h &= MASK + h = h * 69069 + 907133923 + h &= MASK + if h > MAX: + h -= MASK + 1 + if h == -1: + h = 590923713 + return h + +Set.register(frozenset) + + +class MutableSet(Set): + + @abstractmethod + def add(self, value): + """Return True if it was added, False if already there.""" + raise NotImplementedError + + @abstractmethod + def discard(self, value): + """Return True if it was deleted, False if not there.""" + raise NotImplementedError + + def pop(self): + """Return the popped value. Raise KeyError if empty.""" + it = iter(self) + try: + value = it.__next__() + except StopIteration: + raise KeyError + self.discard(value) + return value + + def toggle(self, value): + """Return True if it was added, False if deleted.""" + # XXX This implementation is not thread-safe + if value in self: + self.discard(value) + return False + else: + self.add(value) + return True + + def clear(self): + """This is slow (creates N new iterators!) but effective.""" + try: + while True: + self.pop() + except KeyError: + pass + + def __ior__(self, it: Iterable): + for value in it: + self.add(value) + return self + + def __iand__(self, c: Container): + for value in self: + if value not in c: + self.discard(value) + return self + + def __ixor__(self, it: Iterable): + # This calls toggle(), so if that is overridded, we call the override + for value in it: + self.toggle(it) + return self + + def __isub__(self, it: Iterable): + for value in it: + self.discard(value) + return self + +MutableSet.register(set) + + +### MAPPINGS ### + + +class Mapping(metaclass=ABCMeta): + + @abstractmethod + def __getitem__(self, key): + raise KeyError + + def get(self, key, default=None): + try: + return self[key] + except KeyError: + return default + + def __contains__(self, key): + try: + self[key] + except KeyError: + return False + else: + return True + + @abstractmethod + def __len__(self): + return 0 + + @abstractmethod + def __iter__(self): + while False: + yield None + + def keys(self): + return KeysView(self) + + def items(self): + return ItemsView(self) + + def values(self): + return ValuesView(self) + + +class MappingView(metaclass=ABCMeta): + + def __init__(self, mapping): + self._mapping = mapping + + def __len__(self): + return len(self._mapping) + + +class KeysView(MappingView, Set): + + def __contains__(self, key): + return key in self._mapping + + def __iter__(self): + for key in self._mapping: + yield key + +KeysView.register(type({}.keys())) + + +class ItemsView(MappingView, Set): + + def __contains__(self, item): + key, value = item + try: + v = self._mapping[key] + except KeyError: + return False + else: + return v == value + + def __iter__(self): + for key in self._mapping: + yield (key, self._mapping[key]) + +ItemsView.register(type({}.items())) + + +class ValuesView(MappingView): + + def __contains__(self, value): + for key in self._mapping: + if value == self._mapping[key]: + return True + return False + + def __iter__(self): + for key in self._mapping: + yield self._mapping[key] + +ValuesView.register(type({}.values())) + + +class MutableMapping(Mapping): + + @abstractmethod + def __setitem__(self, key, value): + raise KeyError + + @abstractmethod + def __delitem__(self, key): + raise KeyError + + __marker = object() + + def pop(self, key, default=__marker): + try: + value = self[key] + except KeyError: + if default is self.__marker: + raise + return default + else: + del self[key] + return value + + def popitem(self): + try: + key = next(iter(self)) + except StopIteration: + raise KeyError + value = self[key] + del self[key] + return key, value + + def clear(self): + try: + while True: + self.popitem() + except KeyError: + pass + + def update(self, other=(), **kwds): + if isinstance(other, Mapping): + for key in other: + self[key] = other[key] + elif hasattr(other, "keys"): + for key in other.keys(): + self[key] = other[key] + else: + for key, value in other: + self[key] = value + for key, value in kwds.items(): + self[key] = value + +MutableMapping.register(dict) + + +### SEQUENCES ### + + +class Sequence(metaclass=ABCMeta): + + """All the operations on a read-only sequence. + + Concrete subclasses must override __new__ or __init__, + __getitem__, and __len__. + """ + + @abstractmethod + def __getitem__(self, index): + raise IndexError + + @abstractmethod + def __len__(self): + return 0 + + def __iter__(self): + i = 0 + while True: + try: + v = self[i] + except IndexError: + break + yield v + i += 1 + + def __contains__(self, value): + for v in self: + if v == value: + return True + return False + + def __reversed__(self): + for i in reversed(range(len(self))): + yield self[i] + + def index(self, value): + for i, v in enumerate(self): + if v == value: + return i + raise ValueError + + def count(self, value): + return sum(1 for v in self if v == value) + +Sequence.register(tuple) +Sequence.register(basestring) +Sequence.register(buffer) + + +class MutableSequence(Sequence): + + @abstractmethod + def __setitem__(self, index, value): + raise IndexError + + @abstractmethod + def __delitem__(self, index): + raise IndexError + + @abstractmethod + def insert(self, index, value): + raise IndexError + + def append(self, value): + self.insert(len(self), value) + + def reverse(self): + n = len(self) + for i in range(n//2): + self[i], self[n-i-1] = self[n-i-1], self[i] + + def extend(self, values): + for v in values: + self.append(v) + + def pop(self, index=-1): + v = self[index] + del self[index] + return v + + def remove(self, value): + del self[self.index(value)] + + def __iadd__(self, values): + self.extend(values) + +MutableSequence.register(list) +MutableSequence.register(bytes) Modified: python/branches/p3yk/Lib/collections.py ============================================================================== --- python/branches/p3yk/Lib/collections.py (original) +++ python/branches/p3yk/Lib/collections.py Mon Jun 11 22:07:49 2007 @@ -1,13 +1,14 @@ -__all__ = ['deque', 'defaultdict', 'NamedTuple', - 'Hashable', 'Iterable', 'Iterator', 'Sized', 'Container', - 'Sequence', 'Set', 'Mapping', - 'MutableSequence', 'MutableSet', 'MutableMapping', - ] +__all__ = ['deque', 'defaultdict', 'NamedTuple'] from _collections import deque, defaultdict from operator import itemgetter as _itemgetter import sys as _sys -from abc import abstractmethod as _abstractmethod, ABCMeta as _ABCMeta + +# 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__ def NamedTuple(typename, s): @@ -52,91 +53,7 @@ return result -class _OneTrickPony(metaclass=_ABCMeta): - - """Helper class for Hashable and friends.""" - - @_abstractmethod - def __subclasshook__(self, subclass): - return NotImplemented - - -class Hashable(_OneTrickPony): - - @_abstractmethod - def __hash__(self): - return 0 - - @classmethod - def __subclasshook__(cls, C): - if cls is Hashable: - for B in C.__mro__: - if "__hash__" in B.__dict__: - if B.__dict__["__hash__"]: - return True - break - return NotImplemented - - -class Iterable(_OneTrickPony): - - @_abstractmethod - def __iter__(self): - while False: - yield None - - @classmethod - def __subclasshook__(cls, C): - if cls is Iterable: - if any("__iter__" in B.__dict__ or "__getitem__" in B.__dict__ - for B in C.__mro__): - return True - return NotImplemented - - -class Iterator(_OneTrickPony): - - @_abstractmethod - def __next__(self): - raise StopIteration - - def __iter__(self): - return self - - @classmethod - def __subclasshook__(cls, C): - if cls is Iterator: - if any("__next__" in B.__dict__ for B in C.__mro__): - return True - return NotImplemented - - -class Sized(_OneTrickPony): - - @_abstractmethod - def __len__(self): - return 0 - - @classmethod - def __subclasshook__(cls, C): - if cls is Sized: - if any("__len__" in B.__dict__ for B in C.__mro__): - return True - return NotImplemented - - -class Container(_OneTrickPony): - - @_abstractmethod - def __contains__(self, x): - return False - @classmethod - def __subclasshook__(cls, C): - if cls is Container: - if any("__contains__" in B.__dict__ for B in C.__mro__): - return True - return NotImplemented if __name__ == '__main__': Modified: python/branches/p3yk/Lib/test/test_collections.py ============================================================================== --- python/branches/p3yk/Lib/test/test_collections.py (original) +++ python/branches/p3yk/Lib/test/test_collections.py Mon Jun 11 22:07:49 2007 @@ -3,7 +3,11 @@ import unittest from test import test_support from collections import NamedTuple -from collections import Hashable, Iterable, Iterator, Sized, Container +from collections import Hashable, Iterable, Iterator +from collections import Sized, Container, Callable +from collections import Set, MutableSet +from collections import Mapping, MutableMapping +from collections import Sequence, MutableSequence class TestNamedTuple(unittest.TestCase): @@ -55,7 +59,7 @@ self.assertRaises(AttributeError, eval, 'p.z', locals()) -class TestABCs(unittest.TestCase): +class TestOneTrickPonyABCs(unittest.TestCase): def test_Hashable(self): # Check some non-hashables @@ -80,12 +84,6 @@ return super(H, self).__hash__() self.assertEqual(hash(H()), 0) self.failIf(issubclass(int, H)) - # Check registration - class C: - __hash__ = None - self.failIf(issubclass(C, Hashable)) - Hashable.register(C) - self.failUnless(issubclass(C, Hashable)) def test_Iterable(self): # Check some non-iterables @@ -109,12 +107,6 @@ return super(I, self).__iter__() self.assertEqual(list(I()), []) self.failIf(issubclass(str, I)) - # Check registration - class C: - pass - self.failIf(issubclass(C, Iterable)) - Iterable.register(C) - self.failUnless(issubclass(C, Iterable)) def test_Iterator(self): non_samples = [None, 42, 3.14, 1j, b"", "", u"", (), [], {}, set()] @@ -165,10 +157,86 @@ self.failUnless(isinstance(x, Container), repr(x)) self.failUnless(issubclass(type(x), Container), repr(type(x))) + def test_Callable(self): + non_samples = [None, 42, 3.14, 1j, + "", b"", (), [], {}, set(), + (lambda: (yield))(), + (x for x in []), + ] + for x in non_samples: + self.failIf(isinstance(x, Callable), repr(x)) + self.failIf(issubclass(type(x), Callable), repr(type(x))) + samples = [lambda: None, + type, int, object, + len, + list.append, [].append, + ] + for x in samples: + self.failUnless(isinstance(x, Callable), repr(x)) + self.failUnless(issubclass(type(x), Callable), repr(type(x))) + + def test_direct_subclassing(self): + for B in Hashable, Iterable, Iterator, Sized, Container, Callable: + class C(B): + pass + self.failUnless(issubclass(C, B)) + self.failIf(issubclass(int, C)) + + def test_registration(self): + for B in Hashable, Iterable, Iterator, Sized, Container, Callable: + class C: + __hash__ = None # Make sure it isn't hashable by default + self.failIf(issubclass(C, B), B.__name__) + B.register(C) + self.failUnless(issubclass(C, B)) + + +class TestCollectionABCs(unittest.TestCase): + + # XXX For now, we only test some virtual inheritance properties. + # We should also test the proper behavior of the collection ABCs + # as real base classes or mix-in classes. + + def test_Set(self): + for sample in [set, frozenset]: + self.failUnless(isinstance(sample(), Set)) + self.failUnless(issubclass(sample, Set)) + + def test_MutableSet(self): + self.failUnless(isinstance(set(), MutableSet)) + self.failUnless(issubclass(set, MutableSet)) + self.failIf(isinstance(frozenset(), MutableSet)) + self.failIf(issubclass(frozenset, MutableSet)) + + def test_Mapping(self): + for sample in [dict]: + self.failUnless(isinstance(sample(), Mapping)) + self.failUnless(issubclass(sample, Mapping)) + + def test_MutableMapping(self): + for sample in [dict]: + self.failUnless(isinstance(sample(), MutableMapping)) + self.failUnless(issubclass(sample, MutableMapping)) + + def test_Sequence(self): + for sample in [tuple, list, bytes, str]: + self.failUnless(isinstance(sample(), Sequence)) + self.failUnless(issubclass(sample, Sequence)) + self.failUnless(issubclass(basestring, Sequence)) + + def test_MutableSequence(self): + for sample in [tuple, str]: + self.failIf(isinstance(sample(), MutableSequence)) + self.failIf(issubclass(sample, MutableSequence)) + for sample in [list, bytes]: + self.failUnless(isinstance(sample(), MutableSequence)) + self.failUnless(issubclass(sample, MutableSequence)) + self.failIf(issubclass(basestring, MutableSequence)) + def test_main(verbose=None): import collections as CollectionsModule - test_classes = [TestNamedTuple, TestABCs] + test_classes = [TestNamedTuple, TestOneTrickPonyABCs, TestCollectionABCs] test_support.run_unittest(*test_classes) test_support.run_doctest(CollectionsModule, verbose) From python-3000-checkins at python.org Mon Jun 11 22:09:32 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Mon, 11 Jun 2007 22:09:32 +0200 (CEST) Subject: [Python-3000-checkins] r55912 - python/branches/p3yk/Lib/os.py Message-ID: <20070611200932.82B291E4009@bag.python.org> Author: guido.van.rossum Date: Mon Jun 11 22:09:31 2007 New Revision: 55912 Modified: python/branches/p3yk/Lib/os.py Log: Rewrite the _Environ class to use the new collections ABCs. Modified: python/branches/p3yk/Lib/os.py ============================================================================== --- python/branches/p3yk/Lib/os.py (original) +++ python/branches/p3yk/Lib/os.py Mon Jun 11 22:09:31 2007 @@ -405,108 +405,63 @@ raise error, saved_exc, saved_tb raise error, last_exc, tb -# Change environ to automatically call putenv() if it exists -try: - # This will fail if there's no putenv - putenv -except NameError: - pass + +if name == "riscos": + # On RISC OS, all env access goes through getenv and putenv + from riscosenviron import _Environ else: - import UserDict + # Change environ to automatically call putenv(), unsetenv if they exist. + from _abcoll import MutableMapping # Can't use collections (bootstrap) - # Fake unsetenv() for Windows - # not sure about os2 here but - # I'm guessing they are the same. - - if name in ('os2', 'nt'): - def unsetenv(key): - putenv(key, "") - - if name == "riscos": - # On RISC OS, all env access goes through getenv and putenv - from riscosenviron import _Environ - elif name in ('os2', 'nt'): # Where Env Var Names Must Be UPPERCASE - # But we store them as upper case - class _Environ(UserDict.IterableUserDict): - def __init__(self, environ): - UserDict.UserDict.__init__(self) - data = self.data - for k, v in environ.items(): - data[k.upper()] = v - def __setitem__(self, key, item): - putenv(key, item) - self.data[key.upper()] = item - def __getitem__(self, key): - return self.data[key.upper()] - try: - unsetenv - except NameError: - def __delitem__(self, key): - del self.data[key.upper()] - else: - def __delitem__(self, key): - unsetenv(key) - del self.data[key.upper()] - def __contains__(self, key): - return key.upper() in self.data - def get(self, key, failobj=None): - return self.data.get(key.upper(), failobj) - def update(self, dict=None, **kwargs): - if dict: - try: - keys = dict.keys() - except AttributeError: - # List of (key, value) - for k, v in dict: - self[k] = v - else: - # got keys - # cannot use items(), since mappings - # may not have them. - for k in keys: - self[k] = dict[k] - if kwargs: - self.update(kwargs) - def copy(self): - return dict(self) + class _Environ(MutableMapping): + def __init__(self, environ, keymap, putenv, unsetenv): + self.keymap = keymap + self.putenv = putenv + self.unsetenv = unsetenv + self.data = data = {} + for key, value in environ.items(): + data[keymap(key)] = value + def __getitem__(self, key): + return self.data[self.keymap(key)] + def __setitem__(self, key, item): + self.putenv(key, item) + self.data[self.keymap(key)] = item + def __delitem__(self, key): + self.unsetenv(key) + del self.data[self.keymap(key)] + def __iter__(self): + for key in self.data: + yield key + def __len__(self): + return len(self.data) + def copy(self): + return dict(self) + def setdefault(self, key, value): + if key not in self: + self[key] = value + return self[key] + try: + _putenv = putenv + except NameError: + _putenv = lambda key, value: None + else: + __all__.append("putenv") + + try: + _unsetenv = unsetenv + except NameError: + _unsetenv = lambda key: _putenv(key, "") + else: + __all__.append("unsetenv") + + if name in ('os2', 'nt'): # Where Env Var Names Must Be UPPERCASE + _keymap = lambda key: key.upper() else: # Where Env Var Names Can Be Mixed Case - class _Environ(UserDict.IterableUserDict): - def __init__(self, environ): - UserDict.UserDict.__init__(self) - self.data = environ - def __setitem__(self, key, item): - putenv(key, item) - self.data[key] = item - def update(self, dict=None, **kwargs): - if dict: - try: - keys = dict.keys() - except AttributeError: - # List of (key, value) - for k, v in dict: - self[k] = v - else: - # got keys - # cannot use items(), since mappings - # may not have them. - for k in keys: - self[k] = dict[k] - if kwargs: - self.update(kwargs) - try: - unsetenv - except NameError: - pass - else: - def __delitem__(self, key): - unsetenv(key) - del self.data[key] - def copy(self): - return dict(self) + _keymap = lambda key: key + environ = _Environ(environ, _keymap, _putenv, _unsetenv) - environ = _Environ(environ) def getenv(key, default=None): """Get an environment variable, return None if it doesn't exist. From python-3000-checkins at python.org Mon Jun 11 23:00:00 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Mon, 11 Jun 2007 23:00:00 +0200 (CEST) Subject: [Python-3000-checkins] r55913 - in python/branches/p3yk: Doc/lib/libftplib.tex Doc/lib/libhttplib.tex Doc/lib/libpoplib.tex Doc/lib/libsmtplib.tex Doc/lib/libsocket.tex Doc/lib/libtelnetlib.tex Doc/lib/liburllib2.tex Doc/tut/tut.tex Lib/distutils/mwerkscompiler.py Lib/repr.py Lib/test/string_tests.py Lib/test/test_bytes.py Lib/test/test_repr.py Lib/test/test_str.py Lib/test/test_sundry.py Lib/test/test_unicode.py Lib/test/test_urllib2_localnet.py Misc/ACKS Misc/valgrind-python.supp Modules/_ctypes/callproc.c Modules/_ctypes/ctypes.h Objects/stringobject.c Objects/unicodeobject.c Message-ID: <20070611210000.1BDD41E4002@bag.python.org> Author: guido.van.rossum Date: Mon Jun 11 22:59:45 2007 New Revision: 55913 Modified: python/branches/p3yk/ (props changed) python/branches/p3yk/Doc/lib/libftplib.tex python/branches/p3yk/Doc/lib/libhttplib.tex python/branches/p3yk/Doc/lib/libpoplib.tex python/branches/p3yk/Doc/lib/libsmtplib.tex python/branches/p3yk/Doc/lib/libsocket.tex python/branches/p3yk/Doc/lib/libtelnetlib.tex python/branches/p3yk/Doc/lib/liburllib2.tex python/branches/p3yk/Doc/tut/tut.tex python/branches/p3yk/Lib/distutils/mwerkscompiler.py python/branches/p3yk/Lib/repr.py python/branches/p3yk/Lib/test/string_tests.py python/branches/p3yk/Lib/test/test_bytes.py python/branches/p3yk/Lib/test/test_repr.py python/branches/p3yk/Lib/test/test_str.py python/branches/p3yk/Lib/test/test_sundry.py python/branches/p3yk/Lib/test/test_unicode.py python/branches/p3yk/Lib/test/test_urllib2_localnet.py python/branches/p3yk/Misc/ACKS python/branches/p3yk/Misc/valgrind-python.supp python/branches/p3yk/Modules/_ctypes/callproc.c python/branches/p3yk/Modules/_ctypes/ctypes.h python/branches/p3yk/Objects/stringobject.c python/branches/p3yk/Objects/unicodeobject.c Log: Merged revisions 55869-55912 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r55869 | neal.norwitz | 2007-06-10 17:42:11 -0700 (Sun, 10 Jun 2007) | 1 line Add Atul Varma for patch # 1667860 ........ r55870 | neal.norwitz | 2007-06-10 18:22:03 -0700 (Sun, 10 Jun 2007) | 1 line Ignore valgrind problems on Ubuntu from ld ........ r55872 | neal.norwitz | 2007-06-10 18:48:46 -0700 (Sun, 10 Jun 2007) | 2 lines Ignore config.status.lineno which seems new (new autoconf?) ........ r55873 | neal.norwitz | 2007-06-10 19:14:39 -0700 (Sun, 10 Jun 2007) | 1 line Prevent these tests from running on Win64 since they don\'t apply there either ........ r55874 | neal.norwitz | 2007-06-10 19:16:10 -0700 (Sun, 10 Jun 2007) | 5 lines Fix a bug when there was a newline in the string expandtabs was called on. This also catches another condition that can overflow. Will backport. ........ r55879 | neal.norwitz | 2007-06-10 21:52:37 -0700 (Sun, 10 Jun 2007) | 1 line Prevent hang if the port cannot be opened. ........ r55881 | neal.norwitz | 2007-06-10 22:28:45 -0700 (Sun, 10 Jun 2007) | 4 lines Add all of the distuils modules that don't seem to have explicit tests. :-( Move an import in mworkscompiler so that this module can be imported on any platform. Hopefully this works on all platforms. ........ r55882 | neal.norwitz | 2007-06-10 22:35:10 -0700 (Sun, 10 Jun 2007) | 4 lines SF #1734732, lower case the module names per PEP 8. Will backport. ........ r55885 | neal.norwitz | 2007-06-10 23:16:48 -0700 (Sun, 10 Jun 2007) | 4 lines Not sure why this only fails sometimes on Unix machines. Better to disable it and only import msvccompiler on Windows since that's the only place it can work anyways. ........ r55887 | neal.norwitz | 2007-06-11 00:29:43 -0700 (Mon, 11 Jun 2007) | 4 lines Bug #1734723: Fix repr.Repr() so it doesn't ignore the maxtuple attribute. Will backport ........ r55889 | neal.norwitz | 2007-06-11 00:36:24 -0700 (Mon, 11 Jun 2007) | 1 line Reflow long line ........ r55896 | thomas.heller | 2007-06-11 08:58:33 -0700 (Mon, 11 Jun 2007) | 3 lines Use "O&" in calls to PyArg_Parse when we need a 'void*' instead of "k" or "K" codes. ........ r55901 | facundo.batista | 2007-06-11 09:27:08 -0700 (Mon, 11 Jun 2007) | 5 lines Added versionchanged flag to all the methods which received a new optional timeout parameter, and a versionadded flag to the socket.create_connection function. ........ Modified: python/branches/p3yk/Doc/lib/libftplib.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libftplib.tex (original) +++ python/branches/p3yk/Doc/lib/libftplib.tex Mon Jun 11 22:59:45 2007 @@ -46,6 +46,7 @@ The optional \var{timeout} parameter specifies a timeout in seconds for the connection attempt (if is not specified, or passed as None, the global default timeout setting will be used). +\versionchanged[\var{timeout} was added]{2.6} \end{classdesc} \begin{datadesc}{all_errors} @@ -117,6 +118,8 @@ object timeout is used (the timeout that you passed when instantiating the class); if the object timeout is also None, the global default timeout setting will be used. + +\versionchanged[\var{timeout} was added]{2.6} \end{methoddesc} \begin{methoddesc}[FTP]{getwelcome}{} Modified: python/branches/p3yk/Doc/lib/libhttplib.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libhttplib.tex (original) +++ python/branches/p3yk/Doc/lib/libhttplib.tex Mon Jun 11 22:59:45 2007 @@ -49,6 +49,7 @@ >>> h3 = httplib.HTTPConnection('www.cwi.nl', 80, timeout=10) \end{verbatim} \versionadded{2.0} +\versionchanged[\var{timeout} was added]{2.6} \end{classdesc} \begin{classdesc}{HTTPSConnection}{host\optional{, port\optional{, @@ -63,6 +64,7 @@ \warning{This does not do any certificate verification!} \versionadded{2.0} +\versionchanged[\var{timeout} was added]{2.6} \end{classdesc} \begin{classdesc}{HTTPResponse}{sock\optional{, debuglevel=0}\optional{, strict=0}} Modified: python/branches/p3yk/Doc/lib/libpoplib.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libpoplib.tex (original) +++ python/branches/p3yk/Doc/lib/libpoplib.tex Mon Jun 11 22:59:45 2007 @@ -35,6 +35,8 @@ The optional \var{timeout} parameter specifies a timeout in seconds for the connection attempt (if not specified, or passed as None, the global default timeout setting will be used). + +\versionchanged[\var{timeout} was added]{2.6} \end{classdesc} \begin{classdesc}{POP3_SSL}{host\optional{, port\optional{, keyfile\optional{, certfile}}}} Modified: python/branches/p3yk/Doc/lib/libsmtplib.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libsmtplib.tex (original) +++ python/branches/p3yk/Doc/lib/libsmtplib.tex Mon Jun 11 22:59:45 2007 @@ -29,6 +29,8 @@ For normal use, you should only require the initialization/connect, \method{sendmail()}, and \method{quit()} methods. An example is included below. + +\versionchanged[\var{timeout} was added]{2.6} \end{classdesc} \begin{classdesc}{SMTP_SSL}{\optional{host\optional{, port\optional{, @@ -45,6 +47,8 @@ The optional \var{timeout} parameter specifies a timeout in seconds for the connection attempt (if not specified, or passed as None, the global default timeout setting will be used). + +\versionchanged[\var{timeout} was added]{2.6} \end{classdesc} \begin{classdesc}{LMTP}{\optional{host\optional{, port\optional{, Modified: python/branches/p3yk/Doc/lib/libsocket.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libsocket.tex (original) +++ python/branches/p3yk/Doc/lib/libsocket.tex Mon Jun 11 22:59:45 2007 @@ -177,6 +177,7 @@ application-level code. Passing the optional \var{timeout} parameter will set the timeout on the socket instance (if it is not given or \code{None}, the global default timeout setting is used). +\versionadded{2.6} \end{funcdesc} \begin{funcdesc}{getaddrinfo}{host, port\optional{, family\optional{, Modified: python/branches/p3yk/Doc/lib/libtelnetlib.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libtelnetlib.tex (original) +++ python/branches/p3yk/Doc/lib/libtelnetlib.tex Mon Jun 11 22:59:45 2007 @@ -40,6 +40,7 @@ raise \exception{EOFError} when the end of the connection is read, because they can return an empty string for other reasons. See the individual descriptions below. +\versionchanged[\var{timeout} was added]{2.6} \end{classdesc} @@ -123,6 +124,7 @@ timeout setting will be used). Do not try to reopen an already connected instance. +\versionchanged[\var{timeout} was added]{2.6} \end{methoddesc} \begin{methoddesc}[Telnet]{msg}{msg\optional{, *args}} Modified: python/branches/p3yk/Doc/lib/liburllib2.tex ============================================================================== --- python/branches/p3yk/Doc/lib/liburllib2.tex (original) +++ python/branches/p3yk/Doc/lib/liburllib2.tex Mon Jun 11 22:59:45 2007 @@ -45,6 +45,8 @@ Note that \code{None} may be returned if no handler handles the request (though the default installed global \class{OpenerDirector} uses \class{UnknownHandler} to ensure this never happens). + +\versionchanged[\var{timeout} was added]{2.6} \end{funcdesc} \begin{funcdesc}{install_opener}{opener} @@ -367,6 +369,7 @@ setting will be used; this actually only work for HTTP, HTTPS, FTP and FTPS connections). +\versionchanged[\var{timeout} was added]{2.6} \end{methoddesc} \begin{methoddesc}[OpenerDirector]{error}{proto\optional{, Modified: python/branches/p3yk/Doc/tut/tut.tex ============================================================================== --- python/branches/p3yk/Doc/tut/tut.tex (original) +++ python/branches/p3yk/Doc/tut/tut.tex Mon Jun 11 22:59:45 2007 @@ -2734,9 +2734,9 @@ hierarchical filesystem): \begin{verbatim} -Sound/ Top-level package +sound/ Top-level package __init__.py Initialize the sound package - Formats/ Subpackage for file format conversions + formats/ Subpackage for file format conversions __init__.py wavread.py wavwrite.py @@ -2745,13 +2745,13 @@ auread.py auwrite.py ... - Effects/ Subpackage for sound effects + effects/ Subpackage for sound effects __init__.py echo.py surround.py reverse.py ... - Filters/ Subpackage for filters + filters/ Subpackage for filters __init__.py equalizer.py vocoder.py @@ -2774,20 +2774,20 @@ package, for example: \begin{verbatim} -import Sound.Effects.echo +import sound.effects.echo \end{verbatim} -This loads the submodule \module{Sound.Effects.echo}. It must be referenced +This loads the submodule \module{sound.effects.echo}. It must be referenced with its full name. \begin{verbatim} -Sound.Effects.echo.echofilter(input, output, delay=0.7, atten=4) +sound.effects.echo.echofilter(input, output, delay=0.7, atten=4) \end{verbatim} An alternative way of importing the submodule is: \begin{verbatim} -from Sound.Effects import echo +from sound.effects import echo \end{verbatim} This also loads the submodule \module{echo}, and makes it available without @@ -2800,7 +2800,7 @@ Yet another variation is to import the desired function or variable directly: \begin{verbatim} -from Sound.Effects.echo import echofilter +from sound.effects.echo import echofilter \end{verbatim} Again, this loads the submodule \module{echo}, but this makes its function @@ -2827,7 +2827,7 @@ %The \code{__all__} Attribute \ttindex{__all__} -Now what happens when the user writes \code{from Sound.Effects import +Now what happens when the user writes \code{from sound.effects import *}? Ideally, one would hope that this somehow goes out to the filesystem, finds which submodules are present in the package, and imports them all. Unfortunately, this operation does not work very @@ -2849,19 +2849,19 @@ up-to-date when a new version of the package is released. Package authors may also decide not to support it, if they don't see a use for importing * from their package. For example, the file -\file{Sounds/Effects/__init__.py} could contain the following code: +\file{sounds/effects/__init__.py} could contain the following code: \begin{verbatim} __all__ = ["echo", "surround", "reverse"] \end{verbatim} -This would mean that \code{from Sound.Effects import *} would -import the three named submodules of the \module{Sound} package. +This would mean that \code{from sound.effects import *} would +import the three named submodules of the \module{sound} package. -If \code{__all__} is not defined, the statement \code{from Sound.Effects +If \code{__all__} is not defined, the statement \code{from sound.effects import *} does \emph{not} import all submodules from the package -\module{Sound.Effects} into the current namespace; it only ensures that the -package \module{Sound.Effects} has been imported (possibly running any +\module{sound.effects} into the current namespace; it only ensures that the +package \module{sound.effects} has been imported (possibly running any initialization code in \file{__init__.py}) and then imports whatever names are defined in the package. This includes any names defined (and submodules explicitly loaded) by \file{__init__.py}. It also includes any @@ -2869,14 +2869,14 @@ import statements. Consider this code: \begin{verbatim} -import Sound.Effects.echo -import Sound.Effects.surround -from Sound.Effects import * +import sound.effects.echo +import sound.effects.surround +from sound.effects import * \end{verbatim} In this example, the echo and surround modules are imported in the current namespace because they are defined in the -\module{Sound.Effects} package when the \code{from...import} statement +\module{sound.effects} package when the \code{from...import} statement is executed. (This also works when \code{__all__} is defined.) Note that in general the practice of importing \code{*} from a module or @@ -2904,12 +2904,12 @@ statement looks for a top-level module with the given name. When packages are structured into subpackages (as with the -\module{Sound} package in the example), there's no shortcut to refer +\module{sound} package in the example), there's no shortcut to refer to submodules of sibling packages - the full name of the subpackage must be used. For example, if the module -\module{Sound.Filters.vocoder} needs to use the \module{echo} module -in the \module{Sound.Effects} package, it can use \code{from -Sound.Effects import echo}. +\module{sound.filters.vocoder} needs to use the \module{echo} module +in the \module{sound.effects} package, it can use \code{from +sound.effects import echo}. Starting with Python 2.5, in addition to the implicit relative imports described above, you can write explicit relative imports with the @@ -2920,8 +2920,8 @@ \begin{verbatim} from . import echo -from .. import Formats -from ..Filters import equalizer +from .. import formats +from ..filters import equalizer \end{verbatim} Note that both explicit and implicit relative imports are based on the Modified: python/branches/p3yk/Lib/distutils/mwerkscompiler.py ============================================================================== --- python/branches/p3yk/Lib/distutils/mwerkscompiler.py (original) +++ python/branches/p3yk/Lib/distutils/mwerkscompiler.py Mon Jun 11 22:59:45 2007 @@ -18,7 +18,6 @@ import distutils.util import distutils.dir_util from distutils import log -import mkcwproject class MWerksCompiler (CCompiler) : """Concrete class that implements an interface to MetroWerks CodeWarrior, @@ -188,6 +187,7 @@ # doesn't have a clue about our working directory. xmlfilename = os.path.join(os.getcwd(), os.path.join(build_temp, xmlname)) log.debug("\tCreate XML file %s", xmlfilename) + import mkcwproject xmlbuilder = mkcwproject.cwxmlgen.ProjectBuilder(settings) xmlbuilder.generate() xmldata = settings['tmp_projectxmldata'] Modified: python/branches/p3yk/Lib/repr.py ============================================================================== --- python/branches/p3yk/Lib/repr.py (original) +++ python/branches/p3yk/Lib/repr.py Mon Jun 11 22:59:45 2007 @@ -47,7 +47,7 @@ return '%s%s%s' % (left, s, right) def repr_tuple(self, x, level): - return self._repr_iterable(x, level, '(', ')', self.maxlist, ',') + return self._repr_iterable(x, level, '(', ')', self.maxtuple, ',') def repr_list(self, x, level): return self._repr_iterable(x, level, '[', ']', self.maxlist) Modified: python/branches/p3yk/Lib/test/string_tests.py ============================================================================== --- python/branches/p3yk/Lib/test/string_tests.py (original) +++ python/branches/p3yk/Lib/test/string_tests.py Mon Jun 11 22:59:45 2007 @@ -211,6 +211,32 @@ self.checkraises(TypeError, 'hello', 'rindex') self.checkraises(TypeError, 'hello', 'rindex', 42) + def test_lower(self): + self.checkequal('hello', 'HeLLo', 'lower') + self.checkequal('hello', 'hello', 'lower') + self.checkraises(TypeError, 'hello', 'lower', 42) + + def test_upper(self): + self.checkequal('HELLO', 'HeLLo', 'upper') + self.checkequal('HELLO', 'HELLO', 'upper') + self.checkraises(TypeError, 'hello', 'upper', 42) + + def test_expandtabs(self): + self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs') + self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs', 8) + self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs', 4) + self.checkequal('abc\r\nab def\ng hi', 'abc\r\nab\tdef\ng\thi', 'expandtabs', 4) + self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs') + self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs', 8) + self.checkequal('abc\r\nab\r\ndef\ng\r\nhi', 'abc\r\nab\r\ndef\ng\r\nhi', 'expandtabs', 4) + self.checkequal(' a\n b', ' \ta\n\tb', 'expandtabs', 1) + + 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: + self.checkraises(OverflowError, + '\ta\n\tb', 'expandtabs', sys.maxint) + def test_split(self): # by a char self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|') Modified: python/branches/p3yk/Lib/test/test_bytes.py ============================================================================== --- python/branches/p3yk/Lib/test/test_bytes.py (original) +++ python/branches/p3yk/Lib/test/test_bytes.py Mon Jun 11 22:59:45 2007 @@ -709,6 +709,12 @@ pass def test_find(self): pass + def test_expandtabs(self): + pass + def test_upper(self): + pass + def test_lower(self): + pass def test_main(): Modified: python/branches/p3yk/Lib/test/test_repr.py ============================================================================== --- python/branches/p3yk/Lib/test/test_repr.py (original) +++ python/branches/p3yk/Lib/test/test_repr.py Mon Jun 11 22:59:45 2007 @@ -10,6 +10,7 @@ from test.test_support import run_unittest from repr import repr as r # Don't shadow builtin repr +from repr import Repr def nestedTuple(nesting): @@ -34,6 +35,18 @@ expected = repr(s)[:13] + "..." + repr(s)[-14:] eq(r(s), expected) + def test_tuple(self): + eq = self.assertEquals + eq(r((1,)), "(1,)") + + t3 = (1, 2, 3) + eq(r(t3), "(1, 2, 3)") + + r2 = Repr() + r2.maxtuple = 2 + expected = repr(t3)[:-2] + "...)" + eq(r2.repr(t3), expected) + def test_container(self): from array import array from collections import deque Modified: python/branches/p3yk/Lib/test/test_str.py ============================================================================== --- python/branches/p3yk/Lib/test/test_str.py (original) +++ python/branches/p3yk/Lib/test/test_str.py Mon Jun 11 22:59:45 2007 @@ -1,5 +1,6 @@ import unittest +import struct import sys from test import test_support, string_tests @@ -96,7 +97,7 @@ # 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): + if sys.maxint > (1 << 32) or struct.calcsize('P') != 4: return self.assertRaises(OverflowError, 't\tt\t'.expandtabs, sys.maxint) Modified: python/branches/p3yk/Lib/test/test_sundry.py ============================================================================== --- python/branches/p3yk/Lib/test/test_sundry.py (original) +++ python/branches/p3yk/Lib/test/test_sundry.py Mon Jun 11 22:59:45 2007 @@ -1,6 +1,7 @@ """Do a minimal test of all the modules that aren't otherwise tested.""" from test.test_support import guard_warnings_filter +import sys import warnings with guard_warnings_filter(): @@ -18,6 +19,53 @@ import cmd import code import compileall + + import distutils.archive_util + import distutils.bcppcompiler + import distutils.ccompiler + import distutils.cmd + import distutils.core + import distutils.cygwinccompiler + import distutils.dep_util + import distutils.dir_util + import distutils.emxccompiler + import distutils.errors + import distutils.extension + import distutils.file_util + import distutils.filelist + import distutils.log + if sys.platform.startswith('win'): + import distutils.msvccompiler + import distutils.mwerkscompiler + import distutils.sysconfig + import distutils.text_file + import distutils.unixccompiler + import distutils.util + import distutils.version + + import distutils.command.bdist_dumb + if sys.platform.startswith('win'): + import distutils.command.bdist_msi + import distutils.command.bdist + import distutils.command.bdist_rpm + import distutils.command.bdist_wininst + import distutils.command.build_clib + import distutils.command.build_ext + import distutils.command.build + import distutils.command.build_py + import distutils.command.build_scripts + import distutils.command.clean + import distutils.command.config + import distutils.command.install_data + import distutils.command.install_egg_info + import distutils.command.install_headers + import distutils.command.install_lib + import distutils.command.install + import distutils.command.install_scripts + import distutils.command.register + import distutils.command.sdist + import distutils.command.upload + import encodings import formatter import ftplib @@ -37,7 +85,6 @@ import os2emxpath import pdb import pipes - #import poplib import pstats import py_compile import pydoc Modified: python/branches/p3yk/Lib/test/test_unicode.py ============================================================================== --- python/branches/p3yk/Lib/test/test_unicode.py (original) +++ python/branches/p3yk/Lib/test/test_unicode.py Mon Jun 11 22:59:45 2007 @@ -6,7 +6,7 @@ (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. """#" -import unittest, sys, codecs, new +import unittest, sys, struct, codecs, new from test import test_support, string_tests # Error handling (bad decoder return) @@ -829,7 +829,7 @@ # 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): + if sys.maxint > (1 << 32) or struct.calcsize('P') != 4: return self.assertRaises(OverflowError, u't\tt\t'.expandtabs, sys.maxint) Modified: python/branches/p3yk/Lib/test/test_urllib2_localnet.py ============================================================================== --- python/branches/p3yk/Lib/test/test_urllib2_localnet.py (original) +++ python/branches/p3yk/Lib/test/test_urllib2_localnet.py Mon Jun 11 22:59:45 2007 @@ -47,6 +47,7 @@ self._port = port self._server_address = ('127.0.0.1', self._port) self.ready = threading.Event() + self.error = None def stop(self): """Stops the webserver if it's currently running.""" @@ -59,12 +60,18 @@ def run(self): protocol = "HTTP/1.0" - self._RequestHandlerClass.protocol_version = protocol - httpd = LoopbackHttpServer(self._server_address, - self._RequestHandlerClass) - - sa = httpd.socket.getsockname() - #print "Serving HTTP on", sa[0], "port", sa[1], "..." + try: + self._RequestHandlerClass.protocol_version = protocol + httpd = LoopbackHttpServer(self._server_address, + self._RequestHandlerClass) + + sa = httpd.socket.getsockname() + #print "Serving HTTP on", sa[0], "port", sa[1], "..." + except: + # Fail "gracefully" if we are unable to start. + self.ready.set() + self.error = sys.exc_info()[1] + raise self.ready.set() while not self._stop: @@ -241,6 +248,8 @@ self.server = LoopbackHttpServerThread(self.PORT, FakeProxyHandler) self.server.start() self.server.ready.wait() + if self.server.error: + raise self.server.error handler = urllib2.ProxyHandler({"http" : self.PROXY_URL}) self._digest_auth_handler = urllib2.ProxyDigestAuthHandler() Modified: python/branches/p3yk/Misc/ACKS ============================================================================== --- python/branches/p3yk/Misc/ACKS (original) +++ python/branches/p3yk/Misc/ACKS Mon Jun 11 22:59:45 2007 @@ -661,6 +661,7 @@ Roger Upole Michael Urman Hector Urtubia +Atul Varma Dmitry Vasiliev Frank Vercruesse Mike Verdone Modified: python/branches/p3yk/Misc/valgrind-python.supp ============================================================================== --- python/branches/p3yk/Misc/valgrind-python.supp (original) +++ python/branches/p3yk/Misc/valgrind-python.supp Mon Jun 11 22:59:45 2007 @@ -134,6 +134,15 @@ ### { + Generic ubuntu ld problems + Memcheck:Addr8 + obj:/lib/ld-2.4.so + obj:/lib/ld-2.4.so + obj:/lib/ld-2.4.so + obj:/lib/ld-2.4.so +} + +{ Generic gentoo ld problems Memcheck:Cond obj:/lib/ld-2.3.4.so Modified: python/branches/p3yk/Modules/_ctypes/callproc.c ============================================================================== --- python/branches/p3yk/Modules/_ctypes/callproc.c (original) +++ python/branches/p3yk/Modules/_ctypes/callproc.c Mon Jun 11 22:59:45 2007 @@ -1040,6 +1040,15 @@ return retval; } +static int +_parse_voidp(PyObject *obj, void **address) +{ + *address = PyLong_AsVoidPtr(obj); + if (*address == NULL) + return 0; + return 1; +} + #ifdef MS_WIN32 #ifdef _UNICODE @@ -1127,7 +1136,7 @@ static PyObject *free_library(PyObject *self, PyObject *args) { void *hMod; - if (!PyArg_ParseTuple(args, PY_VOID_P_CODE ":FreeLibrary", &hMod)) + if (!PyArg_ParseTuple(args, "O&:FreeLibrary", &_parse_voidp, &hMod)) return NULL; if (!FreeLibrary((HMODULE)hMod)) return PyErr_SetFromWindowsErr(GetLastError()); @@ -1250,7 +1259,7 @@ { void *handle; - if (!PyArg_ParseTuple(args, PY_VOID_P_CODE ":dlclose", &handle)) + if (!PyArg_ParseTuple(args, "O&:dlclose", &_parse_voidp, &handle)) return NULL; if (dlclose(handle)) { PyErr_SetString(PyExc_OSError, @@ -1267,7 +1276,8 @@ void *handle; void *ptr; - if (!PyArg_ParseTuple(args, PY_VOID_P_CODE "s:dlsym", &handle, &name)) + if (!PyArg_ParseTuple(args, "O&s:dlsym", + &_parse_voidp, &handle, &name)) return NULL; ptr = ctypes_dlsym((void*)handle, name); if (!ptr) { @@ -1292,8 +1302,8 @@ PyObject *result; if (!PyArg_ParseTuple(args, - PY_VOID_P_CODE "O!", - &func, + "O&O!", + &_parse_voidp, &func, &PyTuple_Type, &arguments)) return NULL; @@ -1323,8 +1333,8 @@ PyObject *result; if (!PyArg_ParseTuple(args, - PY_VOID_P_CODE "O!", - &func, + "O&O!", + &_parse_voidp, &func, &PyTuple_Type, &arguments)) return NULL; Modified: python/branches/p3yk/Modules/_ctypes/ctypes.h ============================================================================== --- python/branches/p3yk/Modules/_ctypes/ctypes.h (original) +++ python/branches/p3yk/Modules/_ctypes/ctypes.h Mon Jun 11 22:59:45 2007 @@ -24,12 +24,6 @@ #define PY_LONG_LONG LONG_LONG #endif -#if SIZEOF_VOID_P == SIZEOF_LONG -#define PY_VOID_P_CODE "k" -#elif defined(HAVE_LONG_LONG) && (SIZEOF_VOID_P == SIZEOF_LONG_LONG) -#define PY_VOID_P_CODE "K" -#endif - typedef struct tagPyCArgObject PyCArgObject; typedef struct tagCDataObject CDataObject; typedef PyObject *(* GETFUNC)(void *, Py_ssize_t size); Modified: python/branches/p3yk/Objects/stringobject.c ============================================================================== --- python/branches/p3yk/Objects/stringobject.c (original) +++ python/branches/p3yk/Objects/stringobject.c Mon Jun 11 22:59:45 2007 @@ -3324,7 +3324,8 @@ if (tabsize > 0) { j += tabsize - (j % tabsize); if (old_j > j) { - PyErr_SetString(PyExc_OverflowError, "new string is too long"); + PyErr_SetString(PyExc_OverflowError, + "new string is too long"); return NULL; } old_j = j; @@ -3334,7 +3335,12 @@ j++; if (*p == '\n' || *p == '\r') { i += j; - j = 0; + old_j = j = 0; + if (i < 0) { + PyErr_SetString(PyExc_OverflowError, + "new string is too long"); + return NULL; + } } } Modified: python/branches/p3yk/Objects/unicodeobject.c ============================================================================== --- python/branches/p3yk/Objects/unicodeobject.c (original) +++ python/branches/p3yk/Objects/unicodeobject.c Mon Jun 11 22:59:45 2007 @@ -5708,7 +5708,8 @@ if (tabsize > 0) { j += tabsize - (j % tabsize); if (old_j > j) { - PyErr_SetString(PyExc_OverflowError, "new string is too long"); + PyErr_SetString(PyExc_OverflowError, + "new string is too long"); return NULL; } old_j = j; @@ -5718,7 +5719,12 @@ j++; if (*p == '\n' || *p == '\r') { i += j; - j = 0; + old_j = j = 0; + if (i < 0) { + PyErr_SetString(PyExc_OverflowError, + "new string is too long"); + return NULL; + } } } From python-3000-checkins at python.org Mon Jun 11 23:19:56 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Mon, 11 Jun 2007 23:19:56 +0200 (CEST) Subject: [Python-3000-checkins] r55914 - in python/branches/p3yk: Lib/test/test_super.py Objects/typeobject.c Python/bltinmodule.c Python/compile.c Python/symtable.c Message-ID: <20070611211956.E80821E400C@bag.python.org> Author: guido.van.rossum Date: Mon Jun 11 23:19:50 2007 New Revision: 55914 Added: python/branches/p3yk/Lib/test/test_super.py (contents, props changed) Modified: python/branches/p3yk/Objects/typeobject.c python/branches/p3yk/Python/bltinmodule.c python/branches/p3yk/Python/compile.c python/branches/p3yk/Python/symtable.c Log: New super() implementation, for PEP 3135 (though the PEP is not yet updated to this design, and small tweaks may still be made later). Added: python/branches/p3yk/Lib/test/test_super.py ============================================================================== --- (empty file) +++ python/branches/p3yk/Lib/test/test_super.py Mon Jun 11 23:19:50 2007 @@ -0,0 +1,82 @@ +"""Unit tests for new super() implementation.""" + +# XXX Temporarily, we use super() instead of super. Or maybe we should +# use this, period? + +import sys +import unittest +from test import test_support + + +class A: + def f(self): + return 'A' + @classmethod + def cm(cls): + return (cls, 'A') + +class B(A): + def f(self): + return super().f() + 'B' + @classmethod + def cm(cls): + return (cls, super().cm(), 'B') + +class C(A): + def f(self): + return super().f() + 'C' + @classmethod + def cm(cls): + return (cls, super().cm(), 'C') + +class D(C, B): + def f(self): + return super().f() + 'D' + def cm(cls): + return (cls, super().cm(), 'D') + +class E(D): + pass + +class F(E): + f = E.f + +class G(A): + pass + + +class TestSuper(unittest.TestCase): + + def testBasicsWorking(self): + self.assertEqual(D().f(), 'ABCD') + + def testClassGetattrWorking(self): + self.assertEqual(D.f(D()), 'ABCD') + + def testSubclassNoOverrideWorking(self): + self.assertEqual(E().f(), 'ABCD') + self.assertEqual(E.f(E()), 'ABCD') + + def testUnboundMethodTransferWorking(self): + self.assertEqual(F().f(), 'ABCD') + self.assertEqual(F.f(F()), 'ABCD') + + def testClassMethodsStillWorking(self): + self.assertEqual(A.cm(), (A, 'A')) + self.assertEqual(A().cm(), (A, 'A')) + self.assertEqual(G.cm(), (G, 'A')) + self.assertEqual(G().cm(), (G, 'A')) + + def testSuperInClassMethodsWorking(self): + d = D() + self.assertEqual(d.cm(), (d, (D, (D, (D, 'A'), 'B'), 'C'), 'D')) + e = E() + self.assertEqual(e.cm(), (e, (E, (E, (E, 'A'), 'B'), 'C'), 'D')) + + +def test_main(): + test_support.run_unittest(TestSuper) + + +if __name__ == "__main__": + unittest.main() Modified: python/branches/p3yk/Objects/typeobject.c ============================================================================== --- python/branches/p3yk/Objects/typeobject.c (original) +++ python/branches/p3yk/Objects/typeobject.c Mon Jun 11 23:19:50 2007 @@ -1,6 +1,7 @@ /* Type object implementation */ #include "Python.h" +#include "frameobject.h" #include "structmember.h" #include @@ -5866,14 +5867,76 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds) { superobject *su = (superobject *)self; - PyTypeObject *type; + PyTypeObject *type = NULL; PyObject *obj = NULL; PyTypeObject *obj_type = NULL; if (!_PyArg_NoKeywords("super", kwds)) return -1; - if (!PyArg_ParseTuple(args, "O!|O:super", &PyType_Type, &type, &obj)) + if (!PyArg_ParseTuple(args, "|O!O:super", &PyType_Type, &type, &obj)) return -1; + + if (type == NULL) { + /* Call super(), without args -- fill in from __class__ + and first local variable on the stack. */ + PyFrameObject *f = PyThreadState_GET()->frame; + PyCodeObject *co = f->f_code; + int i, n; + if (co == NULL) { + PyErr_SetString(PyExc_SystemError, + "super(): no code object"); + return -1; + } + if (co->co_argcount == 0) { + PyErr_SetString(PyExc_SystemError, + "super(): no arguments"); + return -1; + } + obj = f->f_localsplus[0]; + if (obj == NULL) { + PyErr_SetString(PyExc_SystemError, + "super(): arg[0] deleted"); + return -1; + } + if (co->co_freevars == NULL) + n = 0; + else { + assert(PyTuple_Check(co->co_freevars)); + n = PyTuple_GET_SIZE(co->co_freevars); + } + for (i = 0; i < n; i++) { + PyObject *name = PyTuple_GET_ITEM(co->co_freevars, i); + assert(PyString_Check(name)); /* XXX PyUnicode? */ + if (!strcmp(PyString_AS_STRING(name), "__class__")) { + PyObject *cell = + f->f_localsplus[co->co_nlocals + i]; + if (cell == NULL || !PyCell_Check(cell)) { + PyErr_SetString(PyExc_SystemError, + "super(): bad __class__ cell"); + return -1; + } + type = (PyTypeObject *) PyCell_GET(cell); + if (type == NULL) { + PyErr_SetString(PyExc_SystemError, + "super(): empty __class__ cell"); + return -1; + } + if (!PyType_Check(type)) { + PyErr_Format(PyExc_SystemError, + "super(): __class__ is not a type (%s)", + type->ob_type->tp_name); + return -1; + } + break; + } + } + if (type == NULL) { + PyErr_SetString(PyExc_SystemError, + "super(): __class__ cell not found"); + return -1; + } + } + if (obj == Py_None) obj = NULL; if (obj != NULL) { @@ -5890,13 +5953,19 @@ } PyDoc_STRVAR(super_doc, +"super() -> same as super(__class__, )\n" "super(type) -> unbound super object\n" "super(type, obj) -> bound super object; requires isinstance(obj, type)\n" "super(type, type2) -> bound super object; requires issubclass(type2, type)\n" "Typical use to call a cooperative superclass method:\n" "class C(B):\n" " def meth(self, arg):\n" -" super(C, self).meth(arg)"); +" super().meth(arg)\n" +"This works for class methods too:\n" +"class C(B):\n" +" @classmethod\n" +" def cmeth(cls, arg):\n" +" super().cmeth(arg)\n"); static int super_traverse(PyObject *self, visitproc visit, void *arg) Modified: python/branches/p3yk/Python/bltinmodule.c ============================================================================== --- python/branches/p3yk/Python/bltinmodule.c (original) +++ python/branches/p3yk/Python/bltinmodule.c Mon Jun 11 23:19:50 2007 @@ -33,7 +33,8 @@ static PyObject * builtin___build_class__(PyObject *self, PyObject *args, PyObject *kwds) { - PyObject *func, *name, *bases, *mkw, *meta, *prep, *ns, *res; + PyObject *func, *name, *bases, *mkw, *meta, *prep, *ns, *cell; + PyObject *cls = NULL; Py_ssize_t nargs, nbases; assert(args != NULL); @@ -114,22 +115,25 @@ return NULL; } } - res = PyObject_CallFunctionObjArgs(func, ns, NULL); - if (res != NULL) { + cell = PyObject_CallFunctionObjArgs(func, ns, NULL); + if (cell != NULL) { PyObject *margs; - Py_DECREF(res); - res = NULL; margs = Py_BuildValue("OOO", name, bases, ns); if (margs != NULL) { - res = PyEval_CallObjectWithKeywords(meta, margs, mkw); + cls = PyEval_CallObjectWithKeywords(meta, margs, mkw); Py_DECREF(margs); } + if (cls != NULL && PyCell_Check(cell)) { + Py_INCREF(cls); + PyCell_SET(cell, cls); + } + Py_DECREF(cell); } Py_DECREF(ns); Py_DECREF(meta); Py_XDECREF(mkw); Py_DECREF(bases); - return res; + return cls; } PyDoc_STRVAR(build_class_doc, Modified: python/branches/p3yk/Python/compile.c ============================================================================== --- python/branches/p3yk/Python/compile.c (original) +++ python/branches/p3yk/Python/compile.c Mon Jun 11 23:19:50 2007 @@ -373,10 +373,12 @@ while (PyDict_Next(src, &pos, &k, &v)) { /* XXX this should probably be a macro in symtable.h */ + long vi; assert(PyInt_Check(v)); - scope = (PyInt_AS_LONG(v) >> SCOPE_OFFSET) & SCOPE_MASK; + vi = PyInt_AS_LONG(v); + scope = (vi >> SCOPE_OFFSET) & SCOPE_MASK; - if (scope == scope_type || PyInt_AS_LONG(v) & flag) { + if (scope == scope_type || vi & flag) { PyObject *tuple, *item = PyInt_FromLong(i); if (item == NULL) { Py_DECREF(dest); @@ -1252,7 +1254,8 @@ else /* (reftype == FREE) */ arg = compiler_lookup_arg(c->u->u_freevars, name); if (arg == -1) { - printf("lookup %s in %s %d %d\n" + fprintf(stderr, + "lookup %s in %s %d %d\n" "freevars of %s: %s\n", PyObject_REPR(name), PyString_AS_STRING(c->u->u_name), @@ -1475,7 +1478,6 @@ static int compiler_class(struct compiler *c, stmt_ty s) { - static PyObject *build_class = NULL; static PyObject *locals = NULL; PyCodeObject *co; PyObject *str; @@ -1486,13 +1488,7 @@ if (!compiler_decorators(c, decos)) return 0; - /* initialize statics */ - if (build_class == NULL) { - build_class = PyString_FromString("__build_class__"); - if (build_class == NULL) - return 0; - } if (locals == NULL) { locals = PyString_FromString("__locals__"); if (locals == NULL) @@ -1502,14 +1498,16 @@ /* ultimately generate code for: = __build_class__(, , *, **) where: - is a function/closure created from the class body + is a function/closure created from the class body; + it has a single argument (__locals__) where the dict + (or MutableSequence) representing the locals is passed is the class name is the positional arguments and *varargs argument is the keyword arguments and **kwds argument This borrows from compiler_call. */ - /* 0. Create a fake variable named __locals__ */ + /* 0. Create a fake argument named __locals__ */ ste = PySymtable_Lookup(c->c_st, s); if (ste == NULL) return 0; @@ -1529,11 +1527,11 @@ c->u->u_private = s->v.ClassDef.name; /* force it to have one mandatory argument */ c->u->u_argcount = 1; - /* load the first argument ... */ + /* load the first argument (__locals__) ... */ ADDOP_I(c, LOAD_FAST, 0); /* ... and store it into f_locals */ ADDOP_IN_SCOPE(c, STORE_LOCALS); - /* load __name__ ... */ + /* load (global) __name__ ... */ str = PyString_InternFromString("__name__"); if (!str || !compiler_nameop(c, str, Load)) { Py_XDECREF(str); @@ -1554,8 +1552,24 @@ compiler_exit_scope(c); return 0; } - /* return None */ - ADDOP_O(c, LOAD_CONST, Py_None, consts); + /* return the (empty) __class__ cell */ + str = PyString_InternFromString("__class__"); + if (str == NULL) { + compiler_exit_scope(c); + return 0; + } + i = compiler_lookup_arg(c->u->u_cellvars, str); + Py_DECREF(str); + if (i == -1) { + /* This happens when nobody references the cell */ + PyErr_Clear(); + /* Return None */ + ADDOP_O(c, LOAD_CONST, Py_None, consts); + } + else { + /* Return the cell where to store __class__ */ + ADDOP_I(c, LOAD_CLOSURE, i); + } ADDOP_IN_SCOPE(c, RETURN_VALUE); /* create the code object */ co = assemble(c, 1); @@ -2422,7 +2436,7 @@ return compiler_error(c, "can not assign to __debug__"); } -mangled = _Py_Mangle(c->u->u_private, name); + mangled = _Py_Mangle(c->u->u_private, name); if (!mangled) return 0; Modified: python/branches/p3yk/Python/symtable.c ============================================================================== --- python/branches/p3yk/Python/symtable.c (original) +++ python/branches/p3yk/Python/symtable.c Mon Jun 11 23:19:50 2007 @@ -187,7 +187,7 @@ static identifier top = NULL, lambda = NULL, genexpr = NULL, - listcomp = NULL, setcomp = NULL; + listcomp = NULL, setcomp = NULL, __class__ = NULL; #define GET_IDENTIFIER(VAR) \ ((VAR) ? (VAR) : ((VAR) = PyString_InternFromString(# VAR))) @@ -321,7 +321,7 @@ /* Analyze raw symbol information to determine scope of each name. - The next several functions are helpers for PySymtable_Analyze(), + The next several functions are helpers for symtable_analyze(), which determines whether a name is local, global, or free. In addition, it determines which local variables are cell variables; they provide bindings that are used for free variables in enclosed blocks. @@ -468,10 +468,13 @@ Note that the current block's free variables are included in free. That's safe because no name can be free and local in the same scope. + + The 'restrict' argument may be set to a string to restrict the analysis + to the one variable whose name equals that string (e.g. "__class__"). */ static int -analyze_cells(PyObject *scopes, PyObject *free) +analyze_cells(PyObject *scopes, PyObject *free, const char *restrict) { PyObject *name, *v, *v_cell; int success = 0; @@ -488,6 +491,9 @@ continue; if (!PySet_Contains(free, name)) continue; + if (restrict != NULL && + strcmp(PyString_AS_STRING(name), restrict)) + continue; /* Replace LOCAL with CELL for this name, and remove from free. It is safe to replace the value of name in the dict, because it will not cause a resize. @@ -596,7 +602,7 @@ } Py_DECREF(v_new); } - /* It's a cell, or already a free variable in this scope */ + /* It's a cell, or already free in this scope */ Py_DECREF(name); continue; } @@ -682,8 +688,7 @@ goto error; } - /* Populate global and bound sets to be passed to children. - */ + /* Populate global and bound sets to be passed to children. */ if (ste->ste_type != ClassBlock) { /* Add function locals to bound set */ if (ste->ste_type == FunctionBlock) { @@ -702,6 +707,14 @@ goto error; Py_DECREF(newglobal); } + else { + /* Special-case __class__ */ + if (!GET_IDENTIFIER(__class__)) + goto error; + assert(PySet_Contains(local, __class__) == 1); + if (PySet_Add(newbound, __class__) < 0) + goto error; + } /* Recursively call analyze_block() on each child block */ for (i = 0; i < PyList_GET_SIZE(ste->ste_children); ++i) { @@ -716,8 +729,12 @@ ste->ste_child_free = 1; } - /* Check if any local variables need to be converted to cell variables */ - if (ste->ste_type == FunctionBlock && !analyze_cells(scopes, newfree)) + /* Check if any local variables must be converted to cell variables */ + if (ste->ste_type == FunctionBlock && !analyze_cells(scopes, newfree, + NULL)) + goto error; + else if (ste->ste_type == ClassBlock && !analyze_cells(scopes, newfree, + "__class__")) goto error; /* Records the results of the analysis in the symbol table entry */ if (!update_symbols(ste->ste_symbols, scopes, bound, newfree, @@ -1034,6 +1051,11 @@ if (!symtable_enter_block(st, s->v.ClassDef.name, ClassBlock, (void *)s, s->lineno)) return 0; + if (!GET_IDENTIFIER(__class__) || + !symtable_add_def(st, __class__, DEF_LOCAL)) { + symtable_exit_block(st, s); + return 0; + } tmp = st->st_private; st->st_private = s->v.ClassDef.name; VISIT_SEQ_IN_BLOCK(st, stmt, s->v.ClassDef.body, s); @@ -1301,6 +1323,14 @@ if (!symtable_add_def(st, e->v.Name.id, e->v.Name.ctx == Load ? USE : DEF_LOCAL)) return 0; + /* Special-case super: it counts as a use of __class__ */ + if (e->v.Name.ctx == Load && + st->st_cur->ste_type == FunctionBlock && + !strcmp(PyString_AS_STRING(e->v.Name.id), "super")) { + if (!GET_IDENTIFIER(__class__) || + !symtable_add_def(st, __class__, USE)) + return 0; + } break; /* child nodes of List and Tuple will have expr_context set */ case List_kind: From python-3000-checkins at python.org Mon Jun 11 23:38:58 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Mon, 11 Jun 2007 23:38:58 +0200 (CEST) Subject: [Python-3000-checkins] r55915 - in python/branches/py3k-struni/Lib: distutils/command/bdist_wininst.py idlelib/PyParse.py lib-tk/Tkinter.py test/test_cfgparser.py test/test_descr.py test/test_iter.py test/test_pprint.py test/test_set.py xml/dom/minicompat.py Message-ID: <20070611213858.240601E4002@bag.python.org> Author: walter.doerwald Date: Mon Jun 11 23:38:39 2007 New Revision: 55915 Modified: python/branches/py3k-struni/Lib/distutils/command/bdist_wininst.py python/branches/py3k-struni/Lib/idlelib/PyParse.py python/branches/py3k-struni/Lib/lib-tk/Tkinter.py python/branches/py3k-struni/Lib/test/test_cfgparser.py python/branches/py3k-struni/Lib/test/test_descr.py python/branches/py3k-struni/Lib/test/test_iter.py python/branches/py3k-struni/Lib/test/test_pprint.py python/branches/py3k-struni/Lib/test/test_set.py python/branches/py3k-struni/Lib/xml/dom/minicompat.py Log: Simplify various spots where: str() is called on something that already is a string or the existence of the str class is checked or a check is done for str twice. These all stem from the initial unicode->str replacement. Modified: python/branches/py3k-struni/Lib/distutils/command/bdist_wininst.py ============================================================================== --- python/branches/py3k-struni/Lib/distutils/command/bdist_wininst.py (original) +++ python/branches/py3k-struni/Lib/distutils/command/bdist_wininst.py Mon Jun 11 23:38:39 2007 @@ -246,13 +246,8 @@ file.write(bitmapdata) # Convert cfgdata from unicode to ascii, mbcs encoded - try: - str - except NameError: - pass - else: - if isinstance(cfgdata, str): - cfgdata = cfgdata.encode("mbcs") + if isinstance(cfgdata, str): + cfgdata = cfgdata.encode("mbcs") # Append the pre-install script cfgdata = cfgdata + "\0" Modified: python/branches/py3k-struni/Lib/idlelib/PyParse.py ============================================================================== --- python/branches/py3k-struni/Lib/idlelib/PyParse.py (original) +++ python/branches/py3k-struni/Lib/idlelib/PyParse.py Mon Jun 11 23:38:39 2007 @@ -104,33 +104,28 @@ _tran = ''.join(_tran) del ch -try: - UnicodeType = type(str("")) -except NameError: - UnicodeType = None - class Parser: def __init__(self, indentwidth, tabwidth): self.indentwidth = indentwidth self.tabwidth = tabwidth - def set_str(self, str): - assert len(str) == 0 or str[-1] == '\n' - if type(str) is UnicodeType: + def set_str(self, s): + assert len(s) == 0 or s[-1] == '\n' + if isinstance(s, str): # The parse functions have no idea what to do with Unicode, so # replace all Unicode characters with "x". This is "safe" # so long as the only characters germane to parsing the structure # of Python are 7-bit ASCII. It's *necessary* because Unicode # strings don't have a .translate() method that supports # deletechars. - uniphooey = str + uniphooey = s str = [] - push = str.append + push = s.append for raw in map(ord, uniphooey): push(raw < 127 and chr(raw) or "x") - str = "".join(str) - self.str = str + s = "".join(s) + self.str = s self.study_level = 0 # Return index of a good place to begin parsing, as close to the Modified: python/branches/py3k-struni/Lib/lib-tk/Tkinter.py ============================================================================== --- python/branches/py3k-struni/Lib/lib-tk/Tkinter.py (original) +++ python/branches/py3k-struni/Lib/lib-tk/Tkinter.py Mon Jun 11 23:38:39 2007 @@ -3734,11 +3734,7 @@ root = Tk() text = "This is Tcl/Tk version %s" % TclVersion if TclVersion >= 8.1: - try: - text = text + str("\nThis should be a cedilla: \347", - "iso-8859-1") - except NameError: - pass # no unicode support + text += "\nThis should be a cedilla: \xe7" label = Label(root, text=text) label.pack() test = Button(root, text="Click me!", Modified: python/branches/py3k-struni/Lib/test/test_cfgparser.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_cfgparser.py (original) +++ python/branches/py3k-struni/Lib/test/test_cfgparser.py Mon Jun 11 23:38:39 2007 @@ -247,13 +247,8 @@ cf.set("sect", "option1", mystr("splat")) cf.set("sect", "option2", "splat") cf.set("sect", "option2", mystr("splat")) - try: - str - except NameError: - pass - else: - cf.set("sect", "option1", str("splat")) - cf.set("sect", "option2", str("splat")) + cf.set("sect", "option1", "splat") + cf.set("sect", "option2", "splat") def test_read_returns_file_list(self): file1 = test_support.findfile("cfgparser.1") Modified: python/branches/py3k-struni/Lib/test/test_descr.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_descr.py (original) +++ python/branches/py3k-struni/Lib/test/test_descr.py Mon Jun 11 23:38:39 2007 @@ -265,7 +265,7 @@ del junk # Just make sure these don't blow up! - for arg in 2, 2, 2j, 2e0, [2], "2", "2", (2,), {2:2}, type, test_dir: + for arg in 2, 2, 2j, 2e0, [2], "2", b"2", (2,), {2:2}, type, test_dir: dir(arg) # Test dir on custom classes. Since these have object as a @@ -1117,34 +1117,29 @@ vereq(c.abc, 5) # Test unicode slot names + # Test a single unicode string is not expanded as a sequence. + class C(object): + __slots__ = "abc" + c = C() + c.abc = 5 + vereq(c.abc, 5) + + # _unicode_to_string used to modify slots in certain circumstances + slots = ("foo", "bar") + class C(object): + __slots__ = slots + x = C() + x.foo = 5 + vereq(x.foo, 5) + veris(type(slots[0]), str) + # this used to leak references try: - str - except NameError: + class C(object): + __slots__ = [chr(128)] + except (TypeError, UnicodeEncodeError): pass else: - # Test a single unicode string is not expanded as a sequence. - class C(object): - __slots__ = str("abc") - c = C() - c.abc = 5 - vereq(c.abc, 5) - - # _unicode_to_string used to modify slots in certain circumstances - slots = (str("foo"), str("bar")) - class C(object): - __slots__ = slots - x = C() - x.foo = 5 - vereq(x.foo, 5) - veris(type(slots[0]), str) - # this used to leak references - try: - class C(object): - __slots__ = [chr(128)] - except (TypeError, UnicodeEncodeError): - pass - else: - raise TestFailed, "[unichr(128)] slots not caught" + raise TestFailed, "[unichr(128)] slots not caught" # Test leaks class Counted(object): @@ -2693,14 +2688,8 @@ __slots__ = ["a", "b"] class H(object): __slots__ = ["b", "a"] - try: - str - except NameError: - class I(object): - __slots__ = ["a", "b"] - else: - class I(object): - __slots__ = [str("a"), str("b")] + class I(object): + __slots__ = ["a", "b"] class J(object): __slots__ = ["c", "b"] class K(object): Modified: python/branches/py3k-struni/Lib/test/test_iter.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_iter.py (original) +++ python/branches/py3k-struni/Lib/test/test_iter.py Mon Jun 11 23:38:39 2007 @@ -526,7 +526,7 @@ # and pass that on to unicode.join(). try: got = " - ".join(OhPhooey(f)) - self.assertEqual(got, str("a\n - b\n - fooled you! - c\n")) + self.assertEqual(got, "a\n - b\n - fooled you! - c\n") finally: f.close() try: Modified: python/branches/py3k-struni/Lib/test/test_pprint.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_pprint.py (original) +++ python/branches/py3k-struni/Lib/test/test_pprint.py Mon Jun 11 23:38:39 2007 @@ -2,12 +2,6 @@ import test.test_support import unittest -try: - uni = str -except NameError: - def uni(x): - return x - # list, tuple and dict subclasses that do or don't overwrite __repr__ class list2(list): pass @@ -41,7 +35,7 @@ # Verify .isrecursive() and .isreadable() w/o recursion verify = self.assert_ pp = pprint.PrettyPrinter() - for safe in (2, 2.0, 2j, "abc", [3], (2,2), {3: 3}, uni("yaddayadda"), + for safe in (2, 2.0, 2j, "abc", [3], (2,2), {3: 3}, "yaddayadda", self.a, self.b): # module-level convenience functions verify(not pprint.isrecursive(safe), @@ -114,12 +108,12 @@ # multiple lines. For that reason, dicts with more than one element # aren't tested here. verify = self.assert_ - for simple in (0, 0, 0+0j, 0.0, "", uni(""), + for simple in (0, 0, 0+0j, 0.0, "", b"", (), tuple2(), tuple3(), [], list2(), list3(), {}, dict2(), dict3(), verify, pprint, - -6, -6, -6-6j, -1.5, "x", uni("x"), (3,), [3], {3: 6}, + -6, -6, -6-6j, -1.5, "x", b"x", (3,), [3], {3: 6}, (1,2), [3,4], {5: 6, 7: 8}, tuple2((1,2)), tuple3((1,2)), tuple3(range(100)), [3,4], list2([3,4]), list3([3,4]), list3(range(100)), Modified: python/branches/py3k-struni/Lib/test/test_set.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_set.py (original) +++ python/branches/py3k-struni/Lib/test/test_set.py Mon Jun 11 23:38:39 2007 @@ -72,7 +72,7 @@ self.assertEqual(type(u), self.thetype) self.assertRaises(PassThru, self.s.union, check_pass_thru()) self.assertRaises(TypeError, self.s.union, [[]]) - for C in set, frozenset, dict.fromkeys, str, str, list, tuple: + for C in set, frozenset, dict.fromkeys, str, str8, list, tuple: self.assertEqual(self.thetype('abcba').union(C('cdc')), set('abcd')) self.assertEqual(self.thetype('abcba').union(C('efgfe')), set('abcefg')) self.assertEqual(self.thetype('abcba').union(C('ccb')), set('abc')) @@ -96,7 +96,7 @@ self.assertEqual(self.s, self.thetype(self.word)) self.assertEqual(type(i), self.thetype) self.assertRaises(PassThru, self.s.intersection, check_pass_thru()) - for C in set, frozenset, dict.fromkeys, str, str, list, tuple: + for C in set, frozenset, dict.fromkeys, str, str8, list, tuple: self.assertEqual(self.thetype('abcba').intersection(C('cdc')), set('cc')) self.assertEqual(self.thetype('abcba').intersection(C('efgfe')), set('')) self.assertEqual(self.thetype('abcba').intersection(C('ccb')), set('bc')) @@ -121,7 +121,7 @@ self.assertEqual(type(i), self.thetype) self.assertRaises(PassThru, self.s.difference, check_pass_thru()) self.assertRaises(TypeError, self.s.difference, [[]]) - for C in set, frozenset, dict.fromkeys, str, str, list, tuple: + for C in set, frozenset, dict.fromkeys, str, str8, list, tuple: self.assertEqual(self.thetype('abcba').difference(C('cdc')), set('ab')) self.assertEqual(self.thetype('abcba').difference(C('efgfe')), set('abc')) self.assertEqual(self.thetype('abcba').difference(C('ccb')), set('a')) @@ -146,7 +146,7 @@ self.assertEqual(type(i), self.thetype) self.assertRaises(PassThru, self.s.symmetric_difference, check_pass_thru()) self.assertRaises(TypeError, self.s.symmetric_difference, [[]]) - for C in set, frozenset, dict.fromkeys, str, str, list, tuple: + for C in set, frozenset, dict.fromkeys, str, str8, list, tuple: self.assertEqual(self.thetype('abcba').symmetric_difference(C('cdc')), set('abd')) self.assertEqual(self.thetype('abcba').symmetric_difference(C('efgfe')), set('abcefg')) self.assertEqual(self.thetype('abcba').symmetric_difference(C('ccb')), set('a')) @@ -390,7 +390,7 @@ self.assertRaises(PassThru, self.s.update, check_pass_thru()) self.assertRaises(TypeError, self.s.update, [[]]) for p, q in (('cdc', 'abcd'), ('efgfe', 'abcefg'), ('ccb', 'abc'), ('ef', 'abcef')): - for C in set, frozenset, dict.fromkeys, str, str, list, tuple: + for C in set, frozenset, dict.fromkeys, str, str8, list, tuple: s = self.thetype('abcba') self.assertEqual(s.update(C(p)), None) self.assertEqual(s, set(q)) @@ -411,7 +411,7 @@ self.assertRaises(PassThru, self.s.intersection_update, check_pass_thru()) self.assertRaises(TypeError, self.s.intersection_update, [[]]) for p, q in (('cdc', 'c'), ('efgfe', ''), ('ccb', 'bc'), ('ef', '')): - for C in set, frozenset, dict.fromkeys, str, str, list, tuple: + for C in set, frozenset, dict.fromkeys, str, str8, list, tuple: s = self.thetype('abcba') self.assertEqual(s.intersection_update(C(p)), None) self.assertEqual(s, set(q)) @@ -436,7 +436,7 @@ self.assertRaises(TypeError, self.s.difference_update, [[]]) self.assertRaises(TypeError, self.s.symmetric_difference_update, [[]]) for p, q in (('cdc', 'ab'), ('efgfe', 'abc'), ('ccb', 'a'), ('ef', 'abc')): - for C in set, frozenset, dict.fromkeys, str, str, list, tuple: + for C in set, frozenset, dict.fromkeys, str, str8, list, tuple: s = self.thetype('abcba') self.assertEqual(s.difference_update(C(p)), None) self.assertEqual(s, set(q)) @@ -460,7 +460,7 @@ self.assertRaises(PassThru, self.s.symmetric_difference_update, check_pass_thru()) self.assertRaises(TypeError, self.s.symmetric_difference_update, [[]]) for p, q in (('cdc', 'abd'), ('efgfe', 'abcefg'), ('ccb', 'a'), ('ef', 'abcef')): - for C in set, frozenset, dict.fromkeys, str, str, list, tuple: + for C in set, frozenset, dict.fromkeys, str, str8, list, tuple: s = self.thetype('abcba') self.assertEqual(s.symmetric_difference_update(C(p)), None) self.assertEqual(s, set(q)) Modified: python/branches/py3k-struni/Lib/xml/dom/minicompat.py ============================================================================== --- python/branches/py3k-struni/Lib/xml/dom/minicompat.py (original) +++ python/branches/py3k-struni/Lib/xml/dom/minicompat.py Mon Jun 11 23:38:39 2007 @@ -40,12 +40,7 @@ import xml.dom -try: - str -except NameError: - StringTypes = type(''), -else: - StringTypes = type(''), type(str('')) +StringTypes = (str,) class NodeList(list): From python-3000-checkins at python.org Mon Jun 11 23:49:05 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Mon, 11 Jun 2007 23:49:05 +0200 (CEST) Subject: [Python-3000-checkins] r55916 - python/branches/py3k-struni/Modules/binascii.c Message-ID: <20070611214905.8C6AE1E4002@bag.python.org> Author: walter.doerwald Date: Mon Jun 11 23:48:58 2007 New Revision: 55916 Modified: python/branches/py3k-struni/Modules/binascii.c Log: Remove unused code. Modified: python/branches/py3k-struni/Modules/binascii.c ============================================================================== --- python/branches/py3k-struni/Modules/binascii.c (original) +++ python/branches/py3k-struni/Modules/binascii.c Mon Jun 11 23:48:58 2007 @@ -956,10 +956,6 @@ retbuf[j++] = c; } return retval; - - finally: - Py_DECREF(retval); - return NULL; } PyDoc_STRVAR(doc_hexlify, From python-3000-checkins at python.org Tue Jun 12 02:25:13 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Tue, 12 Jun 2007 02:25:13 +0200 (CEST) Subject: [Python-3000-checkins] r55917 - python/branches/py3k-struni/Lib/modulefinder.py Message-ID: <20070612002513.8DFB51E4009@bag.python.org> Author: guido.van.rossum Date: Tue Jun 12 02:25:08 2007 New Revision: 55917 Modified: python/branches/py3k-struni/Lib/modulefinder.py Log: Some quick fixes of code that was sorting dict.keys() etc. Modified: python/branches/py3k-struni/Lib/modulefinder.py ============================================================================== --- python/branches/py3k-struni/Lib/modulefinder.py (original) +++ python/branches/py3k-struni/Lib/modulefinder.py Tue Jun 12 02:25:08 2007 @@ -487,8 +487,7 @@ print(" %-25s %s" % ("Name", "File")) print(" %-25s %s" % ("----", "----")) # Print modules found - keys = self.modules.keys() - keys.sort() + keys = sorted(self.modules.keys()) for key in keys: m = self.modules[key] if m.__path__: @@ -503,8 +502,7 @@ print() print("Missing modules:") for name in missing: - mods = self.badmodules[name].keys() - mods.sort() + mods = sorted(self.badmodules[name].keys()) print("?", name, "imported from", ', '.join(mods)) # Print modules that may be missing, but then again, maybe not... if maybe: @@ -512,8 +510,7 @@ print("Submodules thay appear to be missing, but could also be", end=' ') print("global names in the parent package:") for name in maybe: - mods = self.badmodules[name].keys() - mods.sort() + mods = sorted(self.badmodules[name].keys()) print("?", name, "imported from", ', '.join(mods)) def any_missing(self): From python-3000-checkins at python.org Tue Jun 12 02:25:54 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Tue, 12 Jun 2007 02:25:54 +0200 (CEST) Subject: [Python-3000-checkins] r55918 - python/branches/py3k-struni/Python/frozen.c Message-ID: <20070612002554.87E321E4012@bag.python.org> Author: guido.van.rossum Date: Tue Jun 12 02:25:52 2007 New Revision: 55918 Modified: python/branches/py3k-struni/Python/frozen.c Log: Update the frozen bytecode for __hello__. Modified: python/branches/py3k-struni/Python/frozen.c ============================================================================== --- python/branches/py3k-struni/Python/frozen.c (original) +++ python/branches/py3k-struni/Python/frozen.c Tue Jun 12 02:25:52 2007 @@ -14,11 +14,11 @@ static unsigned char M___hello__[] = { 99,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0, 0,64,0,0,0,115,14,0,0,0,101,0,0,100,0,0, - 131,1,0,1,100,1,0,83,40,2,0,0,0,115,14,0, + 131,1,0,1,100,1,0,83,40,2,0,0,0,117,14,0, 0,0,72,101,108,108,111,32,119,111,114,108,100,46,46,46, - 78,40,1,0,0,0,116,5,0,0,0,112,114,105,110,116, + 78,40,1,0,0,0,117,5,0,0,0,112,114,105,110,116, 40,0,0,0,0,40,0,0,0,0,40,0,0,0,0,115, - 8,0,0,0,104,101,108,108,111,46,112,121,115,8,0,0, + 8,0,0,0,104,101,108,108,111,46,112,121,117,8,0,0, 0,60,109,111,100,117,108,101,62,1,0,0,0,115,0,0, 0,0, }; From python-3000-checkins at python.org Tue Jun 12 02:28:39 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Tue, 12 Jun 2007 02:28:39 +0200 (CEST) Subject: [Python-3000-checkins] r55919 - in python/branches/py3k-struni: Objects/fileobject.c Python/ast.c Tools/freeze/bkfile.py Tools/freeze/freeze.py Tools/freeze/makefreeze.py Tools/freeze/makemakefile.py Tools/freeze/parsesetup.py runtests.sh Message-ID: <20070612002839.1E6BE1E4002@bag.python.org> Author: guido.van.rossum Date: Tue Jun 12 02:28:30 2007 New Revision: 55919 Modified: python/branches/py3k-struni/Objects/fileobject.c python/branches/py3k-struni/Python/ast.c python/branches/py3k-struni/Tools/freeze/bkfile.py python/branches/py3k-struni/Tools/freeze/freeze.py python/branches/py3k-struni/Tools/freeze/makefreeze.py python/branches/py3k-struni/Tools/freeze/makemakefile.py python/branches/py3k-struni/Tools/freeze/parsesetup.py python/branches/py3k-struni/runtests.sh Log: Minimal changes to make the "freeze" tool work again. There are other issues left, but these were basics (e.g. keys().sort()). Modified: python/branches/py3k-struni/Objects/fileobject.c ============================================================================== --- python/branches/py3k-struni/Objects/fileobject.c (original) +++ python/branches/py3k-struni/Objects/fileobject.c Tue Jun 12 02:28:30 2007 @@ -265,24 +265,19 @@ PyObject * PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE *)) { - PyErr_SetString(PyExc_SystemError, - "attempt to create old file from FILE *"); - return NULL; -#if 0 - PyFileObject *f = (PyFileObject *)PyFile_Type.tp_new(&PyFile_Type, - NULL, NULL); - if (f != NULL) { - PyObject *o_name = PyString_FromString(name); - if (o_name == NULL) - return NULL; - if (fill_file_fields(f, fp, o_name, mode, close) == NULL) { - Py_DECREF(f); - f = NULL; - } - Py_DECREF(o_name); + PyObject *io = NULL, *stream = NULL; + + io = PyImport_ImportModule("io"); + if (io == NULL) + return NULL; + stream = PyObject_CallMethod(io, "open", "ss", name, mode); + if (stream == NULL) { + Py_XDECREF(io); + return NULL; } - return (PyObject *) f; -#endif + if (close != NULL) + close(fp); + return stream; } PyObject * Modified: python/branches/py3k-struni/Python/ast.c ============================================================================== --- python/branches/py3k-struni/Python/ast.c (original) +++ python/branches/py3k-struni/Python/ast.c Tue Jun 12 02:28:30 2007 @@ -193,8 +193,11 @@ if (flags && flags->cf_flags & PyCF_SOURCE_IS_UTF8) { c.c_encoding = "utf-8"; if (TYPE(n) == encoding_decl) { +#if 0 ast_error(n, "encoding declaration in Unicode string"); goto error; +#endif + n = CHILD(n, 0); } } else if (TYPE(n) == encoding_decl) { c.c_encoding = STR(n); Modified: python/branches/py3k-struni/Tools/freeze/bkfile.py ============================================================================== --- python/branches/py3k-struni/Tools/freeze/bkfile.py (original) +++ python/branches/py3k-struni/Tools/freeze/bkfile.py Tue Jun 12 02:28:30 2007 @@ -21,7 +21,10 @@ self.mode = self.__file.mode self.name = self.__file.name self.read = self.__file.read - self.readinto = self.__file.readinto + try: + self.readinto = self.__file.readinto + except AttributeError: + pass self.readline = self.__file.readline self.readlines = self.__file.readlines self.seek = self.__file.seek Modified: python/branches/py3k-struni/Tools/freeze/freeze.py ============================================================================== --- python/branches/py3k-struni/Tools/freeze/freeze.py (original) +++ python/branches/py3k-struni/Tools/freeze/freeze.py Tue Jun 12 02:28:30 2007 @@ -386,8 +386,7 @@ # look for unfrozen modules (builtin and of unknown origin) builtins = [] unknown = [] - mods = dict.keys() - mods.sort() + mods = sorted(dict.keys()) for mod in mods: if dict[mod].__code__: continue Modified: python/branches/py3k-struni/Tools/freeze/makefreeze.py ============================================================================== --- python/branches/py3k-struni/Tools/freeze/makefreeze.py (original) +++ python/branches/py3k-struni/Tools/freeze/makefreeze.py Tue Jun 12 02:28:30 2007 @@ -33,8 +33,7 @@ if entry_point is None: entry_point = default_entry_point done = [] files = [] - mods = dict.keys() - mods.sort() + mods = sorted(dict.keys()) for mod in mods: m = dict[mod] mangled = "__".join(mod.split(".")) @@ -81,8 +80,8 @@ outfp.write('unsigned char M_%s[] = {' % mod) for i in range(0, len(str), 16): outfp.write('\n\t') - for c in str[i:i+16]: - outfp.write('%d,' % ord(c)) + for c in bytes(str[i:i+16]): + outfp.write('%d,' % c) outfp.write('\n};\n') ## def writecode(outfp, mod, str): Modified: python/branches/py3k-struni/Tools/freeze/makemakefile.py ============================================================================== --- python/branches/py3k-struni/Tools/freeze/makemakefile.py (original) +++ python/branches/py3k-struni/Tools/freeze/makemakefile.py Tue Jun 12 02:28:30 2007 @@ -5,8 +5,7 @@ def makemakefile(outfp, makevars, files, target): outfp.write("# Makefile generated by freeze.py script\n\n") - keys = makevars.keys() - keys.sort() + keys = sorted(makevars.keys()) for key in keys: outfp.write("%s=%s\n" % (key, makevars[key])) outfp.write("\nall: %s\n\n" % target) Modified: python/branches/py3k-struni/Tools/freeze/parsesetup.py ============================================================================== --- python/branches/py3k-struni/Tools/freeze/parsesetup.py (original) +++ python/branches/py3k-struni/Tools/freeze/parsesetup.py Tue Jun 12 02:28:30 2007 @@ -102,8 +102,7 @@ print('(name must begin with "Makefile" or "Setup")') def prdict(d): - keys = d.keys() - keys.sort() + keys = sorted(d.keys()) for key in keys: value = d[key] print("%-15s" % key, str(value)) Modified: python/branches/py3k-struni/runtests.sh ============================================================================== --- python/branches/py3k-struni/runtests.sh (original) +++ python/branches/py3k-struni/runtests.sh Tue Jun 12 02:28:30 2007 @@ -24,6 +24,9 @@ >BAD >SKIPPED +# The -uall flag (edit this file to change). +UALL="-uall" + # Compute the list of tests to run. case $# in 0) @@ -38,7 +41,7 @@ for T in $TESTS do echo -n $T - if $PYTHON Lib/test/regrtest.py -uall $T >OUT/$T.out 2>&1 + if $PYTHON Lib/test/regrtest.py $UALL $T >OUT/$T.out 2>&1 then if grep -q "1 test skipped:" OUT/$T.out then @@ -51,5 +54,7 @@ else echo " BAD" echo $T >>BAD + echo "---------- Re-running test in verbose mode ----------" >>OUT/$T + $PYTHON Lib/test/regrtest.py -v $UALL $T >>OUT/$T.out 2>&1 fi done From guido at python.org Tue Jun 12 02:34:15 2007 From: guido at python.org (Guido van Rossum) Date: Mon, 11 Jun 2007 17:34:15 -0700 Subject: [Python-3000-checkins] r55919 - in python/branches/py3k-struni: Objects/fileobject.c Python/ast.c Tools/freeze/bkfile.py Tools/freeze/freeze.py Tools/freeze/makefreeze.py Tools/freeze/makemakefile.py Tools/freeze/parsesetup.py runtests.sh In-Reply-To: <20070612002839.1E6BE1E4002@bag.python.org> References: <20070612002839.1E6BE1E4002@bag.python.org> Message-ID: This submitted two things I meant to submit separately; here are the comments: fileobject.c: make PyFile_FromFile() work (more or less) by calling io.open() and closing the input file. ast.c: When the input is known to be UTF-8, ignore an encoding declaration. (This was a hack to make the freeze tool "work" -- unclear what else to do about this.) On 6/11/07, guido.van.rossum wrote: > Author: guido.van.rossum > Date: Tue Jun 12 02:28:30 2007 > New Revision: 55919 > > Modified: > python/branches/py3k-struni/Objects/fileobject.c > python/branches/py3k-struni/Python/ast.c > python/branches/py3k-struni/Tools/freeze/bkfile.py > python/branches/py3k-struni/Tools/freeze/freeze.py > python/branches/py3k-struni/Tools/freeze/makefreeze.py > python/branches/py3k-struni/Tools/freeze/makemakefile.py > python/branches/py3k-struni/Tools/freeze/parsesetup.py > python/branches/py3k-struni/runtests.sh > Log: > Minimal changes to make the "freeze" tool work again. > There are other issues left, but these were basics (e.g. keys().sort()). > > > Modified: python/branches/py3k-struni/Objects/fileobject.c > ============================================================================== > --- python/branches/py3k-struni/Objects/fileobject.c (original) > +++ python/branches/py3k-struni/Objects/fileobject.c Tue Jun 12 02:28:30 2007 > @@ -265,24 +265,19 @@ > PyObject * > PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE *)) > { > - PyErr_SetString(PyExc_SystemError, > - "attempt to create old file from FILE *"); > - return NULL; > -#if 0 > - PyFileObject *f = (PyFileObject *)PyFile_Type.tp_new(&PyFile_Type, > - NULL, NULL); > - if (f != NULL) { > - PyObject *o_name = PyString_FromString(name); > - if (o_name == NULL) > - return NULL; > - if (fill_file_fields(f, fp, o_name, mode, close) == NULL) { > - Py_DECREF(f); > - f = NULL; > - } > - Py_DECREF(o_name); > + PyObject *io = NULL, *stream = NULL; > + > + io = PyImport_ImportModule("io"); > + if (io == NULL) > + return NULL; > + stream = PyObject_CallMethod(io, "open", "ss", name, mode); > + if (stream == NULL) { > + Py_XDECREF(io); > + return NULL; > } > - return (PyObject *) f; > -#endif > + if (close != NULL) > + close(fp); > + return stream; > } > > PyObject * > > Modified: python/branches/py3k-struni/Python/ast.c > ============================================================================== > --- python/branches/py3k-struni/Python/ast.c (original) > +++ python/branches/py3k-struni/Python/ast.c Tue Jun 12 02:28:30 2007 > @@ -193,8 +193,11 @@ > if (flags && flags->cf_flags & PyCF_SOURCE_IS_UTF8) { > c.c_encoding = "utf-8"; > if (TYPE(n) == encoding_decl) { > +#if 0 > ast_error(n, "encoding declaration in Unicode string"); > goto error; > +#endif > + n = CHILD(n, 0); > } > } else if (TYPE(n) == encoding_decl) { > c.c_encoding = STR(n); > > Modified: python/branches/py3k-struni/Tools/freeze/bkfile.py > ============================================================================== > --- python/branches/py3k-struni/Tools/freeze/bkfile.py (original) > +++ python/branches/py3k-struni/Tools/freeze/bkfile.py Tue Jun 12 02:28:30 2007 > @@ -21,7 +21,10 @@ > self.mode = self.__file.mode > self.name = self.__file.name > self.read = self.__file.read > - self.readinto = self.__file.readinto > + try: > + self.readinto = self.__file.readinto > + except AttributeError: > + pass > self.readline = self.__file.readline > self.readlines = self.__file.readlines > self.seek = self.__file.seek > > Modified: python/branches/py3k-struni/Tools/freeze/freeze.py > ============================================================================== > --- python/branches/py3k-struni/Tools/freeze/freeze.py (original) > +++ python/branches/py3k-struni/Tools/freeze/freeze.py Tue Jun 12 02:28:30 2007 > @@ -386,8 +386,7 @@ > # look for unfrozen modules (builtin and of unknown origin) > builtins = [] > unknown = [] > - mods = dict.keys() > - mods.sort() > + mods = sorted(dict.keys()) > for mod in mods: > if dict[mod].__code__: > continue > > Modified: python/branches/py3k-struni/Tools/freeze/makefreeze.py > ============================================================================== > --- python/branches/py3k-struni/Tools/freeze/makefreeze.py (original) > +++ python/branches/py3k-struni/Tools/freeze/makefreeze.py Tue Jun 12 02:28:30 2007 > @@ -33,8 +33,7 @@ > if entry_point is None: entry_point = default_entry_point > done = [] > files = [] > - mods = dict.keys() > - mods.sort() > + mods = sorted(dict.keys()) > for mod in mods: > m = dict[mod] > mangled = "__".join(mod.split(".")) > @@ -81,8 +80,8 @@ > outfp.write('unsigned char M_%s[] = {' % mod) > for i in range(0, len(str), 16): > outfp.write('\n\t') > - for c in str[i:i+16]: > - outfp.write('%d,' % ord(c)) > + for c in bytes(str[i:i+16]): > + outfp.write('%d,' % c) > outfp.write('\n};\n') > > ## def writecode(outfp, mod, str): > > Modified: python/branches/py3k-struni/Tools/freeze/makemakefile.py > ============================================================================== > --- python/branches/py3k-struni/Tools/freeze/makemakefile.py (original) > +++ python/branches/py3k-struni/Tools/freeze/makemakefile.py Tue Jun 12 02:28:30 2007 > @@ -5,8 +5,7 @@ > def makemakefile(outfp, makevars, files, target): > outfp.write("# Makefile generated by freeze.py script\n\n") > > - keys = makevars.keys() > - keys.sort() > + keys = sorted(makevars.keys()) > for key in keys: > outfp.write("%s=%s\n" % (key, makevars[key])) > outfp.write("\nall: %s\n\n" % target) > > Modified: python/branches/py3k-struni/Tools/freeze/parsesetup.py > ============================================================================== > --- python/branches/py3k-struni/Tools/freeze/parsesetup.py (original) > +++ python/branches/py3k-struni/Tools/freeze/parsesetup.py Tue Jun 12 02:28:30 2007 > @@ -102,8 +102,7 @@ > print('(name must begin with "Makefile" or "Setup")') > > def prdict(d): > - keys = d.keys() > - keys.sort() > + keys = sorted(d.keys()) > for key in keys: > value = d[key] > print("%-15s" % key, str(value)) > > Modified: python/branches/py3k-struni/runtests.sh > ============================================================================== > --- python/branches/py3k-struni/runtests.sh (original) > +++ python/branches/py3k-struni/runtests.sh Tue Jun 12 02:28:30 2007 > @@ -24,6 +24,9 @@ > >BAD > >SKIPPED > > +# The -uall flag (edit this file to change). > +UALL="-uall" > + > # Compute the list of tests to run. > case $# in > 0) > @@ -38,7 +41,7 @@ > for T in $TESTS > do > echo -n $T > - if $PYTHON Lib/test/regrtest.py -uall $T >OUT/$T.out 2>&1 > + if $PYTHON Lib/test/regrtest.py $UALL $T >OUT/$T.out 2>&1 > then > if grep -q "1 test skipped:" OUT/$T.out > then > @@ -51,5 +54,7 @@ > else > echo " BAD" > echo $T >>BAD > + echo "---------- Re-running test in verbose mode ----------" >>OUT/$T > + $PYTHON Lib/test/regrtest.py -v $UALL $T >>OUT/$T.out 2>&1 > fi > done > _______________________________________________ > 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 Tue Jun 12 02:41:05 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Tue, 12 Jun 2007 02:41:05 +0200 (CEST) Subject: [Python-3000-checkins] r55920 - python/branches/py3k-struni/Lib/test/test_frozen.py Message-ID: <20070612004105.716A11E4012@bag.python.org> Author: guido.van.rossum Date: Tue Jun 12 02:41:02 2007 New Revision: 55920 Modified: python/branches/py3k-struni/Lib/test/test_frozen.py Log: Seems this test is just fine. It fails because __phello__.spam doesn't exist, but that seems a separate issue. Modified: python/branches/py3k-struni/Lib/test/test_frozen.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_frozen.py (original) +++ python/branches/py3k-struni/Lib/test/test_frozen.py Tue Jun 12 02:41:02 2007 @@ -10,8 +10,6 @@ from test.test_support import TestFailed import sys, os -raise TestFailed, "test currently causes assertion in debug mode" - try: import __hello__ except ImportError as x: From python-3000-checkins at python.org Tue Jun 12 02:41:39 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Tue, 12 Jun 2007 02:41:39 +0200 (CEST) Subject: [Python-3000-checkins] r55921 - python/branches/py3k-struni/Lib/test/test_frozen.py Message-ID: <20070612004139.1BC8A1E400C@bag.python.org> Author: guido.van.rossum Date: Tue Jun 12 02:41:35 2007 New Revision: 55921 Modified: python/branches/py3k-struni/Lib/test/test_frozen.py Log: Duh. Delete the outdated comment too. Modified: python/branches/py3k-struni/Lib/test/test_frozen.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_frozen.py (original) +++ python/branches/py3k-struni/Lib/test/test_frozen.py Tue Jun 12 02:41:35 2007 @@ -1,11 +1,4 @@ # Test the frozen module defined in frozen.c. -# Currently test_frozen fails: -# Implementing pep3102(keyword only argument) needs changes in -# code object, which needs modification to marshal. -# However, to regenerate hard-coded marshal data in frozen.c, -# we need to run Tools/freeze/freeze.py, which currently doesn't work -# because Lib/modulefinder.py cannot handle relative module import -# This test will keep failing until Lib/modulefinder.py is fixed from test.test_support import TestFailed import sys, os From nnorwitz at gmail.com Tue Jun 12 02:47:59 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Mon, 11 Jun 2007 20:47:59 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures basics (1) Message-ID: <20070612004759.GA22120@python.psfb.org> test_grammar test_opcodes test_dict test_builtin test_exceptions test test_exceptions failed -- Traceback (most recent call last): File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 186, in testSettingException test_capi1() File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 155, in test_capi1 import _testcapi ImportError: No module named _testcapi test_types test_unittest test_doctest test_doctest2 test_StringIO test___all__ test___future__ test__locale test_abc test_aepack test_aepack skipped -- No module named aepack test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_buffer test_bufio test_bytes test_bz2 test_cProfile test_calendar test_call test_capi test_capi skipped -- No module named _testcapi test_cfgparser test_cgi test_charmapcodec test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_cn skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_hk test_codecmaps_hk skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_jp test_codecmaps_jp skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_kr test_codecmaps_kr skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_tw test_codecmaps_tw skipped -- Use of the `urlfetch' resource not enabled test_codecs test_codecs skipped -- No module named _testcapi test_codeop test_coding test_collections test_colorsys test_commands test_compare test_compile test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictviews test_difflib test_dircache test_dis test_distutils test_dl test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_ftplib test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getargs2 skipped -- No module named _testcapi test_getopt test_gettext test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imaplib test_imp test_import test_importhooks test_index test_inspect test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_keywordonlyarg test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_listcomps test_locale test_logging test_long test_long_future test_longexp test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_metaclass test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_normalization test_normalization skipped -- Use of the `urlfetch' resource not enabled test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [12978 refs] [12978 refs] [12978 refs] test_poplib test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [13862 refs] [13862 refs] test_random test_re test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sgmllib test_shelve test_shlex test_shutil test_signal test_site test_slice test_smtplib test_socket test_socket_ssl test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strptime test_struct test_structmembers test_structmembers skipped -- No module named _testcapi test_structseq test_subprocess [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [16239 refs] [13188 refs] [12972 refs] [12973 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] . [12972 refs] [12972 refs] this bit of output is from a test of stdout in a different process ... [12972 refs] [12972 refs] [13188 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_super test_symtable test_syntax test_sys [12972 refs] [12972 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [12974 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_tuple test_typechecks test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_unpack test_unpack_ex test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmlrpc test_xpickle test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zlib 285 tests OK. 1 test failed: test_exceptions 32 tests skipped: test_aepack test_applesingle test_bsddb3 test_capi test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_curses test_getargs2 test_ioctl test_linuxaudiodev test_macostools test_normalization test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socketserver test_startfile test_structmembers test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_getargs2 test_capi test_tcl test_ioctl test_structmembers test_codecs [628258 refs] From nnorwitz at gmail.com Tue Jun 12 02:53:42 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Mon, 11 Jun 2007 20:53:42 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures opt (1) Message-ID: <20070612005342.GA22828@python.psfb.org> test_grammar test_opcodes test_dict test_builtin test_exceptions test test_exceptions failed -- Traceback (most recent call last): File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 186, in testSettingException test_capi1() File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 155, in test_capi1 import _testcapi ImportError: No module named _testcapi test_types test_unittest test_doctest test_doctest2 test_StringIO test___all__ test___future__ test__locale test_abc test_aepack test_aepack skipped -- No module named aepack test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_buffer test_bufio test_bytes test_bz2 test_cProfile test_calendar test_call test_capi test_capi skipped -- No module named _testcapi test_cfgparser test_cgi test_charmapcodec test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_cn skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_hk test_codecmaps_hk skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_jp test_codecmaps_jp skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_kr test_codecmaps_kr skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_tw test_codecmaps_tw skipped -- Use of the `urlfetch' resource not enabled test_codecs test_codecs skipped -- No module named _testcapi test_codeop test_coding test_collections test_colorsys test_commands test_compare test_compile test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictviews test_difflib test_dircache test_dis test_distutils [16409 refs] test_dl test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_ftplib test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getargs2 skipped -- No module named _testcapi test_getopt test_gettext test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imaplib test_imp test_import test_importhooks test_index test_inspect test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_keywordonlyarg test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_listcomps test_locale test_logging test_long test_long_future test_longexp test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_metaclass test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_normalization test_normalization skipped -- Use of the `urlfetch' resource not enabled test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [12978 refs] [12978 refs] [12978 refs] test_poplib test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [13862 refs] [13862 refs] test_random test_re test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sgmllib test_shelve test_shlex test_shutil test_signal test_site test_slice test_smtplib test_socket test_socket_ssl test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strptime test_struct test_structmembers test_structmembers skipped -- No module named _testcapi test_structseq test_subprocess [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [16239 refs] [13188 refs] [12972 refs] [12973 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] . [12972 refs] [12972 refs] this bit of output is from a test of stdout in a different process ... [12972 refs] [12972 refs] [13188 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_super test_symtable test_syntax test_sys [12972 refs] [12972 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [12974 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_tuple test_typechecks test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_unpack test_unpack_ex test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmlrpc test_xpickle test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zlib 285 tests OK. 1 test failed: test_exceptions 32 tests skipped: test_aepack test_applesingle test_bsddb3 test_capi test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_curses test_getargs2 test_ioctl test_linuxaudiodev test_macostools test_normalization test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socketserver test_startfile test_structmembers test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_getargs2 test_capi test_tcl test_ioctl test_structmembers test_codecs [627453 refs] From nnorwitz at gmail.com Tue Jun 12 03:51:58 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Mon, 11 Jun 2007 21:51:58 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures refleak (1) Message-ID: <20070612015158.GA28323@python.psfb.org> test_threading_local leaked [0, -1, 1] references, sum=0 test_urllib2_localnet leaked [3, 3, 3] references, sum=9 From nnorwitz at gmail.com Tue Jun 12 04:03:12 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Mon, 11 Jun 2007 22:03:12 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures all (1) Message-ID: <20070612020312.GA30118@python.psfb.org> test_grammar test_opcodes test_dict test_builtin test_exceptions test test_exceptions failed -- Traceback (most recent call last): File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 186, in testSettingException test_capi1() File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 155, in test_capi1 import _testcapi ImportError: No module named _testcapi test_types test_unittest test_doctest test_doctest2 test_StringIO test___all__ test___future__ test__locale test_abc test_aepack test_aepack skipped -- No module named aepack test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb3 test_buffer test_bufio test_bytes test_bz2 test_cProfile test_calendar test_call test_capi test_capi skipped -- No module named _testcapi test_cfgparser test_cgi test_charmapcodec test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codecs skipped -- No module named _testcapi test_codeop test_coding test_collections test_colorsys test_commands test_compare test_compile test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictviews test_difflib test_dircache test_dis test_distutils test_dl test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_ftplib test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getargs2 skipped -- No module named _testcapi test_getopt test_gettext test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imaplib test_imp test_import test_importhooks test_index test_inspect test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_keywordonlyarg test_largefile test_list test_listcomps test_locale test_logging test_long test_long_future test_longexp test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_metaclass test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [12978 refs] [12978 refs] [12978 refs] test_poplib test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [13862 refs] [13862 refs] test_random test_re test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sgmllib test_shelve test_shlex test_shutil test_signal test_site test_slice test_smtplib test_socket test_socket_ssl test_socketserver test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strptime test_struct test_structmembers test_structmembers skipped -- No module named _testcapi test_structseq test_subprocess [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [16239 refs] [13188 refs] [12972 refs] [12973 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] . [12972 refs] [12972 refs] this bit of output is from a test of stdout in a different process ... [12972 refs] [12972 refs] [13188 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_super test_symtable test_syntax test_sys [12972 refs] [12972 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [12974 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_tokenize test_trace test_traceback test_tuple test_typechecks test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_unpack test_unpack_ex test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllibnet test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmlrpc test_xpickle test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zlib 296 tests OK. 1 test failed: test_exceptions 18 tests skipped: test_aepack test_applesingle test_capi test_codecs test_getargs2 test_ioctl test_macostools test_pep277 test_plistlib test_scriptpackages test_startfile test_structmembers test_sunaudiodev test_tcl test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_getargs2 test_capi test_tcl test_ioctl test_structmembers test_codecs [642237 refs] From python-3000-checkins at python.org Tue Jun 12 06:15:29 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Tue, 12 Jun 2007 06:15:29 +0200 (CEST) Subject: [Python-3000-checkins] r55923 - python/branches/p3yk/Lib/plat-mac/aepack.py Message-ID: <20070612041529.13B6E1E4002@bag.python.org> Author: guido.van.rossum Date: Tue Jun 12 06:15:24 2007 New Revision: 55923 Modified: python/branches/p3yk/Lib/plat-mac/aepack.py Log: I'm guessing this module broke when Neal ripped out the types module -- it used 'list' both as a local variable and as the built-in list type. Renamed the local variable since that was easier. Modified: python/branches/p3yk/Lib/plat-mac/aepack.py ============================================================================== --- python/branches/p3yk/Lib/plat-mac/aepack.py (original) +++ python/branches/p3yk/Lib/plat-mac/aepack.py Tue Jun 12 06:15:24 2007 @@ -100,10 +100,10 @@ data = data[2:] return AE.AECreateDesc('utxt', data) if isinstance(x, list): - list = AE.AECreateList('', 0) + lst = AE.AECreateList('', 0) for item in x: - list.AEPutDesc(0, pack(item)) - return list + lst.AEPutDesc(0, pack(item)) + return lst if isinstance(x, dict): record = AE.AECreateList('', 1) for key, value in x.items(): From python-3000-checkins at python.org Tue Jun 12 06:20:22 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Tue, 12 Jun 2007 06:20:22 +0200 (CEST) Subject: [Python-3000-checkins] r55924 - in python/branches/p3yk/Lib: _strptime.py abc.py ctypes/__init__.py ctypes/_endian.py ctypes/test/test_init.py distutils/tests/support.py plat-mac/plistlib.py random.py string.py test/list_tests.py test/test_array.py test/test_collections.py test/test_list.py test/test_super.py test/test_tuple.py test/test_unittest.py test/test_userlist.py test/test_weakref.py weakref.py Message-ID: <20070612042022.ED5221E4002@bag.python.org> Author: guido.van.rossum Date: Tue Jun 12 06:20:05 2007 New Revision: 55924 Modified: python/branches/p3yk/Lib/_strptime.py python/branches/p3yk/Lib/abc.py python/branches/p3yk/Lib/ctypes/__init__.py python/branches/p3yk/Lib/ctypes/_endian.py python/branches/p3yk/Lib/ctypes/test/test_init.py python/branches/p3yk/Lib/distutils/tests/support.py python/branches/p3yk/Lib/plat-mac/plistlib.py python/branches/p3yk/Lib/random.py python/branches/p3yk/Lib/string.py python/branches/p3yk/Lib/test/list_tests.py python/branches/p3yk/Lib/test/test_array.py python/branches/p3yk/Lib/test/test_collections.py python/branches/p3yk/Lib/test/test_list.py python/branches/p3yk/Lib/test/test_super.py python/branches/p3yk/Lib/test/test_tuple.py python/branches/p3yk/Lib/test/test_unittest.py python/branches/p3yk/Lib/test/test_userlist.py python/branches/p3yk/Lib/test/test_weakref.py python/branches/p3yk/Lib/weakref.py Log: Change all occurrences of super(, ) to super(). Seems to have worked, all the tests still pass. Exception: test_descr and test_descrtut, which have tons of these and are there to test the various usages. Modified: python/branches/p3yk/Lib/_strptime.py ============================================================================== --- python/branches/p3yk/Lib/_strptime.py (original) +++ python/branches/p3yk/Lib/_strptime.py Tue Jun 12 06:20:05 2007 @@ -186,7 +186,7 @@ self.locale_time = locale_time else: self.locale_time = LocaleTime() - base = super(TimeRE, self) + base = super() base.__init__({ # The " \d" part of the regex is to make %c from ANSI C work 'd': r"(?P3[0-1]|[1-2]\d|0[1-9]|[1-9]| [1-9])", Modified: python/branches/p3yk/Lib/abc.py ============================================================================== --- python/branches/p3yk/Lib/abc.py (original) +++ python/branches/p3yk/Lib/abc.py Tue Jun 12 06:20:05 2007 @@ -93,7 +93,7 @@ def __new__(mcls, name, bases, namespace): bases = _fix_bases(bases) - cls = super(ABCMeta, mcls).__new__(mcls, name, bases, namespace) + cls = super().__new__(mcls, name, bases, namespace) # Compute set of abstract method names abstracts = {name for name, value in namespace.items() Modified: python/branches/p3yk/Lib/ctypes/__init__.py ============================================================================== --- python/branches/p3yk/Lib/ctypes/__init__.py (original) +++ python/branches/p3yk/Lib/ctypes/__init__.py Tue Jun 12 06:20:05 2007 @@ -149,7 +149,7 @@ _type_ = "O" def __repr__(self): try: - return super(py_object, self).__repr__() + return super().__repr__() except ValueError: return "%s()" % type(self).__name__ _check_size(py_object, "P") Modified: python/branches/p3yk/Lib/ctypes/_endian.py ============================================================================== --- python/branches/p3yk/Lib/ctypes/_endian.py (original) +++ python/branches/p3yk/Lib/ctypes/_endian.py Tue Jun 12 06:20:05 2007 @@ -29,7 +29,7 @@ rest = desc[2:] fields.append((name, _other_endian(typ)) + rest) value = fields - super(_swapped_meta, self).__setattr__(attrname, value) + super().__setattr__(attrname, value) ################################################################ Modified: python/branches/p3yk/Lib/ctypes/test/test_init.py ============================================================================== --- python/branches/p3yk/Lib/ctypes/test/test_init.py (original) +++ python/branches/p3yk/Lib/ctypes/test/test_init.py Tue Jun 12 06:20:05 2007 @@ -7,7 +7,7 @@ new_was_called = False def __new__(cls): - result = super(X, cls).__new__(cls) + result = super().__new__(cls) result.new_was_called = True return result Modified: python/branches/p3yk/Lib/distutils/tests/support.py ============================================================================== --- python/branches/p3yk/Lib/distutils/tests/support.py (original) +++ python/branches/p3yk/Lib/distutils/tests/support.py Tue Jun 12 06:20:05 2007 @@ -9,12 +9,12 @@ class LoggingSilencer(object): def setUp(self): - super(LoggingSilencer, self).setUp() + super().setUp() self.threshold = log.set_threshold(log.FATAL) def tearDown(self): log.set_threshold(self.threshold) - super(LoggingSilencer, self).tearDown() + super().tearDown() class TempdirManager(object): @@ -24,11 +24,11 @@ """ def setUp(self): - super(TempdirManager, self).setUp() + super().setUp() self.tempdirs = [] def tearDown(self): - super(TempdirManager, self).tearDown() + super().tearDown() while self.tempdirs: d = self.tempdirs.pop() shutil.rmtree(d) Modified: python/branches/p3yk/Lib/plat-mac/plistlib.py ============================================================================== --- python/branches/p3yk/Lib/plat-mac/plistlib.py (original) +++ python/branches/p3yk/Lib/plat-mac/plistlib.py Tue Jun 12 06:20:05 2007 @@ -320,7 +320,7 @@ from warnings import warn warn("The plistlib.Dict class is deprecated, use builtin dict instead", PendingDeprecationWarning) - super(Dict, self).__init__(**kwargs) + super().__init__(**kwargs) class Plist(_InternalDict): @@ -333,7 +333,7 @@ from warnings import warn warn("The Plist class is deprecated, use the readPlist() and " "writePlist() functions instead", PendingDeprecationWarning) - super(Plist, self).__init__(**kwargs) + super().__init__(**kwargs) def fromFile(cls, pathOrFile): """Deprecated. Use the readPlist() function instead.""" Modified: python/branches/p3yk/Lib/random.py ============================================================================== --- python/branches/p3yk/Lib/random.py (original) +++ python/branches/p3yk/Lib/random.py Tue Jun 12 06:20:05 2007 @@ -110,19 +110,19 @@ import time a = int(time.time() * 256) # use fractional seconds - super(Random, self).seed(a) + super().seed(a) self.gauss_next = None def getstate(self): """Return internal state; can be passed to setstate() later.""" - return self.VERSION, super(Random, self).getstate(), self.gauss_next + return self.VERSION, super().getstate(), self.gauss_next def setstate(self, state): """Restore internal state from object returned by getstate().""" version = state[0] if version == 2: version, internalstate, self.gauss_next = state - super(Random, self).setstate(internalstate) + super().setstate(internalstate) else: raise ValueError("state with version %s passed to " "Random.setstate() of version %s" % Modified: python/branches/p3yk/Lib/string.py ============================================================================== --- python/branches/p3yk/Lib/string.py (original) +++ python/branches/p3yk/Lib/string.py Tue Jun 12 06:20:05 2007 @@ -103,7 +103,7 @@ """ def __init__(cls, name, bases, dct): - super(_TemplateMetaclass, cls).__init__(name, bases, dct) + super().__init__(name, bases, dct) if 'pattern' in dct: pattern = cls.pattern else: Modified: python/branches/p3yk/Lib/test/list_tests.py ============================================================================== --- python/branches/p3yk/Lib/test/list_tests.py (original) +++ python/branches/p3yk/Lib/test/list_tests.py Tue Jun 12 06:20:05 2007 @@ -451,7 +451,7 @@ self.assertEqual(u, list("ham")) def test_iadd(self): - super(CommonTest, self).test_iadd() + super().test_iadd() u = self.type2test([0, 1]) u2 = u u += [2, 3] Modified: python/branches/p3yk/Lib/test/test_array.py ============================================================================== --- python/branches/p3yk/Lib/test/test_array.py (original) +++ python/branches/p3yk/Lib/test/test_array.py Tue Jun 12 06:20:05 2007 @@ -710,7 +710,7 @@ class StringTest(BaseTest): def test_setitem(self): - super(StringTest, self).test_setitem() + super().test_setitem() a = array.array(self.typecode, self.example) self.assertRaises(TypeError, a.__setitem__, 0, self.example[:2]) Modified: python/branches/p3yk/Lib/test/test_collections.py ============================================================================== --- python/branches/p3yk/Lib/test/test_collections.py (original) +++ python/branches/p3yk/Lib/test/test_collections.py Tue Jun 12 06:20:05 2007 @@ -81,7 +81,7 @@ # Check direct subclassing class H(Hashable): def __hash__(self): - return super(H, self).__hash__() + return super().__hash__() self.assertEqual(hash(H()), 0) self.failIf(issubclass(int, H)) @@ -104,7 +104,7 @@ # Check direct subclassing class I(Iterable): def __iter__(self): - return super(I, self).__iter__() + return super().__iter__() self.assertEqual(list(I()), []) self.failIf(issubclass(str, I)) Modified: python/branches/p3yk/Lib/test/test_list.py ============================================================================== --- python/branches/p3yk/Lib/test/test_list.py (original) +++ python/branches/p3yk/Lib/test/test_list.py Tue Jun 12 06:20:05 2007 @@ -5,7 +5,7 @@ type2test = list def test_truth(self): - super(ListTest, self).test_truth() + super().test_truth() self.assert_(not []) self.assert_([42]) @@ -13,7 +13,7 @@ self.assert_([] is not []) def test_len(self): - super(ListTest, self).test_len() + super().test_len() self.assertEqual(len([]), 0) self.assertEqual(len([0]), 1) self.assertEqual(len([0, 1, 2]), 3) Modified: python/branches/p3yk/Lib/test/test_super.py ============================================================================== --- python/branches/p3yk/Lib/test/test_super.py (original) +++ python/branches/p3yk/Lib/test/test_super.py Tue Jun 12 06:20:05 2007 @@ -1,8 +1,5 @@ """Unit tests for new super() implementation.""" -# XXX Temporarily, we use super() instead of super. Or maybe we should -# use this, period? - import sys import unittest from test import test_support Modified: python/branches/p3yk/Lib/test/test_tuple.py ============================================================================== --- python/branches/p3yk/Lib/test/test_tuple.py (original) +++ python/branches/p3yk/Lib/test/test_tuple.py Tue Jun 12 06:20:05 2007 @@ -5,30 +5,30 @@ type2test = tuple def test_constructors(self): - super(TupleTest, self).test_len() + super().test_len() # calling built-in types without argument must return empty self.assertEqual(tuple(), ()) def test_truth(self): - super(TupleTest, self).test_truth() + super().test_truth() self.assert_(not ()) self.assert_((42, )) def test_len(self): - super(TupleTest, self).test_len() + super().test_len() self.assertEqual(len(()), 0) self.assertEqual(len((0,)), 1) self.assertEqual(len((0, 1, 2)), 3) def test_iadd(self): - super(TupleTest, self).test_iadd() + super().test_iadd() u = (0, 1) u2 = u u += (2, 3) self.assert_(u is not u2) def test_imul(self): - super(TupleTest, self).test_imul() + super().test_imul() u = (0, 1) u2 = u u *= 3 Modified: python/branches/p3yk/Lib/test/test_unittest.py ============================================================================== --- python/branches/p3yk/Lib/test/test_unittest.py (original) +++ python/branches/p3yk/Lib/test/test_unittest.py Tue Jun 12 06:20:05 2007 @@ -16,23 +16,23 @@ class LoggingResult(unittest.TestResult): def __init__(self, log): self._events = log - super(LoggingResult, self).__init__() + super().__init__() def startTest(self, test): self._events.append('startTest') - super(LoggingResult, self).startTest(test) + super().startTest(test) def stopTest(self, test): self._events.append('stopTest') - super(LoggingResult, self).stopTest(test) + super().stopTest(test) def addFailure(self, *args): self._events.append('addFailure') - super(LoggingResult, self).addFailure(*args) + super().addFailure(*args) def addError(self, *args): self._events.append('addError') - super(LoggingResult, self).addError(*args) + super().addError(*args) class TestEquality(object): # Check for a valid __eq__ implementation Modified: python/branches/p3yk/Lib/test/test_userlist.py ============================================================================== --- python/branches/p3yk/Lib/test/test_userlist.py (original) +++ python/branches/p3yk/Lib/test/test_userlist.py Tue Jun 12 06:20:05 2007 @@ -8,7 +8,7 @@ type2test = UserList def test_getslice(self): - super(UserListTest, self).test_getslice() + super().test_getslice() l = [0, 1, 2, 3, 4] u = self.type2test(l) for i in range(-3, 6): @@ -30,7 +30,7 @@ self.assertEqual(u2, list("spameggs")) def test_iadd(self): - super(UserListTest, self).test_iadd() + super().test_iadd() u = [0, 1] u += UserList([0, 1]) self.assertEqual(u, [0, 1, 0, 1]) Modified: python/branches/p3yk/Lib/test/test_weakref.py ============================================================================== --- python/branches/p3yk/Lib/test/test_weakref.py (original) +++ python/branches/p3yk/Lib/test/test_weakref.py Tue Jun 12 06:20:05 2007 @@ -651,10 +651,10 @@ class MyRef(weakref.ref): def __init__(self, ob, callback=None, value=42): self.value = value - super(MyRef, self).__init__(ob, callback) + super().__init__(ob, callback) def __call__(self): self.called = True - return super(MyRef, self).__call__() + return super().__call__() o = Object("foo") mr = MyRef(o, value=24) self.assert_(mr() is o) @@ -1091,7 +1091,7 @@ >>> import weakref >>> class ExtendedRef(weakref.ref): ... def __init__(self, ob, callback=None, **annotations): -... super(ExtendedRef, self).__init__(ob, callback) +... super().__init__(ob, callback) ... self.__counter = 0 ... for k, v in annotations.items(): ... setattr(self, k, v) @@ -1099,7 +1099,7 @@ ... '''Return a pair containing the referent and the number of ... times the reference has been called. ... ''' -... ob = super(ExtendedRef, self).__call__() +... ob = super().__call__() ... if ob is not None: ... self.__counter += 1 ... ob = (ob, self.__counter) Modified: python/branches/p3yk/Lib/weakref.py ============================================================================== --- python/branches/p3yk/Lib/weakref.py (original) +++ python/branches/p3yk/Lib/weakref.py Tue Jun 12 06:20:05 2007 @@ -204,7 +204,7 @@ return self def __init__(self, ob, callback, key): - super(KeyedRef, self).__init__(ob, callback) + super().__init__(ob, callback) class WeakKeyDictionary(UserDict.UserDict): From python-3000-checkins at python.org Tue Jun 12 07:53:05 2007 From: python-3000-checkins at python.org (martin.v.loewis) Date: Tue, 12 Jun 2007 07:53:05 +0200 (CEST) Subject: [Python-3000-checkins] r55925 - python/branches/py3k-struni/Python/codecs.c python/branches/py3k-struni/Python/import.c Message-ID: <20070612055305.868561E4002@bag.python.org> Author: martin.v.loewis Date: Tue Jun 12 07:53:00 2007 New Revision: 55925 Modified: python/branches/py3k-struni/Python/codecs.c python/branches/py3k-struni/Python/import.c Log: Revert 55876. Use PyUnicode_AsEncodedString instead. Modified: python/branches/py3k-struni/Python/codecs.c ============================================================================== --- python/branches/py3k-struni/Python/codecs.c (original) +++ python/branches/py3k-struni/Python/codecs.c Tue Jun 12 07:53:00 2007 @@ -319,23 +319,6 @@ PyObject *args = NULL, *result = NULL; PyObject *v; - /* XXX short-cut a few common file system - encodings for now, as otherwise the import - code can't load the codec registry. */ - if (strcmp(encoding, "utf-8") == 0 && PyUnicode_Check(object)) { - return PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(object), - PyUnicode_GET_SIZE(object), - errors); - } -#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) - if (strcmp(encoding, "mbcs") == 0 && PyUnicode_Check(object)) { - return PyUnicode_EncodeMBCS(PyUnicode_AS_UNICODE(object), - PyUnicode_GET_SIZE(object), - errors); - } -#endif - - encoder = PyCodec_Encoder(encoding); if (encoder == NULL) goto onError; Modified: python/branches/py3k-struni/Python/import.c ============================================================================== --- python/branches/py3k-struni/Python/import.c (original) +++ python/branches/py3k-struni/Python/import.c Tue Jun 12 07:53:00 2007 @@ -2305,10 +2305,10 @@ if (!Py_FileSystemDefaultEncoding) { item8 = PyUnicode_EncodeASCII(PyUnicode_AsUnicode(item), PyUnicode_GetSize(item), - "strict"); + NULL); } else { - item8 = PyUnicode_AsEncodedObject(item, - Py_FileSystemDefaultEncoding, "strict"); + item8 = PyUnicode_AsEncodedString(item, + Py_FileSystemDefaultEncoding, NULL); } if (!item8) { PyErr_SetString(PyExc_ValueError, "Cannot encode path item"); From nnorwitz at gmail.com Tue Jun 12 14:47:07 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Tue, 12 Jun 2007 08:47:07 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures basics (1) Message-ID: <20070612124707.GA2592@python.psfb.org> test_grammar test_opcodes test_dict test_builtin test_exceptions test test_exceptions failed -- Traceback (most recent call last): File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 186, in testSettingException test_capi1() File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 155, in test_capi1 import _testcapi ImportError: No module named _testcapi test_types test_unittest test_doctest test_doctest2 test_StringIO test___all__ test___future__ test__locale test_abc test_aepack test_aepack skipped -- No module named aepack test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_buffer test_bufio test_bytes test_bz2 test_cProfile test_calendar test_call test_capi test_capi skipped -- No module named _testcapi test_cfgparser test_cgi test_charmapcodec test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_cn skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_hk test_codecmaps_hk skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_jp test_codecmaps_jp skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_kr test_codecmaps_kr skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_tw test_codecmaps_tw skipped -- Use of the `urlfetch' resource not enabled test_codecs test_codecs skipped -- No module named _testcapi test_codeop test_coding test_collections test_colorsys test_commands test_compare test_compile test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictviews test_difflib test_dircache test_dis test_distutils test_dl test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_ftplib test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getargs2 skipped -- No module named _testcapi test_getopt test_gettext test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imaplib test_imp test_import test_importhooks test_index test_inspect test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_keywordonlyarg test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_listcomps test_locale test_logging test_long test_long_future test_longexp test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_metaclass test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_normalization test_normalization skipped -- Use of the `urlfetch' resource not enabled test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [12978 refs] [12978 refs] [12978 refs] test_poplib test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [13862 refs] [13862 refs] test_random test_re test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sgmllib test_shelve test_shlex test_shutil test_signal test_site test_slice test_smtplib test_socket test_socket_ssl test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strptime test_struct test_structmembers test_structmembers skipped -- No module named _testcapi test_structseq test_subprocess [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [16244 refs] [13188 refs] [12972 refs] [12973 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] . [12972 refs] [12972 refs] this bit of output is from a test of stdout in a different process ... [12972 refs] [12972 refs] [13188 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_super test_symtable test_syntax test_sys [12972 refs] [12972 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [12974 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_tuple test_typechecks test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_unpack test_unpack_ex test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmlrpc test_xpickle test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zlib 285 tests OK. 1 test failed: test_exceptions 32 tests skipped: test_aepack test_applesingle test_bsddb3 test_capi test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_curses test_getargs2 test_ioctl test_linuxaudiodev test_macostools test_normalization test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socketserver test_startfile test_structmembers test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_getargs2 test_capi test_tcl test_ioctl test_structmembers test_codecs [628223 refs] From nnorwitz at gmail.com Tue Jun 12 14:52:54 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Tue, 12 Jun 2007 08:52:54 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures opt (1) Message-ID: <20070612125254.GA3303@python.psfb.org> test_grammar test_opcodes test_dict test_builtin test_exceptions test test_exceptions failed -- Traceback (most recent call last): File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 186, in testSettingException test_capi1() File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 155, in test_capi1 import _testcapi ImportError: No module named _testcapi test_types test_unittest test_doctest test_doctest2 test_StringIO test___all__ test___future__ test__locale test_abc test_aepack test_aepack skipped -- No module named aepack test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_buffer test_bufio test_bytes test_bz2 test_cProfile test_calendar test_call test_capi test_capi skipped -- No module named _testcapi test_cfgparser test_cgi test_charmapcodec test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_cn skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_hk test_codecmaps_hk skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_jp test_codecmaps_jp skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_kr test_codecmaps_kr skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_tw test_codecmaps_tw skipped -- Use of the `urlfetch' resource not enabled test_codecs test_codecs skipped -- No module named _testcapi test_codeop test_coding test_collections test_colorsys test_commands test_compare test_compile test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictviews test_difflib test_dircache test_dis test_distutils [16409 refs] test_dl test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_ftplib test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getargs2 skipped -- No module named _testcapi test_getopt test_gettext test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imaplib test_imp test_import test_importhooks test_index test_inspect test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_keywordonlyarg test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_listcomps test_locale test_logging test_long test_long_future test_longexp test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_metaclass test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_normalization test_normalization skipped -- Use of the `urlfetch' resource not enabled test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [12978 refs] [12978 refs] [12978 refs] test_poplib test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [13862 refs] [13862 refs] test_random test_re test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sgmllib test_shelve test_shlex test_shutil test_signal test_site test_slice test_smtplib test_socket test_socket_ssl test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strptime test_struct test_structmembers test_structmembers skipped -- No module named _testcapi test_structseq test_subprocess [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [16244 refs] [13188 refs] [12972 refs] [12973 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] . [12972 refs] [12972 refs] this bit of output is from a test of stdout in a different process ... [12972 refs] [12972 refs] [13188 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_super test_symtable test_syntax test_sys [12972 refs] [12972 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [12974 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_tuple test_typechecks test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_unpack test_unpack_ex test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmlrpc test_xpickle test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zlib 285 tests OK. 1 test failed: test_exceptions 32 tests skipped: test_aepack test_applesingle test_bsddb3 test_capi test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_curses test_getargs2 test_ioctl test_linuxaudiodev test_macostools test_normalization test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socketserver test_startfile test_structmembers test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_getargs2 test_capi test_tcl test_ioctl test_structmembers test_codecs [627418 refs] From nnorwitz at gmail.com Tue Jun 12 15:51:04 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Tue, 12 Jun 2007 09:51:04 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures refleak (1) Message-ID: <20070612135104.GA8820@python.psfb.org> test_threading_local leaked [-11, 11, 0] references, sum=0 test_urllib2_localnet leaked [3, 2, 4] references, sum=9 From nnorwitz at gmail.com Tue Jun 12 16:02:14 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Tue, 12 Jun 2007 10:02:14 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures all (1) Message-ID: <20070612140214.GA10615@python.psfb.org> test_grammar test_opcodes test_dict test_builtin test_exceptions test test_exceptions failed -- Traceback (most recent call last): File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 186, in testSettingException test_capi1() File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 155, in test_capi1 import _testcapi ImportError: No module named _testcapi test_types test_unittest test_doctest test_doctest2 test_StringIO test___all__ test___future__ test__locale test_abc test_aepack test_aepack skipped -- No module named aepack test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb3 test_buffer test_bufio test_bytes test_bz2 test_cProfile test_calendar test_call test_capi test_capi skipped -- No module named _testcapi test_cfgparser test_cgi test_charmapcodec test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codecs skipped -- No module named _testcapi test_codeop test_coding test_collections test_colorsys test_commands test_compare test_compile test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictviews test_difflib test_dircache test_dis test_distutils test_dl test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_ftplib test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getargs2 skipped -- No module named _testcapi test_getopt test_gettext test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imaplib test_imp test_import test_importhooks test_index test_inspect test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_keywordonlyarg test_largefile test_list test_listcomps test_locale test_logging test_long test_long_future test_longexp test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_metaclass test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [12978 refs] [12978 refs] [12978 refs] test_poplib test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [13862 refs] [13862 refs] test_random test_re test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sgmllib test_shelve test_shlex test_shutil test_signal test_site test_slice test_smtplib test_socket test_socket_ssl test_socketserver test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strptime test_struct test_structmembers test_structmembers skipped -- No module named _testcapi test_structseq test_subprocess [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] [16244 refs] [13188 refs] [12972 refs] [12973 refs] [12972 refs] [12972 refs] [12972 refs] [12972 refs] . [12972 refs] [12972 refs] this bit of output is from a test of stdout in a different process ... [12972 refs] [12972 refs] [13188 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_super test_symtable test_syntax test_sys [12972 refs] [12972 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [12974 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_tokenize test_trace test_traceback test_tuple test_typechecks test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_unpack test_unpack_ex test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllibnet test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmlrpc test_xpickle test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zlib 296 tests OK. 1 test failed: test_exceptions 18 tests skipped: test_aepack test_applesingle test_capi test_codecs test_getargs2 test_ioctl test_macostools test_pep277 test_plistlib test_scriptpackages test_startfile test_structmembers test_sunaudiodev test_tcl test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_getargs2 test_capi test_tcl test_ioctl test_structmembers test_codecs warning: DBTxn aborted in destructor. No prior commit() or abort(). [642206 refs] From python-3000-checkins at python.org Tue Jun 12 17:23:53 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Tue, 12 Jun 2007 17:23:53 +0200 (CEST) Subject: [Python-3000-checkins] r55928 - python/branches/py3k-struni/Python/modsupport.c Message-ID: <20070612152353.671141E400C@bag.python.org> Author: walter.doerwald Date: Tue Jun 12 17:23:50 2007 New Revision: 55928 Modified: python/branches/py3k-struni/Python/modsupport.c Log: Make module docstrings unicode objects. Modified: python/branches/py3k-struni/Python/modsupport.c ============================================================================== --- python/branches/py3k-struni/Python/modsupport.c (original) +++ python/branches/py3k-struni/Python/modsupport.c Tue Jun 12 17:23:50 2007 @@ -92,7 +92,7 @@ Py_DECREF(n); } if (doc != NULL) { - v = PyString_FromString(doc); + v = PyUnicode_FromString(doc); if (v == NULL || PyDict_SetItemString(d, "__doc__", v) != 0) { Py_XDECREF(v); return NULL; From python-3000-checkins at python.org Tue Jun 12 18:40:26 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Tue, 12 Jun 2007 18:40:26 +0200 (CEST) Subject: [Python-3000-checkins] r55932 - in python/branches/py3k-struni: Doc/lib/libcodecs.tex Lib/encodings/base64_codec.py Lib/encodings/hex_codec.py Lib/encodings/quopri_codec.py Lib/encodings/rot_13.py Lib/encodings/string_escape.py Lib/encodings/uu_codec.py Lib/encodings/zlib_codec.py Lib/pickle.py Lib/pickletools.py Lib/test/test_codecs.py Message-ID: <20070612164026.3D1141E4002@bag.python.org> Author: walter.doerwald Date: Tue Jun 12 18:40:17 2007 New Revision: 55932 Removed: python/branches/py3k-struni/Lib/encodings/base64_codec.py python/branches/py3k-struni/Lib/encodings/hex_codec.py python/branches/py3k-struni/Lib/encodings/quopri_codec.py python/branches/py3k-struni/Lib/encodings/rot_13.py python/branches/py3k-struni/Lib/encodings/string_escape.py python/branches/py3k-struni/Lib/encodings/uu_codec.py python/branches/py3k-struni/Lib/encodings/zlib_codec.py Modified: python/branches/py3k-struni/Doc/lib/libcodecs.tex python/branches/py3k-struni/Lib/pickle.py python/branches/py3k-struni/Lib/pickletools.py python/branches/py3k-struni/Lib/test/test_codecs.py Log: Rip out all codecs that can't work in a unicode/bytes world: base64, uu, zlib, rot_13, hex, quopri, bz2, string_escape. However codecs.escape_encode() and codecs.escape_decode() still exist, as they are used for pickling str8 objects (so those two functions can go, when the str8 type is removed). Modified: python/branches/py3k-struni/Doc/lib/libcodecs.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libcodecs.tex (original) +++ python/branches/py3k-struni/Doc/lib/libcodecs.tex Tue Jun 12 18:40:17 2007 @@ -1214,22 +1214,6 @@ \begin{tableiv}{l|l|l|l}{textrm}{Codec}{Aliases}{Operand type}{Purpose} -\lineiv{base64_codec} - {base64, base-64} - {byte string} - {Convert operand to MIME base64} - -\lineiv{bz2_codec} - {bz2} - {byte string} - {Compress the operand using bz2} - -\lineiv{hex_codec} - {hex} - {byte string} - {Convert operand to hexadecimal representation, with two - digits per byte} - \lineiv{idna} {} {Unicode string} @@ -1251,34 +1235,18 @@ {Unicode string} {Implements \rfc{3492}} -\lineiv{quopri_codec} - {quopri, quoted-printable, quotedprintable} - {byte string} - {Convert operand to MIME quoted printable} - \lineiv{raw_unicode_escape} {} {Unicode string} {Produce a string that is suitable as raw Unicode literal in Python source code} -\lineiv{rot_13} - {rot13} - {Unicode string} - {Returns the Caesar-cypher encryption of the operand} - -\lineiv{string_escape} - {} - {byte string} - {Produce a string that is suitable as string literal in - Python source code} - \lineiv{undefined} {} {any} {Raise an exception for all conversions. Can be used as the system encoding if no automatic coercion between byte and - Unicode strings is desired.} + Unicode strings is desired.} \lineiv{unicode_escape} {} @@ -1290,17 +1258,6 @@ {} {Unicode string} {Return the internal representation of the operand} - -\lineiv{uu_codec} - {uu} - {byte string} - {Convert the operand using uuencode} - -\lineiv{zlib_codec} - {zip, zlib} - {byte string} - {Compress the operand using gzip} - \end{tableiv} \versionadded[The \code{idna} and \code{punycode} encodings]{2.3} Deleted: /python/branches/py3k-struni/Lib/encodings/base64_codec.py ============================================================================== --- /python/branches/py3k-struni/Lib/encodings/base64_codec.py Tue Jun 12 18:40:17 2007 +++ (empty file) @@ -1,79 +0,0 @@ -""" Python 'base64_codec' Codec - base64 content transfer encoding - - Unlike most of the other codecs which target Unicode, this codec - will return Python string objects for both encode and decode. - - Written by Marc-Andre Lemburg (mal at lemburg.com). - -""" -import codecs, base64 - -### Codec APIs - -def base64_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 = bytes(base64.encodestring(input)) - return (output, len(input)) - -def base64_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 = base64.decodestring(input) - return (output, len(input)) - -class Codec(codecs.Codec): - - def encode(self, input,errors='strict'): - return base64_encode(input,errors) - def decode(self, input,errors='strict'): - return base64_decode(input,errors) - -class IncrementalEncoder(codecs.IncrementalEncoder): - def encode(self, input, final=False): - assert self.errors == 'strict' - return base64.encodestring(input) - -class IncrementalDecoder(codecs.IncrementalDecoder): - def decode(self, input, final=False): - assert self.errors == 'strict' - return base64.decodestring(input) - -class StreamWriter(Codec,codecs.StreamWriter): - pass - -class StreamReader(Codec,codecs.StreamReader): - pass - -### encodings module API - -def getregentry(): - return codecs.CodecInfo( - name='base64', - encode=base64_encode, - decode=base64_decode, - incrementalencoder=IncrementalEncoder, - incrementaldecoder=IncrementalDecoder, - streamwriter=StreamWriter, - streamreader=StreamReader, - ) Deleted: /python/branches/py3k-struni/Lib/encodings/hex_codec.py ============================================================================== --- /python/branches/py3k-struni/Lib/encodings/hex_codec.py Tue Jun 12 18:40:17 2007 +++ (empty file) @@ -1,79 +0,0 @@ -""" Python 'hex_codec' Codec - 2-digit hex content transfer encoding - - Unlike most of the other codecs which target Unicode, this codec - will return Python string objects for both encode and decode. - - Written by Marc-Andre Lemburg (mal at lemburg.com). - -""" -import codecs, binascii - -### Codec APIs - -def hex_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 = binascii.b2a_hex(input) - return (output, len(input)) - -def hex_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 = binascii.a2b_hex(input) - return (output, len(input)) - -class Codec(codecs.Codec): - - def encode(self, input,errors='strict'): - return hex_encode(input,errors) - def decode(self, input,errors='strict'): - return hex_decode(input,errors) - -class IncrementalEncoder(codecs.IncrementalEncoder): - def encode(self, input, final=False): - assert self.errors == 'strict' - return binascii.b2a_hex(input) - -class IncrementalDecoder(codecs.IncrementalDecoder): - def decode(self, input, final=False): - assert self.errors == 'strict' - return binascii.a2b_hex(input) - -class StreamWriter(Codec,codecs.StreamWriter): - pass - -class StreamReader(Codec,codecs.StreamReader): - pass - -### encodings module API - -def getregentry(): - return codecs.CodecInfo( - name='hex', - encode=hex_encode, - decode=hex_decode, - incrementalencoder=IncrementalEncoder, - incrementaldecoder=IncrementalDecoder, - streamwriter=StreamWriter, - streamreader=StreamReader, - ) Deleted: /python/branches/py3k-struni/Lib/encodings/quopri_codec.py ============================================================================== --- /python/branches/py3k-struni/Lib/encodings/quopri_codec.py Tue Jun 12 18:40:17 2007 +++ (empty file) @@ -1,74 +0,0 @@ -"""Codec for quoted-printable encoding. - -Like base64 and rot13, this returns Python strings, not Unicode. -""" - -import codecs, quopri -try: - from cStringIO import StringIO -except ImportError: - from StringIO import StringIO - -def quopri_encode(input, errors='strict'): - """Encode the input, returning 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' - f = StringIO(input) - g = StringIO() - quopri.encode(f, g, 1) - output = g.getvalue() - return (output, len(input)) - -def quopri_decode(input, errors='strict'): - """Decode the input, returning 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' - f = StringIO(input) - g = StringIO() - quopri.decode(f, g) - output = g.getvalue() - return (output, len(input)) - -class Codec(codecs.Codec): - - def encode(self, input,errors='strict'): - return quopri_encode(input,errors) - def decode(self, input,errors='strict'): - return quopri_decode(input,errors) - -class IncrementalEncoder(codecs.IncrementalEncoder): - def encode(self, input, final=False): - return quopri_encode(input, self.errors)[0] - -class IncrementalDecoder(codecs.IncrementalDecoder): - def decode(self, input, final=False): - return quopri_decode(input, self.errors)[0] - -class StreamWriter(Codec, codecs.StreamWriter): - pass - -class StreamReader(Codec,codecs.StreamReader): - pass - -# encodings module API - -def getregentry(): - return codecs.CodecInfo( - name='quopri', - encode=quopri_encode, - decode=quopri_decode, - incrementalencoder=IncrementalEncoder, - incrementaldecoder=IncrementalDecoder, - streamwriter=StreamWriter, - streamreader=StreamReader, - ) Deleted: /python/branches/py3k-struni/Lib/encodings/rot_13.py ============================================================================== --- /python/branches/py3k-struni/Lib/encodings/rot_13.py Tue Jun 12 18:40:17 2007 +++ (empty file) @@ -1,118 +0,0 @@ -#!/usr/bin/env python -""" Python Character Mapping Codec for ROT13. - - See http://ucsub.colorado.edu/~kominek/rot13/ for details. - - Written by Marc-Andre Lemburg (mal at lemburg.com). - -"""#" - -import codecs - -### Codec APIs - -class Codec(codecs.Codec): - - def encode(self,input,errors='strict'): - return codecs.charmap_encode(input,errors,encoding_map) - - def decode(self,input,errors='strict'): - return codecs.charmap_decode(input,errors,decoding_map) - -class IncrementalEncoder(codecs.IncrementalEncoder): - def encode(self, input, final=False): - return codecs.charmap_encode(input,self.errors,encoding_map)[0] - -class IncrementalDecoder(codecs.IncrementalDecoder): - def decode(self, input, final=False): - return codecs.charmap_decode(input,self.errors,decoding_map)[0] - -class StreamWriter(Codec,codecs.StreamWriter): - pass - -class StreamReader(Codec,codecs.StreamReader): - pass - -### encodings module API - -def getregentry(): - return codecs.CodecInfo( - name='rot-13', - encode=Codec().encode, - decode=Codec().decode, - incrementalencoder=IncrementalEncoder, - incrementaldecoder=IncrementalDecoder, - streamwriter=StreamWriter, - streamreader=StreamReader, - ) - -### Decoding Map - -decoding_map = codecs.make_identity_dict(range(256)) -decoding_map.update({ - 0x0041: 0x004e, - 0x0042: 0x004f, - 0x0043: 0x0050, - 0x0044: 0x0051, - 0x0045: 0x0052, - 0x0046: 0x0053, - 0x0047: 0x0054, - 0x0048: 0x0055, - 0x0049: 0x0056, - 0x004a: 0x0057, - 0x004b: 0x0058, - 0x004c: 0x0059, - 0x004d: 0x005a, - 0x004e: 0x0041, - 0x004f: 0x0042, - 0x0050: 0x0043, - 0x0051: 0x0044, - 0x0052: 0x0045, - 0x0053: 0x0046, - 0x0054: 0x0047, - 0x0055: 0x0048, - 0x0056: 0x0049, - 0x0057: 0x004a, - 0x0058: 0x004b, - 0x0059: 0x004c, - 0x005a: 0x004d, - 0x0061: 0x006e, - 0x0062: 0x006f, - 0x0063: 0x0070, - 0x0064: 0x0071, - 0x0065: 0x0072, - 0x0066: 0x0073, - 0x0067: 0x0074, - 0x0068: 0x0075, - 0x0069: 0x0076, - 0x006a: 0x0077, - 0x006b: 0x0078, - 0x006c: 0x0079, - 0x006d: 0x007a, - 0x006e: 0x0061, - 0x006f: 0x0062, - 0x0070: 0x0063, - 0x0071: 0x0064, - 0x0072: 0x0065, - 0x0073: 0x0066, - 0x0074: 0x0067, - 0x0075: 0x0068, - 0x0076: 0x0069, - 0x0077: 0x006a, - 0x0078: 0x006b, - 0x0079: 0x006c, - 0x007a: 0x006d, -}) - -### Encoding Map - -encoding_map = codecs.make_encoding_map(decoding_map) - -### Filter API - -def rot13(infile, outfile): - outfile.write(infile.read().encode('rot-13')) - -if __name__ == '__main__': - import sys - rot13(sys.stdin, sys.stdout) Deleted: /python/branches/py3k-struni/Lib/encodings/string_escape.py ============================================================================== --- /python/branches/py3k-struni/Lib/encodings/string_escape.py Tue Jun 12 18:40:17 2007 +++ (empty file) @@ -1,38 +0,0 @@ -# -*- coding: iso-8859-1 -*- -""" Python 'escape' Codec - - -Written by Martin v. L?wis (martin at v.loewis.de). - -""" -import codecs - -class Codec(codecs.Codec): - - encode = codecs.escape_encode - decode = codecs.escape_decode - -class IncrementalEncoder(codecs.IncrementalEncoder): - def encode(self, input, final=False): - return codecs.escape_encode(input, self.errors)[0] - -class IncrementalDecoder(codecs.IncrementalDecoder): - def decode(self, input, final=False): - return codecs.escape_decode(input, self.errors)[0] - -class StreamWriter(Codec,codecs.StreamWriter): - pass - -class StreamReader(Codec,codecs.StreamReader): - pass - -def getregentry(): - return codecs.CodecInfo( - name='string-escape', - encode=Codec.encode, - decode=Codec.decode, - incrementalencoder=IncrementalEncoder, - incrementaldecoder=IncrementalDecoder, - streamwriter=StreamWriter, - streamreader=StreamReader, - ) Deleted: /python/branches/py3k-struni/Lib/encodings/uu_codec.py ============================================================================== --- /python/branches/py3k-struni/Lib/encodings/uu_codec.py Tue Jun 12 18:40:17 2007 +++ (empty file) @@ -1,128 +0,0 @@ -""" Python 'uu_codec' Codec - UU content transfer encoding - - Unlike most of the other codecs which target Unicode, this codec - will return Python string objects for both encode and decode. - - Written by Marc-Andre Lemburg (mal at lemburg.com). Some details were - adapted from uu.py which was written by Lance Ellinghouse and - modified by Jack Jansen and Fredrik Lundh. - -""" -import codecs, binascii - -### Codec APIs - -def uu_encode(input,errors='strict',filename='',mode=0666): - - """ 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' - from cStringIO import StringIO - from binascii import b2a_uu - infile = StringIO(input) - outfile = StringIO() - read = infile.read - write = outfile.write - - # Encode - write('begin %o %s\n' % (mode & 0777, filename)) - chunk = read(45) - while chunk: - write(b2a_uu(chunk)) - chunk = read(45) - write(' \nend\n') - - return (outfile.getvalue(), len(input)) - -def uu_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. - - Note: filename and file mode information in the input data is - ignored. - - """ - assert errors == 'strict' - from cStringIO import StringIO - from binascii import a2b_uu - infile = StringIO(input) - outfile = StringIO() - readline = infile.readline - write = outfile.write - - # Find start of encoded data - while 1: - s = readline() - if not s: - raise ValueError, 'Missing "begin" line in input data' - if s[:5] == 'begin': - break - - # Decode - while 1: - s = readline() - if not s or \ - s == 'end\n': - break - try: - data = a2b_uu(s) - except binascii.Error as v: - # Workaround for broken uuencoders by /Fredrik Lundh - nbytes = (((ord(s[0])-32) & 63) * 4 + 5) / 3 - data = a2b_uu(s[:nbytes]) - #sys.stderr.write("Warning: %s\n" % str(v)) - write(data) - if not s: - raise ValueError, 'Truncated input data' - - return (outfile.getvalue(), len(input)) - -class Codec(codecs.Codec): - - def encode(self,input,errors='strict'): - return uu_encode(input,errors) - - def decode(self,input,errors='strict'): - return uu_decode(input,errors) - -class IncrementalEncoder(codecs.IncrementalEncoder): - def encode(self, input, final=False): - return uu_encode(input, self.errors)[0] - -class IncrementalDecoder(codecs.IncrementalDecoder): - def decode(self, input, final=False): - return uu_decode(input, self.errors)[0] - -class StreamWriter(Codec,codecs.StreamWriter): - pass - -class StreamReader(Codec,codecs.StreamReader): - pass - -### encodings module API - -def getregentry(): - return codecs.CodecInfo( - name='uu', - encode=uu_encode, - decode=uu_decode, - incrementalencoder=IncrementalEncoder, - incrementaldecoder=IncrementalDecoder, - streamreader=StreamReader, - streamwriter=StreamWriter, - ) Deleted: /python/branches/py3k-struni/Lib/encodings/zlib_codec.py ============================================================================== --- /python/branches/py3k-struni/Lib/encodings/zlib_codec.py Tue Jun 12 18:40:17 2007 +++ (empty file) @@ -1,102 +0,0 @@ -""" Python 'zlib_codec' Codec - zlib compression encoding - - Unlike most of the other codecs which target Unicode, this codec - will return Python string objects for both encode and decode. - - Written by Marc-Andre Lemburg (mal at lemburg.com). - -""" -import codecs -import zlib # this codec needs the optional zlib module ! - -### Codec APIs - -def zlib_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 = zlib.compress(input) - return (output, len(input)) - -def zlib_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 = zlib.decompress(input) - return (output, len(input)) - -class Codec(codecs.Codec): - - def encode(self, input, errors='strict'): - return zlib_encode(input, errors) - def decode(self, input, errors='strict'): - return zlib_decode(input, errors) - -class IncrementalEncoder(codecs.IncrementalEncoder): - def __init__(self, errors='strict'): - assert errors == 'strict' - self.errors = errors - self.compressobj = zlib.compressobj() - - 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 = zlib.compressobj() - -class IncrementalDecoder(codecs.IncrementalDecoder): - def __init__(self, errors='strict'): - assert errors == 'strict' - self.errors = errors - self.decompressobj = zlib.decompressobj() - - def decode(self, input, final=False): - if final: - c = self.decompressobj.decompress(input) - return c + self.decompressobj.flush() - else: - return self.decompressobj.decompress(input) - - def reset(self): - self.decompressobj = zlib.decompressobj() - -class StreamWriter(Codec,codecs.StreamWriter): - pass - -class StreamReader(Codec,codecs.StreamReader): - pass - -### encodings module API - -def getregentry(): - return codecs.CodecInfo( - name='zlib', - encode=zlib_encode, - decode=zlib_decode, - incrementalencoder=IncrementalEncoder, - incrementaldecoder=IncrementalDecoder, - streamreader=StreamReader, - streamwriter=StreamWriter, - ) Modified: python/branches/py3k-struni/Lib/pickle.py ============================================================================== --- python/branches/py3k-struni/Lib/pickle.py (original) +++ python/branches/py3k-struni/Lib/pickle.py Tue Jun 12 18:40:17 2007 @@ -34,6 +34,7 @@ import struct import re import io +import codecs __all__ = ["PickleError", "PicklingError", "UnpicklingError", "Pickler", "Unpickler", "dump", "dumps", "load", "loads"] @@ -929,7 +930,7 @@ break else: raise ValueError, "insecure string pickle" - self.append(str8(rep.decode("string-escape"))) + self.append(str8(codecs.escape_decode(rep)[0])) dispatch[STRING[0]] = load_string def load_binstring(self): Modified: python/branches/py3k-struni/Lib/pickletools.py ============================================================================== --- python/branches/py3k-struni/Lib/pickletools.py (original) +++ python/branches/py3k-struni/Lib/pickletools.py Tue Jun 12 18:40:17 2007 @@ -10,6 +10,8 @@ Print a symbolic disassembly of a pickle. ''' +import codecs + __all__ = ['dis', 'genops', ] @@ -318,10 +320,8 @@ else: raise ValueError("no string quotes around %r" % data) - # I'm not sure when 'string_escape' was added to the std codecs; it's - # crazy not to use it if it's there. if decode: - data = data.decode('string_escape') + data = codecs.escape_decode(data)[0] return data stringnl = ArgumentDescriptor( Modified: python/branches/py3k-struni/Lib/test/test_codecs.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_codecs.py (original) +++ python/branches/py3k-struni/Lib/test/test_codecs.py Tue Jun 12 18:40:17 2007 @@ -486,10 +486,6 @@ self.check_state_handling_decode(self.encoding, u, u.encode(self.encoding)) -class EscapeDecodeTest(unittest.TestCase): - def test_empty(self): - self.assertEquals(codecs.escape_decode(""), ("", 0)) - class RecodingTest(unittest.TestCase): def test_recoding(self): f = io.BytesIO() @@ -986,25 +982,8 @@ ef.write(b'\xc3\xbc') self.assertEquals(f.getvalue(), b'\xfc') -class Str2StrTest(unittest.TestCase): - - def test_read(self): - sin = "\x80".encode("base64_codec") - reader = codecs.getreader("base64_codec")(io.BytesIO(sin)) - sout = reader.read() - self.assertEqual(sout, "\x80") - self.assert_(isinstance(sout, str)) - - def test_readline(self): - sin = "\x80".encode("base64_codec") - reader = codecs.getreader("base64_codec")(io.BytesIO(sin)) - sout = reader.readline() - self.assertEqual(sout, "\x80") - self.assert_(isinstance(sout, str)) - all_unicode_encodings = [ "ascii", - "base64_codec", "big5", "big5hkscs", "charmap", @@ -1051,7 +1030,6 @@ "gb18030", "gb2312", "gbk", - "hex_codec", "hp_roman8", "hz", "idna", @@ -1091,7 +1069,6 @@ "ptcp154", "punycode", "raw_unicode_escape", - "rot_13", "shift_jis", "shift_jis_2004", "shift_jisx0213", @@ -1108,53 +1085,24 @@ if hasattr(codecs, "mbcs_encode"): all_unicode_encodings.append("mbcs") -# The following encodings work only with str8, not str -all_string_encodings = [ - "quopri_codec", - "string_escape", - "uu_codec", -] - # The following encoding is not tested, because it's not supposed # to work: # "undefined" # The following encodings don't work in stateful mode broken_unicode_with_streams = [ - "base64_codec", - "hex_codec", "punycode", "unicode_internal" ] broken_incremental_coders = broken_unicode_with_streams + [ "idna", - "zlib_codec", - "bz2_codec", ] # The following encodings only support "strict" mode only_strict_mode = [ "idna", - "zlib_codec", - "bz2_codec", ] -try: - import bz2 -except ImportError: - pass -else: - all_unicode_encodings.append("bz2_codec") - broken_unicode_with_streams.append("bz2_codec") - -try: - import zlib -except ImportError: - pass -else: - all_unicode_encodings.append("zlib_codec") - broken_unicode_with_streams.append("zlib_codec") - class BasicUnicodeTest(unittest.TestCase, MixInCheckStateHandling): def test_basics(self): s = "abc123" # all codecs should be able to encode these @@ -1287,15 +1235,6 @@ self.check_state_handling_decode(encoding, u, u.encode(encoding)) self.check_state_handling_encode(encoding, u, u.encode(encoding)) -class BasicStrTest(unittest.TestCase): - def test_basics(self): - s = str8("abc123") - for encoding in all_string_encodings: - (encoded, size) = codecs.getencoder(encoding)(s) - self.assertEqual(size, len(s)) - (chars, size) = codecs.getdecoder(encoding)(encoded) - self.assertEqual(chars, s, "%r != %r (encoding=%r)" % (chars, s, encoding)) - class CharmapTest(unittest.TestCase): def test_decode_with_string_map(self): self.assertEquals( @@ -1354,7 +1293,6 @@ UTF16ExTest, ReadBufferTest, CharBufferTest, - EscapeDecodeTest, RecodingTest, PunycodeTest, UnicodeInternalTest, @@ -1363,9 +1301,7 @@ CodecsModuleTest, StreamReaderTest, EncodedFileTest, - Str2StrTest, BasicUnicodeTest, - BasicStrTest, CharmapTest, WithStmtTest, ) From python-3000-checkins at python.org Tue Jun 12 18:51:34 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Tue, 12 Jun 2007 18:51:34 +0200 (CEST) Subject: [Python-3000-checkins] r55933 - python/branches/py3k-struni/Objects/unicodeobject.c Message-ID: <20070612165134.405E21E4005@bag.python.org> Author: walter.doerwald Date: Tue Jun 12 18:51:31 2007 New Revision: 55933 Modified: python/branches/py3k-struni/Objects/unicodeobject.c Log: Mention name of left operand, if "foo in unicode_string" fails. Modified: python/branches/py3k-struni/Objects/unicodeobject.c ============================================================================== --- python/branches/py3k-struni/Objects/unicodeobject.c (original) +++ python/branches/py3k-struni/Objects/unicodeobject.c Tue Jun 12 18:51:31 2007 @@ -6001,8 +6001,9 @@ /* Coerce the two arguments */ sub = PyUnicode_FromObject(element); if (!sub) { - PyErr_SetString(PyExc_TypeError, - "'in ' requires string as left operand"); + PyErr_Format(PyExc_TypeError, + "'in ' requires string as left operand, not %s", + element->ob_type->tp_name); return -1; } From python-3000-checkins at python.org Tue Jun 12 19:43:48 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Tue, 12 Jun 2007 19:43:48 +0200 (CEST) Subject: [Python-3000-checkins] r55935 - python/branches/py3k-struni/Lib/test/test_shlex.py Message-ID: <20070612174348.D53121E4008@bag.python.org> Author: walter.doerwald Date: Tue Jun 12 19:43:43 2007 New Revision: 55935 Modified: python/branches/py3k-struni/Lib/test/test_shlex.py Log: Fix test_shlex: Use io.StringIO. Modified: python/branches/py3k-struni/Lib/test/test_shlex.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_shlex.py (original) +++ python/branches/py3k-struni/Lib/test/test_shlex.py Tue Jun 12 19:43:43 2007 @@ -1,15 +1,10 @@ # -*- coding: iso-8859-1 -*- import unittest -import os, sys +import os, sys, io import shlex from test import test_support -try: - from cStringIO import StringIO -except ImportError: - from StringIO import StringIO - # The original test data set was from shellwords, by Hartmut Goebel. @@ -160,7 +155,7 @@ def oldSplit(self, s): ret = [] - lex = shlex.shlex(StringIO(s)) + lex = shlex.shlex(io.StringIO(s)) tok = lex.get_token() while tok: ret.append(tok) From python-3000-checkins at python.org Tue Jun 12 20:07:44 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Tue, 12 Jun 2007 20:07:44 +0200 (CEST) Subject: [Python-3000-checkins] r55936 - python/branches/py3k-struni/Lib/tarfile.py Message-ID: <20070612180744.97E931E400D@bag.python.org> Author: walter.doerwald Date: Tue Jun 12 20:07:38 2007 New Revision: 55936 Modified: python/branches/py3k-struni/Lib/tarfile.py Log: unicode is named str now => fix type check. Modified: python/branches/py3k-struni/Lib/tarfile.py ============================================================================== --- python/branches/py3k-struni/Lib/tarfile.py (original) +++ python/branches/py3k-struni/Lib/tarfile.py Tue Jun 12 20:07:38 2007 @@ -978,7 +978,7 @@ info["name"] += "/" for key in ("name", "linkname", "uname", "gname"): - if type(info[key]) is unicode: + if isinstance(info[key], str): info[key] = info[key].encode(encoding, errors) return info From python-3000-checkins at python.org Tue Jun 12 22:57:54 2007 From: python-3000-checkins at python.org (collin.winter) Date: Tue, 12 Jun 2007 22:57:54 +0200 (CEST) Subject: [Python-3000-checkins] r55939 - in python/branches/p3yk: Doc/api/exceptions.tex Doc/lib/libdecimal.tex Doc/lib/libexcs.tex Doc/tut/tut.tex Include/pyerrors.h Lib/bsddb/dbtables.py Lib/sqlite3/test/dbapi.py Lib/test/exception_hierarchy.txt Lib/test/test_cgi.py Lib/test/test_pep352.py Lib/test/tf_inherit_check.py Lib/xml/dom/domreg.py Misc/Vim/python.vim Misc/cheatsheet Misc/python-mode.el Modules/_sqlite/module.c Objects/exceptions.c PC/os2emx/python25.def PC/os2vacpp/python.def Message-ID: <20070612205754.7AC601E4004@bag.python.org> Author: collin.winter Date: Tue Jun 12 22:57:33 2007 New Revision: 55939 Modified: python/branches/p3yk/Doc/api/exceptions.tex python/branches/p3yk/Doc/lib/libdecimal.tex python/branches/p3yk/Doc/lib/libexcs.tex python/branches/p3yk/Doc/tut/tut.tex python/branches/p3yk/Include/pyerrors.h python/branches/p3yk/Lib/bsddb/dbtables.py python/branches/p3yk/Lib/sqlite3/test/dbapi.py python/branches/p3yk/Lib/test/exception_hierarchy.txt python/branches/p3yk/Lib/test/test_cgi.py python/branches/p3yk/Lib/test/test_pep352.py python/branches/p3yk/Lib/test/tf_inherit_check.py python/branches/p3yk/Lib/xml/dom/domreg.py python/branches/p3yk/Misc/Vim/python.vim python/branches/p3yk/Misc/cheatsheet python/branches/p3yk/Misc/python-mode.el python/branches/p3yk/Modules/_sqlite/module.c python/branches/p3yk/Objects/exceptions.c python/branches/p3yk/PC/os2emx/python25.def python/branches/p3yk/PC/os2vacpp/python.def Log: Patch #1735485: remove StandardError from the exception hierarchy. Modified: python/branches/p3yk/Doc/api/exceptions.tex ============================================================================== --- python/branches/p3yk/Doc/api/exceptions.tex (original) +++ python/branches/p3yk/Doc/api/exceptions.tex Tue Jun 12 22:57:33 2007 @@ -381,7 +381,6 @@ \begin{tableiii}{l|l|c}{cdata}{C Name}{Python Name}{Notes} \lineiii{PyExc_BaseException\ttindex{PyExc_BaseException}}{\exception{BaseException}}{(1), (4)} \lineiii{PyExc_Exception\ttindex{PyExc_Exception}}{\exception{Exception}}{(1)} - \lineiii{PyExc_StandardError\ttindex{PyExc_StandardError}}{\exception{StandardError}}{(1)} \lineiii{PyExc_ArithmeticError\ttindex{PyExc_ArithmeticError}}{\exception{ArithmeticError}}{(1)} \lineiii{PyExc_LookupError\ttindex{PyExc_LookupError}}{\exception{LookupError}}{(1)} \lineiii{PyExc_AssertionError\ttindex{PyExc_AssertionError}}{\exception{AssertionError}}{} Modified: python/branches/p3yk/Doc/lib/libdecimal.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libdecimal.tex (original) +++ python/branches/p3yk/Doc/lib/libdecimal.tex Tue Jun 12 22:57:33 2007 @@ -845,7 +845,7 @@ The following table summarizes the hierarchy of signals: \begin{verbatim} - exceptions.ArithmeticError(exceptions.StandardError) + exceptions.ArithmeticError(exceptions.Exception) DecimalException Clamped DivisionByZero(DecimalException, exceptions.ZeroDivisionError) Modified: python/branches/p3yk/Doc/lib/libexcs.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libexcs.tex (original) +++ python/branches/p3yk/Doc/lib/libexcs.tex Tue Jun 12 22:57:33 2007 @@ -64,13 +64,6 @@ \versionchanged[Changed to inherit from \exception{BaseException}]{2.5} \end{excdesc} -\begin{excdesc}{StandardError} -The base class for all built-in exceptions except -\exception{StopIteration}, \exception{GeneratorExit}, -\exception{KeyboardInterrupt} and \exception{SystemExit}. -\exception{StandardError} itself is derived from \exception{Exception}. -\end{excdesc} - \begin{excdesc}{ArithmeticError} The base class for those built-in exceptions that are raised for various arithmetic errors: \exception{OverflowError}, @@ -143,9 +136,9 @@ \begin{excdesc}{GeneratorExit} Raise when a generator's \method{close()} method is called. - It directly inherits from \exception{Exception} instead of - \exception{StandardError} since it is technically not an error. \versionadded{2.5} + \versionchanged[Changed to inherit from Exception instead of + StandardError]{3.0} \end{excdesc} \begin{excdesc}{IOError} @@ -257,10 +250,9 @@ \begin{excdesc}{StopIteration} Raised by builtin \function{next()} and an iterator's \method{__next__()} method to signal that there are no further values. - This is derived from \exception{Exception} rather than - \exception{StandardError}, since this is not considered an error in - its normal application. \versionadded{2.2} + \versionchanged[Changed to inherit from Exception instead of + StandardError]{3.0} \end{excdesc} @@ -304,7 +296,7 @@ Instances have an attribute \member{code} which is set to the proposed exit status or error message (defaulting to \code{None}). Also, this exception derives directly from \exception{BaseException} and - not \exception{StandardError}, since it is not technically an error. + not \exception{Exception}, since it is not technically an error. A call to \function{sys.exit()} is translated into an exception so that clean-up handlers (\keyword{finally} clauses of \keyword{try} statements) @@ -315,7 +307,7 @@ \function{fork()}). The exception inherits from \exception{BaseException} instead of - \exception{StandardError} or \exception{Exception} so that it is not + \exception{Exception} so that it is not accidentally caught by code that catches \exception{Exception}. This allows the exception to properly propagate up and cause the interpreter to exit. \versionchanged[Changed to inherit from \exception{BaseException}]{2.5} Modified: python/branches/p3yk/Doc/tut/tut.tex ============================================================================== --- python/branches/p3yk/Doc/tut/tut.tex (original) +++ python/branches/p3yk/Doc/tut/tut.tex Tue Jun 12 22:57:33 2007 @@ -2689,7 +2689,7 @@ 'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'ReferenceError', 'RuntimeError', - 'RuntimeWarning', 'StandardError', 'StopIteration', 'SyntaxError', + 'RuntimeWarning', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'True', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', Modified: python/branches/p3yk/Include/pyerrors.h ============================================================================== --- python/branches/p3yk/Include/pyerrors.h (original) +++ python/branches/p3yk/Include/pyerrors.h Tue Jun 12 22:57:33 2007 @@ -107,7 +107,6 @@ PyAPI_DATA(PyObject *) PyExc_Exception; PyAPI_DATA(PyObject *) PyExc_StopIteration; PyAPI_DATA(PyObject *) PyExc_GeneratorExit; -PyAPI_DATA(PyObject *) PyExc_StandardError; PyAPI_DATA(PyObject *) PyExc_ArithmeticError; PyAPI_DATA(PyObject *) PyExc_LookupError; Modified: python/branches/p3yk/Lib/bsddb/dbtables.py ============================================================================== --- python/branches/p3yk/Lib/bsddb/dbtables.py (original) +++ python/branches/p3yk/Lib/bsddb/dbtables.py Tue Jun 12 22:57:33 2007 @@ -38,7 +38,7 @@ class DBIncompleteError(Exception): pass -class TableDBError(StandardError): +class TableDBError(Exception): pass class TableAlreadyExists(TableDBError): pass Modified: python/branches/p3yk/Lib/sqlite3/test/dbapi.py ============================================================================== --- python/branches/p3yk/Lib/sqlite3/test/dbapi.py (original) +++ python/branches/p3yk/Lib/sqlite3/test/dbapi.py Tue Jun 12 22:57:33 2007 @@ -40,12 +40,12 @@ sqlite.paramstyle) def CheckWarning(self): - self.assert_(issubclass(sqlite.Warning, StandardError), - "Warning is not a subclass of StandardError") + self.assert_(issubclass(sqlite.Warning, Exception), + "Warning is not a subclass of Exception") def CheckError(self): - self.failUnless(issubclass(sqlite.Error, StandardError), - "Error is not a subclass of StandardError") + self.failUnless(issubclass(sqlite.Error, Exception), + "Error is not a subclass of Exception") def CheckInterfaceError(self): self.failUnless(issubclass(sqlite.InterfaceError, sqlite.Error), Modified: python/branches/p3yk/Lib/test/exception_hierarchy.txt ============================================================================== --- python/branches/p3yk/Lib/test/exception_hierarchy.txt (original) +++ python/branches/p3yk/Lib/test/exception_hierarchy.txt Tue Jun 12 22:57:33 2007 @@ -4,39 +4,38 @@ +-- Exception +-- GeneratorExit +-- StopIteration - +-- StandardError - | +-- ArithmeticError - | | +-- FloatingPointError - | | +-- OverflowError - | | +-- ZeroDivisionError - | +-- AssertionError - | +-- AttributeError - | +-- EnvironmentError - | | +-- IOError - | | +-- OSError - | | +-- WindowsError (Windows) - | | +-- VMSError (VMS) - | +-- EOFError - | +-- ImportError - | +-- LookupError - | | +-- IndexError - | | +-- KeyError - | +-- MemoryError - | +-- NameError - | | +-- UnboundLocalError - | +-- ReferenceError - | +-- RuntimeError - | | +-- NotImplementedError - | +-- SyntaxError - | | +-- IndentationError - | | +-- TabError - | +-- SystemError - | +-- TypeError - | +-- ValueError - | | +-- UnicodeError - | | +-- UnicodeDecodeError - | | +-- UnicodeEncodeError - | | +-- UnicodeTranslateError + +-- ArithmeticError + | +-- FloatingPointError + | +-- OverflowError + | +-- ZeroDivisionError + +-- AssertionError + +-- AttributeError + +-- EnvironmentError + | +-- IOError + | +-- OSError + | +-- WindowsError (Windows) + | +-- VMSError (VMS) + +-- EOFError + +-- ImportError + +-- LookupError + | +-- IndexError + | +-- KeyError + +-- MemoryError + +-- NameError + | +-- UnboundLocalError + +-- ReferenceError + +-- RuntimeError + | +-- NotImplementedError + +-- SyntaxError + | +-- IndentationError + | +-- TabError + +-- SystemError + +-- TypeError + +-- ValueError + | +-- UnicodeError + | +-- UnicodeDecodeError + | +-- UnicodeEncodeError + | +-- UnicodeTranslateError +-- Warning +-- DeprecationWarning +-- PendingDeprecationWarning Modified: python/branches/p3yk/Lib/test/test_cgi.py ============================================================================== --- python/branches/p3yk/Lib/test/test_cgi.py (original) +++ python/branches/p3yk/Lib/test/test_cgi.py Tue Jun 12 22:57:33 2007 @@ -50,7 +50,7 @@ raise ValueError, "unknown method: %s" % method try: return cgi.parse(fp, env, strict_parsing=1) - except StandardError as err: + except Exception as err: return ComparableException(err) # A list of test cases. Each test case is a a two-tuple that contains Modified: python/branches/p3yk/Lib/test/test_pep352.py ============================================================================== --- python/branches/p3yk/Lib/test/test_pep352.py (original) +++ python/branches/p3yk/Lib/test/test_pep352.py Tue Jun 12 22:57:33 2007 @@ -133,22 +133,22 @@ """Catching 'object_' should raise a TypeError.""" try: try: - raise StandardError + raise Exception except object_: pass except TypeError: pass - except StandardError: + except Exception: self.fail("TypeError expected when catching %s" % type(object_)) try: try: - raise StandardError + raise Exception except (object_,): pass except TypeError: return - except StandardError: + except Exception: self.fail("TypeError expected when catching %s as specified in a " "tuple" % type(object_)) Modified: python/branches/p3yk/Lib/test/tf_inherit_check.py ============================================================================== --- python/branches/p3yk/Lib/test/tf_inherit_check.py (original) +++ python/branches/p3yk/Lib/test/tf_inherit_check.py Tue Jun 12 22:57:33 2007 @@ -19,7 +19,7 @@ sys.stderr.write("fd %d is open in child" % fd) sys.exit(1) -except StandardError: +except Exception: if verbose: raise sys.exit(1) Modified: python/branches/p3yk/Lib/xml/dom/domreg.py ============================================================================== --- python/branches/p3yk/Lib/xml/dom/domreg.py (original) +++ python/branches/p3yk/Lib/xml/dom/domreg.py Tue Jun 12 22:57:33 2007 @@ -72,7 +72,7 @@ for creator in well_known_implementations.keys(): try: dom = getDOMImplementation(name = creator) - except StandardError: # typically ImportError, or AttributeError + except Exception: # typically ImportError, or AttributeError continue if _good_enough(dom, features): return dom Modified: python/branches/p3yk/Misc/Vim/python.vim ============================================================================== --- python/branches/p3yk/Misc/Vim/python.vim (original) +++ python/branches/p3yk/Misc/Vim/python.vim Tue Jun 12 22:57:33 2007 @@ -88,7 +88,7 @@ syn keyword pythonException MemoryError NameError NotImplementedError syn keyword pythonException OSError OverflowError PendingDeprecationWarning syn keyword pythonException ReferenceError RuntimeError RuntimeWarning - syn keyword pythonException StandardError StopIteration SyntaxError + syn keyword pythonException StopIteration SyntaxError syn keyword pythonException SyntaxWarning SystemError SystemExit TabError syn keyword pythonException TypeError UnboundLocalError UnicodeDecodeError syn keyword pythonException UnicodeEncodeError UnicodeError Modified: python/branches/p3yk/Misc/cheatsheet ============================================================================== --- python/branches/p3yk/Misc/cheatsheet (original) +++ python/branches/p3yk/Misc/cheatsheet Tue Jun 12 22:57:33 2007 @@ -779,8 +779,8 @@ class, the class name is printed, then a colon and a space, and finally the instance converted to a string using the built-in function str(). -All built-in exception classes derives from StandardError, itself -derived from Exception. +All built-in exception classes derives from Exception, itself +derived from BaseException. Name Space Statements @@ -1051,9 +1051,6 @@ On 'sys.exit()' StopIteration Signal the end from iterator.__next__() - StandardError - Base class for all built-in exceptions; derived from Exception - root class. ArithmeticError Base class for OverflowError, ZeroDivisionError, FloatingPointError Modified: python/branches/p3yk/Misc/python-mode.el ============================================================================== --- python/branches/p3yk/Misc/python-mode.el (original) +++ python/branches/p3yk/Misc/python-mode.el Tue Jun 12 22:57:33 2007 @@ -369,7 +369,7 @@ "NotImplementedError" "OSError" "OverflowError" "OverflowWarning" "PendingDeprecationWarning" "ReferenceError" "RuntimeError" "RuntimeWarning" - "StandardError" "StopIteration" "SyntaxError" + "StopIteration" "SyntaxError" "SyntaxWarning" "SystemError" "SystemExit" "TabError" "True" "TypeError" "UnboundLocalError" "UnicodeDecodeError" "UnicodeEncodeError" Modified: python/branches/p3yk/Modules/_sqlite/module.c ============================================================================== --- python/branches/p3yk/Modules/_sqlite/module.c (original) +++ python/branches/p3yk/Modules/_sqlite/module.c Tue Jun 12 22:57:33 2007 @@ -287,12 +287,12 @@ /*** Create DB-API Exception hierarchy */ - if (!(pysqlite_Error = PyErr_NewException(MODULE_NAME ".Error", PyExc_StandardError, NULL))) { + if (!(pysqlite_Error = PyErr_NewException(MODULE_NAME ".Error", PyExc_Exception, NULL))) { goto error; } PyDict_SetItemString(dict, "Error", pysqlite_Error); - if (!(pysqlite_Warning = PyErr_NewException(MODULE_NAME ".Warning", PyExc_StandardError, NULL))) { + if (!(pysqlite_Warning = PyErr_NewException(MODULE_NAME ".Warning", PyExc_Exception, NULL))) { goto error; } PyDict_SetItemString(dict, "Warning", pysqlite_Warning); Modified: python/branches/p3yk/Objects/exceptions.c ============================================================================== --- python/branches/p3yk/Objects/exceptions.c (original) +++ python/branches/p3yk/Objects/exceptions.c Tue Jun 12 22:57:33 2007 @@ -334,17 +334,9 @@ /* - * StandardError extends Exception + * TypeError extends Exception */ -SimpleExtendsException(PyExc_Exception, StandardError, - "Base class for all standard Python exceptions that do not represent\n" - "interpreter exiting."); - - -/* - * TypeError extends StandardError - */ -SimpleExtendsException(PyExc_StandardError, TypeError, +SimpleExtendsException(PyExc_Exception, TypeError, "Inappropriate argument type."); @@ -425,14 +417,14 @@ /* - * ImportError extends StandardError + * ImportError extends Exception */ -SimpleExtendsException(PyExc_StandardError, ImportError, +SimpleExtendsException(PyExc_Exception, ImportError, "Import can't find module, or can't find name in module."); /* - * EnvironmentError extends StandardError + * EnvironmentError extends Exception */ /* Where a function has a single filename, such as open() or some @@ -657,7 +649,7 @@ {NULL} }; -ComplexExtendsException(PyExc_StandardError, EnvironmentError, +ComplexExtendsException(PyExc_Exception, EnvironmentError, EnvironmentError, EnvironmentError_dealloc, EnvironmentError_methods, EnvironmentError_members, EnvironmentError_str, @@ -867,16 +859,16 @@ /* - * EOFError extends StandardError + * EOFError extends Exception */ -SimpleExtendsException(PyExc_StandardError, EOFError, +SimpleExtendsException(PyExc_Exception, EOFError, "Read beyond end of file."); /* - * RuntimeError extends StandardError + * RuntimeError extends Exception */ -SimpleExtendsException(PyExc_StandardError, RuntimeError, +SimpleExtendsException(PyExc_Exception, RuntimeError, "Unspecified run-time error."); @@ -887,9 +879,9 @@ "Method or function hasn't been implemented yet."); /* - * NameError extends StandardError + * NameError extends Exception */ -SimpleExtendsException(PyExc_StandardError, NameError, +SimpleExtendsException(PyExc_Exception, NameError, "Name not found globally."); /* @@ -899,14 +891,14 @@ "Local name referenced but not bound to a value."); /* - * AttributeError extends StandardError + * AttributeError extends Exception */ -SimpleExtendsException(PyExc_StandardError, AttributeError, +SimpleExtendsException(PyExc_Exception, AttributeError, "Attribute not found."); /* - * SyntaxError extends StandardError + * SyntaxError extends Exception */ static int @@ -1085,7 +1077,7 @@ {NULL} /* Sentinel */ }; -ComplexExtendsException(PyExc_StandardError, SyntaxError, SyntaxError, +ComplexExtendsException(PyExc_Exception, SyntaxError, SyntaxError, SyntaxError_dealloc, 0, SyntaxError_members, SyntaxError_str, "Invalid syntax."); @@ -1105,9 +1097,9 @@ /* - * LookupError extends StandardError + * LookupError extends Exception */ -SimpleExtendsException(PyExc_StandardError, LookupError, +SimpleExtendsException(PyExc_Exception, LookupError, "Base class for lookup errors."); @@ -1144,9 +1136,9 @@ /* - * ValueError extends StandardError + * ValueError extends Exception */ -SimpleExtendsException(PyExc_StandardError, ValueError, +SimpleExtendsException(PyExc_Exception, ValueError, "Inappropriate argument value (of correct type)."); /* @@ -1763,16 +1755,16 @@ /* - * AssertionError extends StandardError + * AssertionError extends Exception */ -SimpleExtendsException(PyExc_StandardError, AssertionError, +SimpleExtendsException(PyExc_Exception, AssertionError, "Assertion failed."); /* - * ArithmeticError extends StandardError + * ArithmeticError extends Exception */ -SimpleExtendsException(PyExc_StandardError, ArithmeticError, +SimpleExtendsException(PyExc_Exception, ArithmeticError, "Base class for arithmetic errors."); @@ -1798,9 +1790,9 @@ /* - * SystemError extends StandardError + * SystemError extends Exception */ -SimpleExtendsException(PyExc_StandardError, SystemError, +SimpleExtendsException(PyExc_Exception, SystemError, "Internal error in the Python interpreter.\n" "\n" "Please report this to the Python maintainer, along with the traceback,\n" @@ -1808,16 +1800,16 @@ /* - * ReferenceError extends StandardError + * ReferenceError extends Exception */ -SimpleExtendsException(PyExc_StandardError, ReferenceError, +SimpleExtendsException(PyExc_Exception, ReferenceError, "Weak ref proxy used after referent went away."); /* - * MemoryError extends StandardError + * MemoryError extends Exception */ -SimpleExtendsException(PyExc_StandardError, MemoryError, "Out of memory."); +SimpleExtendsException(PyExc_Exception, MemoryError, "Out of memory."); /* Warning category docstrings */ @@ -1930,7 +1922,6 @@ PRE_INIT(BaseException) PRE_INIT(Exception) - PRE_INIT(StandardError) PRE_INIT(TypeError) PRE_INIT(StopIteration) PRE_INIT(GeneratorExit) @@ -1992,7 +1983,6 @@ POST_INIT(BaseException) POST_INIT(Exception) - POST_INIT(StandardError) POST_INIT(TypeError) POST_INIT(StopIteration) POST_INIT(GeneratorExit) Modified: python/branches/p3yk/PC/os2emx/python25.def ============================================================================== --- python/branches/p3yk/PC/os2emx/python25.def (original) +++ python/branches/p3yk/PC/os2emx/python25.def Tue Jun 12 22:57:33 2007 @@ -767,7 +767,6 @@ "_PyExc_Fini" "PyExc_BaseException" "PyExc_Exception" - "PyExc_StandardError" "PyExc_TypeError" "PyExc_StopIteration" "PyExc_GeneratorExit" Modified: python/branches/p3yk/PC/os2vacpp/python.def ============================================================================== --- python/branches/p3yk/PC/os2vacpp/python.def (original) +++ python/branches/p3yk/PC/os2vacpp/python.def Tue Jun 12 22:57:33 2007 @@ -30,7 +30,6 @@ PyExc_OSError PyExc_OverflowError PyExc_RuntimeError - PyExc_StandardError PyExc_SyntaxError PyExc_SystemError PyExc_SystemExit From python-3000-checkins at python.org Wed Jun 13 01:30:27 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Wed, 13 Jun 2007 01:30:27 +0200 (CEST) Subject: [Python-3000-checkins] r55943 - in python/branches/py3k-struni: Include/fileobject.h Include/sysmodule.h Modules/_cursesmodule.c Modules/bz2module.c Modules/cPickle.c Modules/pyexpat.c Objects/fileobject.c Parser/tokenizer.c Python/bltinmodule.c Python/import.c Python/marshal.c Python/pythonrun.c Python/sysmodule.c runtests.sh Message-ID: <20070612233027.D6B201E4005@bag.python.org> Author: guido.van.rossum Date: Wed Jun 13 01:30:11 2007 New Revision: 55943 Modified: python/branches/py3k-struni/Include/fileobject.h python/branches/py3k-struni/Include/sysmodule.h python/branches/py3k-struni/Modules/_cursesmodule.c python/branches/py3k-struni/Modules/bz2module.c python/branches/py3k-struni/Modules/cPickle.c python/branches/py3k-struni/Modules/pyexpat.c python/branches/py3k-struni/Objects/fileobject.c python/branches/py3k-struni/Parser/tokenizer.c python/branches/py3k-struni/Python/bltinmodule.c python/branches/py3k-struni/Python/import.c python/branches/py3k-struni/Python/marshal.c python/branches/py3k-struni/Python/pythonrun.c python/branches/py3k-struni/Python/sysmodule.c python/branches/py3k-struni/runtests.sh Log: Rip out the file object's implementation. Fixed test_import.py while I was at it. However, there's still a problem in import.c -- get_file() can leak a FILE struct (not a file descriptor though). I'm not sure how to fix this; closing the FILE* closes the file descriptor, and that's the wrong thing to do when there's still a Python file object keeping the file descriptor open. I also would rather not mess with dup(), as it won't port to Windows. Modified: python/branches/py3k-struni/Include/fileobject.h ============================================================================== --- python/branches/py3k-struni/Include/fileobject.h (original) +++ python/branches/py3k-struni/Include/fileobject.h Wed Jun 13 01:30:11 2007 @@ -1,5 +1,4 @@ - -/* File object interface */ +/* File object interface (what's left of it -- see io.py) */ #ifndef Py_FILEOBJECT_H #define Py_FILEOBJECT_H @@ -7,59 +6,20 @@ extern "C" { #endif -typedef struct { - PyObject_HEAD - FILE *f_fp; - PyObject *f_name; - PyObject *f_mode; - int (*f_close)(FILE *); - int f_binary; /* Flag which indicates whether the file is - open in binary (1) or text (0) mode */ - char* f_buf; /* Allocated readahead buffer */ - char* f_bufend; /* Points after last occupied position */ - char* f_bufptr; /* Current buffer position */ - char *f_setbuf; /* Buffer for setbuf(3) and setvbuf(3) */ - int f_univ_newline; /* Handle any newline convention */ - int f_newlinetypes; /* Types of newlines seen */ - int f_skipnextlf; /* Skip next \n */ - PyObject *f_encoding; - PyObject *weakreflist; /* List of weak references */ -} PyFileObject; - -PyAPI_DATA(PyTypeObject) PyFile_Type; - -#define PyFile_Check(op) PyObject_TypeCheck(op, &PyFile_Type) -#define PyFile_CheckExact(op) ((op)->ob_type == &PyFile_Type) +#define PY_STDIOTEXTMODE "b" -PyAPI_FUNC(PyObject *) PyFile_FromString(char *, char *); -PyAPI_FUNC(void) PyFile_SetBufSize(PyObject *, int); -PyAPI_FUNC(int) PyFile_SetEncoding(PyObject *, const char *); -PyAPI_FUNC(PyObject *) PyFile_FromFile(FILE *, char *, char *, - int (*)(FILE *)); -PyAPI_FUNC(FILE *) PyFile_AsFile(PyObject *); -PyAPI_FUNC(PyObject *) PyFile_Name(PyObject *); +PyAPI_FUNC(PyObject *) PyFile_FromFile(FILE *, char *, char *, int (*)(FILE*)); PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int); PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int); PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *); PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *); +PyAPI_FUNC(char *) Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *); /* The default encoding used by the platform file system APIs If non-NULL, this is different than the default encoding for strings */ PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding; -/* Routines to replace fread() and fgets() which accept any of \r, \n - or \r\n as line terminators. -*/ -#define PY_STDIOTEXTMODE "b" -char *Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *); -size_t Py_UniversalNewlineFread(char *, size_t, FILE *, PyObject *); - -/* A routine to do sanity checking on the file mode string. returns - non-zero on if an exception occurred -*/ -int _PyFile_SanitizeMode(char *mode); - #ifdef __cplusplus } #endif Modified: python/branches/py3k-struni/Include/sysmodule.h ============================================================================== --- python/branches/py3k-struni/Include/sysmodule.h (original) +++ python/branches/py3k-struni/Include/sysmodule.h Wed Jun 13 01:30:11 2007 @@ -9,7 +9,6 @@ PyAPI_FUNC(PyObject *) PySys_GetObject(char *); PyAPI_FUNC(int) PySys_SetObject(char *, PyObject *); -PyAPI_FUNC(FILE *) PySys_GetFile(char *, FILE *); PyAPI_FUNC(void) PySys_SetArgv(int, char **); PyAPI_FUNC(void) PySys_SetPath(char *); Modified: python/branches/py3k-struni/Modules/_cursesmodule.c ============================================================================== --- python/branches/py3k-struni/Modules/_cursesmodule.c (original) +++ python/branches/py3k-struni/Modules/_cursesmodule.c Wed Jun 13 01:30:11 2007 @@ -1287,12 +1287,13 @@ if (!PyArg_ParseTuple(args, "O;fileobj", &temp)) return NULL; - if (!PyFile_Check(temp)) { - PyErr_SetString(PyExc_TypeError, "argument must be a file object"); - return NULL; - } + PyErr_SetString(PyExc_TypeError, "argument must be a file object"); + return NULL; + +#if 0 return PyCursesCheckERR(putwin(self->win, PyFile_AsFile(temp)), "putwin"); +#endif } static PyObject * @@ -1748,11 +1749,10 @@ PyCursesInitialised - if (!PyFile_Check(temp)) { - PyErr_SetString(PyExc_TypeError, "argument must be a file object"); - return NULL; - } + PyErr_SetString(PyExc_TypeError, "argument must be a file object"); + return NULL; +#if 0 win = getwin(PyFile_AsFile(temp)); if (win == NULL) { @@ -1761,6 +1761,7 @@ } return PyCursesWindow_New(win); +#endif } static PyObject * Modified: python/branches/py3k-struni/Modules/bz2module.c ============================================================================== --- python/branches/py3k-struni/Modules/bz2module.c (original) +++ python/branches/py3k-struni/Modules/bz2module.c Wed Jun 13 01:30:11 2007 @@ -1075,6 +1075,7 @@ offset -= self->pos; } else { /* we cannot move back, so rewind the stream */ + FILE *fp = NULL; /* XXX temporary!!! */ BZ2_bzReadClose(&bzerror, self->fp); if (bzerror != BZ_OK) { Util_CatchBZ2Error(bzerror); @@ -1086,7 +1087,7 @@ Py_DECREF(ret); ret = NULL; self->pos = 0; - self->fp = BZ2_bzReadOpen(&bzerror, PyFile_AsFile(self->file), + self->fp = BZ2_bzReadOpen(&bzerror, fp, 0, 0, NULL, 0); if (bzerror != BZ_OK) { Util_CatchBZ2Error(bzerror); @@ -1286,6 +1287,7 @@ { static char *kwlist[] = {"filename", "mode", "buffering", "compresslevel", 0}; + FILE *fp = NULL; /* XXX temporary!!! */ PyObject *name; char *mode = "r"; int buffering = -1; @@ -1347,8 +1349,8 @@ mode = (mode_char == 'r') ? "rb" : "wb"; - self->file = PyObject_CallFunction((PyObject*)&PyFile_Type, "(Osi)", - name, mode, buffering); + self->file = NULL; /* XXX io.open(name, mode, buffering); */ + PyErr_SetString(PyExc_RuntimeError, "can't open bz2 files yet"); if (self->file == NULL) return -1; @@ -1365,11 +1367,11 @@ if (mode_char == 'r') self->fp = BZ2_bzReadOpen(&bzerror, - PyFile_AsFile(self->file), + fp, 0, 0, NULL, 0); else self->fp = BZ2_bzWriteOpen(&bzerror, - PyFile_AsFile(self->file), + fp, compresslevel, 0, 0); if (bzerror != BZ_OK) { Modified: python/branches/py3k-struni/Modules/cPickle.c ============================================================================== --- python/branches/py3k-struni/Modules/cPickle.c (original) +++ python/branches/py3k-struni/Modules/cPickle.c Wed Jun 13 01:30:11 2007 @@ -418,31 +418,6 @@ } static int -write_file(Picklerobject *self, const char *s, Py_ssize_t n) -{ - size_t nbyteswritten; - - if (s == NULL) { - return 0; - } - - if (n > INT_MAX) { - /* String too large */ - return -1; - } - - Py_BEGIN_ALLOW_THREADS - nbyteswritten = fwrite(s, sizeof(char), n, self->fp); - Py_END_ALLOW_THREADS - if (nbyteswritten != (size_t)n) { - PyErr_SetFromErrno(PyExc_IOError); - return -1; - } - - return (int)n; -} - -static int write_cStringIO(Picklerobject *self, const char *s, Py_ssize_t n) { if (s == NULL) { @@ -517,92 +492,6 @@ static Py_ssize_t -read_file(Unpicklerobject *self, char **s, Py_ssize_t n) -{ - size_t nbytesread; - - if (self->buf_size == 0) { - int size; - - size = ((n < 32) ? 32 : n); - if (!( self->buf = (char *)malloc(size))) { - PyErr_NoMemory(); - return -1; - } - - self->buf_size = size; - } - else if (n > self->buf_size) { - char *newbuf = (char *)realloc(self->buf, n); - if (!newbuf) { - PyErr_NoMemory(); - return -1; - } - self->buf = newbuf; - self->buf_size = n; - } - - Py_BEGIN_ALLOW_THREADS - nbytesread = fread(self->buf, sizeof(char), n, self->fp); - Py_END_ALLOW_THREADS - if (nbytesread != (size_t)n) { - if (feof(self->fp)) { - PyErr_SetNone(PyExc_EOFError); - return -1; - } - - PyErr_SetFromErrno(PyExc_IOError); - return -1; - } - - *s = self->buf; - - return n; -} - - -static Py_ssize_t -readline_file(Unpicklerobject *self, char **s) -{ - int i; - - if (self->buf_size == 0) { - if (!( self->buf = (char *)malloc(40))) { - PyErr_NoMemory(); - return -1; - } - self->buf_size = 40; - } - - i = 0; - while (1) { - int bigger; - char *newbuf; - for (; i < (self->buf_size - 1); i++) { - if (feof(self->fp) || - (self->buf[i] = getc(self->fp)) == '\n') { - self->buf[i + 1] = '\0'; - *s = self->buf; - return i + 1; - } - } - bigger = self->buf_size << 1; - if (bigger <= 0) { /* overflow */ - PyErr_NoMemory(); - return -1; - } - newbuf = (char *)realloc(self->buf, bigger); - if (!newbuf) { - PyErr_NoMemory(); - return -1; - } - self->buf = newbuf; - self->buf_size = bigger; - } -} - - -static Py_ssize_t read_cStringIO(Unpicklerobject *self, char **s, Py_ssize_t n) { char *ptr; @@ -2665,16 +2554,7 @@ if (!( self->memo = PyDict_New())) goto err; - if (PyFile_Check(file)) { - self->fp = PyFile_AsFile(file); - if (self->fp == NULL) { - PyErr_SetString(PyExc_ValueError, - "I/O operation on closed file"); - goto err; - } - self->write_func = write_file; - } - else if (PycStringIO_OutputCheck(file)) { + if (PycStringIO_OutputCheck(file)) { self->write_func = write_cStringIO; } else if (file == Py_None) { @@ -4988,17 +4868,7 @@ self->file = f; /* Set read, readline based on type of f */ - if (PyFile_Check(f)) { - self->fp = PyFile_AsFile(f); - if (self->fp == NULL) { - PyErr_SetString(PyExc_ValueError, - "I/O operation on closed file"); - goto err; - } - self->read_func = read_file; - self->readline_func = readline_file; - } - else if (PycStringIO_InputCheck(f)) { + if (PycStringIO_InputCheck(f)) { self->fp = NULL; self->read_func = read_cStringIO; self->readline_func = readline_cStringIO; Modified: python/branches/py3k-struni/Modules/pyexpat.c ============================================================================== --- python/branches/py3k-struni/Modules/pyexpat.c (original) +++ python/branches/py3k-struni/Modules/pyexpat.c Wed Jun 13 01:30:11 2007 @@ -956,10 +956,7 @@ FILE *fp; PyObject *readmethod = NULL; - if (PyFile_Check(f)) { - fp = PyFile_AsFile(f); - } - else { + { fp = NULL; readmethod = PyObject_GetAttrString(f, "read"); if (readmethod == NULL) { Modified: python/branches/py3k-struni/Objects/fileobject.c ============================================================================== --- python/branches/py3k-struni/Objects/fileobject.c (original) +++ python/branches/py3k-struni/Objects/fileobject.c Wed Jun 13 01:30:11 2007 @@ -1,36 +1,7 @@ -/* File object implementation */ +/* File object implementation (what's left of it -- see io.py) */ #define PY_SSIZE_T_CLEAN #include "Python.h" -#include "structmember.h" - -#ifdef HAVE_SYS_TYPES_H -#include -#endif /* HAVE_SYS_TYPES_H */ - -#ifdef MS_WINDOWS -#define fileno _fileno -/* can simulate truncate with Win32 API functions; see file_truncate */ -#define HAVE_FTRUNCATE -#define WIN32_LEAN_AND_MEAN -#include -#endif - -#ifdef _MSC_VER -/* Need GetVersion to see if on NT so safe to use _wfopen */ -#define WIN32_LEAN_AND_MEAN -#include -#endif /* _MSC_VER */ - -#if defined(PYOS_OS2) && defined(PYCC_GCC) -#include -#endif - -#define BUF(v) PyString_AS_STRING((PyStringObject *)v) - -#ifndef DONT_HAVE_ERRNO_H -#include -#endif #ifdef HAVE_GETC_UNLOCKED #define GETC(f) getc_unlocked(f) @@ -42,7 +13,7 @@ #define FUNLOCKFILE(f) #endif -/* Bits in f_newlinetypes */ +/* Newline flags */ #define NEWLINE_UNKNOWN 0 /* No newline seen, yet */ #define NEWLINE_CR 1 /* \r newline seen */ #define NEWLINE_LF 2 /* \n newline seen */ @@ -52,1212 +23,31 @@ extern "C" { #endif -FILE * -PyFile_AsFile(PyObject *f) -{ - if (f == NULL || !PyFile_Check(f)) - return NULL; - else - return ((PyFileObject *)f)->f_fp; -} - -PyObject * -PyFile_Name(PyObject *f) -{ - if (f == NULL || !PyFile_Check(f)) - return NULL; - else - return ((PyFileObject *)f)->f_name; -} - -/* On Unix, fopen will succeed for directories. - In Python, there should be no file objects referring to - directories, so we need a check. */ - -static PyFileObject* -dircheck(PyFileObject* f) -{ -#if defined(HAVE_FSTAT) && defined(S_IFDIR) && defined(EISDIR) - struct stat buf; - if (f->f_fp == NULL) - return f; - if (fstat(fileno(f->f_fp), &buf) == 0 && - S_ISDIR(buf.st_mode)) { -#ifdef HAVE_STRERROR - char *msg = strerror(EISDIR); -#else - char *msg = "Is a directory"; -#endif - PyObject *exc = PyObject_CallFunction(PyExc_IOError, "(is)", - EISDIR, msg); - PyErr_SetObject(PyExc_IOError, exc); - Py_XDECREF(exc); - return NULL; - } -#endif - return f; -} - - -static PyObject * -fill_file_fields(PyFileObject *f, FILE *fp, PyObject *name, char *mode, - int (*close)(FILE *)) -{ - assert(name != NULL); - assert(f != NULL); - assert(PyFile_Check(f)); - assert(f->f_fp == NULL); - - Py_DECREF(f->f_name); - Py_DECREF(f->f_mode); - Py_DECREF(f->f_encoding); - - Py_INCREF(name); - f->f_name = name; - - f->f_mode = PyString_FromString(mode); - - f->f_close = close; - f->f_binary = strchr(mode,'b') != NULL; - f->f_buf = NULL; - f->f_univ_newline = (strchr(mode, 'U') != NULL); - f->f_newlinetypes = NEWLINE_UNKNOWN; - f->f_skipnextlf = 0; - Py_INCREF(Py_None); - f->f_encoding = Py_None; - - if (f->f_mode == NULL) - return NULL; - f->f_fp = fp; - f = dircheck(f); - return (PyObject *) f; -} - -/* check for known incorrect mode strings - problem is, platforms are - free to accept any mode characters they like and are supposed to - ignore stuff they don't understand... write or append mode with - universal newline support is expressly forbidden by PEP 278. - Additionally, remove the 'U' from the mode string as platforms - won't know what it is. Non-zero return signals an exception */ -int -_PyFile_SanitizeMode(char *mode) -{ - char *upos; - size_t len = strlen(mode); - - if (!len) { - PyErr_SetString(PyExc_ValueError, "empty mode string"); - return -1; - } - - upos = strchr(mode, 'U'); - if (upos) { - memmove(upos, upos+1, len-(upos-mode)); /* incl null char */ - - if (mode[0] == 'w' || mode[0] == 'a') { - PyErr_Format(PyExc_ValueError, "universal newline " - "mode can only be used with modes " - "starting with 'r'"); - return -1; - } - - if (mode[0] != 'r') { - memmove(mode+1, mode, strlen(mode)+1); - mode[0] = 'r'; - } - - if (!strchr(mode, 'b')) { - memmove(mode+2, mode+1, strlen(mode)); - mode[1] = 'b'; - } - } else if (mode[0] != 'r' && mode[0] != 'w' && mode[0] != 'a') { - PyErr_Format(PyExc_ValueError, "mode string must begin with " - "one of 'r', 'w', 'a' or 'U', not '%.200s'", mode); - return -1; - } - - return 0; -} - -static PyObject * -open_the_file(PyFileObject *f, char *name, char *mode) -{ - char *newmode; - assert(f != NULL); - assert(PyFile_Check(f)); -#ifdef MS_WINDOWS - /* windows ignores the passed name in order to support Unicode */ - assert(f->f_name != NULL); -#else - assert(name != NULL); -#endif - assert(mode != NULL); - assert(f->f_fp == NULL); - - /* probably need to replace 'U' by 'rb' */ - newmode = PyMem_MALLOC(strlen(mode) + 3); - if (!newmode) { - PyErr_NoMemory(); - return NULL; - } - strcpy(newmode, mode); - - if (_PyFile_SanitizeMode(newmode)) { - f = NULL; - goto cleanup; - } - - errno = 0; - -#ifdef MS_WINDOWS - if (PyUnicode_Check(f->f_name)) { - PyObject *wmode; - wmode = PyUnicode_DecodeASCII(newmode, strlen(newmode), NULL); - if (f->f_name && wmode) { - Py_BEGIN_ALLOW_THREADS - /* PyUnicode_AS_UNICODE OK without thread - lock as it is a simple dereference. */ - f->f_fp = _wfopen(PyUnicode_AS_UNICODE(f->f_name), - PyUnicode_AS_UNICODE(wmode)); - Py_END_ALLOW_THREADS - } - Py_XDECREF(wmode); - } -#endif - if (NULL == f->f_fp && NULL != name) { - Py_BEGIN_ALLOW_THREADS - f->f_fp = fopen(name, newmode); - Py_END_ALLOW_THREADS - } - - if (f->f_fp == NULL) { -#if defined _MSC_VER && (_MSC_VER < 1400 || !defined(__STDC_SECURE_LIB__)) - /* MSVC 6 (Microsoft) leaves errno at 0 for bad mode strings, - * across all Windows flavors. When it sets EINVAL varies - * across Windows flavors, the exact conditions aren't - * documented, and the answer lies in the OS's implementation - * of Win32's CreateFile function (whose source is secret). - * Seems the best we can do is map EINVAL to ENOENT. - * Starting with Visual Studio .NET 2005, EINVAL is correctly - * set by our CRT error handler (set in exceptions.c.) - */ - if (errno == 0) /* bad mode string */ - errno = EINVAL; - else if (errno == EINVAL) /* unknown, but not a mode string */ - errno = ENOENT; -#endif - if (errno == EINVAL) - PyErr_Format(PyExc_IOError, "invalid mode: %s", - mode); - else - PyErr_SetFromErrnoWithFilenameObject(PyExc_IOError, f->f_name); - f = NULL; - } - if (f != NULL) - f = dircheck(f); - -cleanup: - PyMem_FREE(newmode); - - return (PyObject *)f; -} +/* External C interface */ PyObject * PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE *)) { - PyObject *io = NULL, *stream = NULL; + PyObject *io, *stream, *nameobj; io = PyImport_ImportModule("io"); if (io == NULL) return NULL; - stream = PyObject_CallMethod(io, "open", "ss", name, mode); - if (stream == NULL) { - Py_XDECREF(io); - return NULL; - } - if (close != NULL) - close(fp); - return stream; -} - -PyObject * -PyFile_FromString(char *name, char *mode) -{ - extern int fclose(FILE *); - PyFileObject *f; - - f = (PyFileObject *)PyFile_FromFile((FILE *)NULL, name, mode, fclose); - if (f != NULL) { - if (open_the_file(f, name, mode) == NULL) { - Py_DECREF(f); - f = NULL; - } - } - return (PyObject *)f; -} - -void -PyFile_SetBufSize(PyObject *f, int bufsize) -{ - PyFileObject *file = (PyFileObject *)f; - if (bufsize >= 0) { - int type; - switch (bufsize) { - case 0: - type = _IONBF; - break; -#ifdef HAVE_SETVBUF - case 1: - type = _IOLBF; - bufsize = BUFSIZ; - break; -#endif - default: - type = _IOFBF; -#ifndef HAVE_SETVBUF - bufsize = BUFSIZ; -#endif - break; - } - fflush(file->f_fp); - if (type == _IONBF) { - PyMem_Free(file->f_setbuf); - file->f_setbuf = NULL; - } else { - file->f_setbuf = (char *)PyMem_Realloc(file->f_setbuf, - bufsize); - } -#ifdef HAVE_SETVBUF - setvbuf(file->f_fp, file->f_setbuf, type, bufsize); -#else /* !HAVE_SETVBUF */ - setbuf(file->f_fp, file->f_setbuf); -#endif /* !HAVE_SETVBUF */ - } -} - -/* Set the encoding used to output Unicode strings. - Returh 1 on success, 0 on failure. */ - -int -PyFile_SetEncoding(PyObject *f, const char *enc) -{ - PyFileObject *file = (PyFileObject*)f; - PyObject *str = PyString_FromString(enc); - - assert(PyFile_Check(f)); - if (!str) - return 0; - Py_DECREF(file->f_encoding); - file->f_encoding = str; - return 1; -} - -static PyObject * -err_closed(void) -{ - PyErr_SetString(PyExc_ValueError, "I/O operation on closed file"); - return NULL; -} - -/* Refuse regular file I/O if there's data in the iteration-buffer. - * Mixing them would cause data to arrive out of order, as the read* - * methods don't use the iteration buffer. */ -static PyObject * -err_iterbuffered(void) -{ - PyErr_SetString(PyExc_ValueError, - "Mixing iteration and read methods would lose data"); - return NULL; -} - -static void drop_readahead(PyFileObject *); - -/* Methods */ - -static void -file_dealloc(PyFileObject *f) -{ - int sts = 0; - if (f->weakreflist != NULL) - PyObject_ClearWeakRefs((PyObject *) f); - if (f->f_fp != NULL && f->f_close != NULL) { - Py_BEGIN_ALLOW_THREADS - sts = (*f->f_close)(f->f_fp); - Py_END_ALLOW_THREADS - if (sts == EOF) -#ifdef HAVE_STRERROR - PySys_WriteStderr("close failed: [Errno %d] %s\n", errno, strerror(errno)); -#else - PySys_WriteStderr("close failed: [Errno %d]\n", errno); -#endif - } - PyMem_Free(f->f_setbuf); - Py_XDECREF(f->f_name); - Py_XDECREF(f->f_mode); - Py_XDECREF(f->f_encoding); - drop_readahead(f); - f->ob_type->tp_free((PyObject *)f); -} - -static PyObject * -file_repr(PyFileObject *f) -{ - if (PyUnicode_Check(f->f_name)) { - PyObject *ret = NULL; - PyObject *name = PyUnicode_AsUnicodeEscapeString(f->f_name); - const char *name_str = name ? PyString_AsString(name) : "?"; - ret = PyUnicode_FromFormat("<%s file u'%s', mode '%s' at %p>", - f->f_fp == NULL ? "closed" : "open", - name_str, - PyString_AsString(f->f_mode), - f); - Py_XDECREF(name); - return ret; - } else { - return PyUnicode_FromFormat("<%s file '%s', mode '%s' at %p>", - f->f_fp == NULL ? "closed" : "open", - PyString_AsString(f->f_name), - PyString_AsString(f->f_mode), - f); - } -} - -static PyObject * -file_close(PyFileObject *f) -{ - int sts = 0; - if (f->f_fp != NULL) { - if (f->f_close != NULL) { - Py_BEGIN_ALLOW_THREADS - errno = 0; - sts = (*f->f_close)(f->f_fp); - Py_END_ALLOW_THREADS - } - f->f_fp = NULL; - } - PyMem_Free(f->f_setbuf); - f->f_setbuf = NULL; - if (sts == EOF) - return PyErr_SetFromErrno(PyExc_IOError); - if (sts != 0) - return PyInt_FromLong((long)sts); - Py_INCREF(Py_None); - return Py_None; -} - - -/* Our very own off_t-like type, 64-bit if possible */ -#if !defined(HAVE_LARGEFILE_SUPPORT) -typedef off_t Py_off_t; -#elif SIZEOF_OFF_T >= 8 -typedef off_t Py_off_t; -#elif SIZEOF_FPOS_T >= 8 -typedef fpos_t Py_off_t; -#else -#error "Large file support, but neither off_t nor fpos_t is large enough." -#endif - - -/* a portable fseek() function - return 0 on success, non-zero on failure (with errno set) */ -static int -_portable_fseek(FILE *fp, Py_off_t offset, int whence) -{ -#if !defined(HAVE_LARGEFILE_SUPPORT) - return fseek(fp, offset, whence); -#elif defined(HAVE_FSEEKO) && SIZEOF_OFF_T >= 8 - return fseeko(fp, offset, whence); -#elif defined(HAVE_FSEEK64) - return fseek64(fp, offset, whence); -#elif defined(__BEOS__) - return _fseek(fp, offset, whence); -#elif SIZEOF_FPOS_T >= 8 - /* lacking a 64-bit capable fseek(), use a 64-bit capable fsetpos() - and fgetpos() to implement fseek()*/ - fpos_t pos; - switch (whence) { - case SEEK_END: -#ifdef MS_WINDOWS - fflush(fp); - if (_lseeki64(fileno(fp), 0, 2) == -1) - return -1; -#else - if (fseek(fp, 0, SEEK_END) != 0) - return -1; -#endif - /* fall through */ - case SEEK_CUR: - if (fgetpos(fp, &pos) != 0) - return -1; - offset += pos; - break; - /* case SEEK_SET: break; */ - } - return fsetpos(fp, &offset); -#else -#error "Large file support, but no way to fseek." -#endif -} - - -/* a portable ftell() function - Return -1 on failure with errno set appropriately, current file - position on success */ -static Py_off_t -_portable_ftell(FILE* fp) -{ -#if !defined(HAVE_LARGEFILE_SUPPORT) - return ftell(fp); -#elif defined(HAVE_FTELLO) && SIZEOF_OFF_T >= 8 - return ftello(fp); -#elif defined(HAVE_FTELL64) - return ftell64(fp); -#elif SIZEOF_FPOS_T >= 8 - fpos_t pos; - if (fgetpos(fp, &pos) != 0) - return -1; - return pos; -#else -#error "Large file support, but no way to ftell." -#endif -} - - -static PyObject * -file_seek(PyFileObject *f, PyObject *args) -{ - int whence; - int ret; - Py_off_t offset; - PyObject *offobj, *off_index; - - if (f->f_fp == NULL) - return err_closed(); - drop_readahead(f); - whence = 0; - if (!PyArg_ParseTuple(args, "O|i:seek", &offobj, &whence)) + stream = PyObject_CallMethod(io, "open", "is", fileno(fp), mode); + Py_DECREF(io); + if (stream == NULL) return NULL; - off_index = PyNumber_Index(offobj); - if (!off_index) { - if (!PyFloat_Check(offobj)) - return NULL; - /* Deprecated in 2.6 */ + nameobj = PyUnicode_FromString(name); + if (nameobj == NULL) PyErr_Clear(); - if (PyErr_Warn(PyExc_DeprecationWarning, - "integer argument expected, got float")) - return NULL; - off_index = offobj; - Py_INCREF(offobj); - } -#if !defined(HAVE_LARGEFILE_SUPPORT) - offset = PyInt_AsLong(off_index); -#else - offset = PyLong_Check(off_index) ? - PyLong_AsLongLong(off_index) : PyInt_AsLong(off_index); -#endif - Py_DECREF(off_index); - if (PyErr_Occurred()) - return NULL; - - Py_BEGIN_ALLOW_THREADS - errno = 0; - ret = _portable_fseek(f->f_fp, offset, whence); - Py_END_ALLOW_THREADS - - if (ret != 0) { - PyErr_SetFromErrno(PyExc_IOError); - clearerr(f->f_fp); - return NULL; - } - f->f_skipnextlf = 0; - Py_INCREF(Py_None); - return Py_None; -} - - -#ifdef HAVE_FTRUNCATE -static PyObject * -file_truncate(PyFileObject *f, PyObject *args) -{ - Py_off_t newsize; - PyObject *newsizeobj = NULL; - Py_off_t initialpos; - int ret; - - if (f->f_fp == NULL) - return err_closed(); - if (!PyArg_UnpackTuple(args, "truncate", 0, 1, &newsizeobj)) - return NULL; - - /* Get current file position. If the file happens to be open for - * update and the last operation was an input operation, C doesn't - * define what the later fflush() will do, but we promise truncate() - * won't change the current position (and fflush() *does* change it - * then at least on Windows). The easiest thing is to capture - * current pos now and seek back to it at the end. - */ - Py_BEGIN_ALLOW_THREADS - errno = 0; - initialpos = _portable_ftell(f->f_fp); - Py_END_ALLOW_THREADS - if (initialpos == -1) - goto onioerror; - - /* Set newsize to current postion if newsizeobj NULL, else to the - * specified value. - */ - if (newsizeobj != NULL) { -#if !defined(HAVE_LARGEFILE_SUPPORT) - newsize = PyInt_AsLong(newsizeobj); -#else - newsize = PyLong_Check(newsizeobj) ? - PyLong_AsLongLong(newsizeobj) : - PyInt_AsLong(newsizeobj); -#endif - if (PyErr_Occurred()) - return NULL; - } - else /* default to current position */ - newsize = initialpos; - - /* Flush the stream. We're mixing stream-level I/O with lower-level - * I/O, and a flush may be necessary to synch both platform views - * of the current file state. - */ - Py_BEGIN_ALLOW_THREADS - errno = 0; - ret = fflush(f->f_fp); - Py_END_ALLOW_THREADS - if (ret != 0) - goto onioerror; - -#ifdef MS_WINDOWS - /* MS _chsize doesn't work if newsize doesn't fit in 32 bits, - so don't even try using it. */ - { - HANDLE hFile; - - /* Have to move current pos to desired endpoint on Windows. */ - Py_BEGIN_ALLOW_THREADS - errno = 0; - ret = _portable_fseek(f->f_fp, newsize, SEEK_SET) != 0; - Py_END_ALLOW_THREADS - if (ret) - goto onioerror; - - /* Truncate. Note that this may grow the file! */ - Py_BEGIN_ALLOW_THREADS - errno = 0; - hFile = (HANDLE)_get_osfhandle(fileno(f->f_fp)); - ret = hFile == (HANDLE)-1; - if (ret == 0) { - ret = SetEndOfFile(hFile) == 0; - if (ret) - errno = EACCES; - } - Py_END_ALLOW_THREADS - if (ret) - goto onioerror; - } -#else - Py_BEGIN_ALLOW_THREADS - errno = 0; - ret = ftruncate(fileno(f->f_fp), newsize); - Py_END_ALLOW_THREADS - if (ret != 0) - goto onioerror; -#endif /* !MS_WINDOWS */ - - /* Restore original file position. */ - Py_BEGIN_ALLOW_THREADS - errno = 0; - ret = _portable_fseek(f->f_fp, initialpos, SEEK_SET) != 0; - Py_END_ALLOW_THREADS - if (ret) - goto onioerror; - - Py_INCREF(Py_None); - return Py_None; - -onioerror: - PyErr_SetFromErrno(PyExc_IOError); - clearerr(f->f_fp); - return NULL; -} -#endif /* HAVE_FTRUNCATE */ - -static PyObject * -file_tell(PyFileObject *f) -{ - Py_off_t pos; - - if (f->f_fp == NULL) - return err_closed(); - Py_BEGIN_ALLOW_THREADS - errno = 0; - pos = _portable_ftell(f->f_fp); - Py_END_ALLOW_THREADS - if (pos == -1) { - PyErr_SetFromErrno(PyExc_IOError); - clearerr(f->f_fp); - return NULL; - } - if (f->f_skipnextlf) { - int c; - c = GETC(f->f_fp); - if (c == '\n') { - pos++; - f->f_skipnextlf = 0; - } else if (c != EOF) ungetc(c, f->f_fp); - } -#if !defined(HAVE_LARGEFILE_SUPPORT) - return PyInt_FromLong(pos); -#else - return PyLong_FromLongLong(pos); -#endif -} - -static PyObject * -file_fileno(PyFileObject *f) -{ - if (f->f_fp == NULL) - return err_closed(); - return PyInt_FromLong((long) fileno(f->f_fp)); -} - -static PyObject * -file_flush(PyFileObject *f) -{ - int res; - - if (f->f_fp == NULL) - return err_closed(); - Py_BEGIN_ALLOW_THREADS - errno = 0; - res = fflush(f->f_fp); - Py_END_ALLOW_THREADS - if (res != 0) { - PyErr_SetFromErrno(PyExc_IOError); - clearerr(f->f_fp); - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -file_isatty(PyFileObject *f) -{ - long res; - if (f->f_fp == NULL) - return err_closed(); - Py_BEGIN_ALLOW_THREADS - res = isatty((int)fileno(f->f_fp)); - Py_END_ALLOW_THREADS - return PyBool_FromLong(res); -} - - -#if BUFSIZ < 8192 -#define SMALLCHUNK 8192 -#else -#define SMALLCHUNK BUFSIZ -#endif - -#if SIZEOF_INT < 4 -#define BIGCHUNK (512 * 32) -#else -#define BIGCHUNK (512 * 1024) -#endif - -static size_t -new_buffersize(PyFileObject *f, size_t currentsize) -{ -#ifdef HAVE_FSTAT - off_t pos, end; - struct stat st; - if (fstat(fileno(f->f_fp), &st) == 0) { - end = st.st_size; - /* The following is not a bug: we really need to call lseek() - *and* ftell(). The reason is that some stdio libraries - mistakenly flush their buffer when ftell() is called and - the lseek() call it makes fails, thereby throwing away - data that cannot be recovered in any way. To avoid this, - we first test lseek(), and only call ftell() if lseek() - works. We can't use the lseek() value either, because we - need to take the amount of buffered data into account. - (Yet another reason why stdio stinks. :-) */ - pos = lseek(fileno(f->f_fp), 0L, SEEK_CUR); - if (pos >= 0) { - pos = ftell(f->f_fp); - } - if (pos < 0) - clearerr(f->f_fp); - if (end > pos && pos >= 0) - return currentsize + end - pos + 1; - /* Add 1 so if the file were to grow we'd notice. */ - } -#endif - if (currentsize > SMALLCHUNK) { - /* Keep doubling until we reach BIGCHUNK; - then keep adding BIGCHUNK. */ - if (currentsize <= BIGCHUNK) - return currentsize + currentsize; - else - return currentsize + BIGCHUNK; - } - return currentsize + SMALLCHUNK; -} - -#if defined(EWOULDBLOCK) && defined(EAGAIN) && EWOULDBLOCK != EAGAIN -#define BLOCKED_ERRNO(x) ((x) == EWOULDBLOCK || (x) == EAGAIN) -#else -#ifdef EWOULDBLOCK -#define BLOCKED_ERRNO(x) ((x) == EWOULDBLOCK) -#else -#ifdef EAGAIN -#define BLOCKED_ERRNO(x) ((x) == EAGAIN) -#else -#define BLOCKED_ERRNO(x) 0 -#endif -#endif -#endif - -static PyObject * -file_read(PyFileObject *f, PyObject *args) -{ - long bytesrequested = -1; - size_t bytesread, buffersize, chunksize; - PyObject *v; - - if (f->f_fp == NULL) - return err_closed(); - /* refuse to mix with f.next() */ - if (f->f_buf != NULL && - (f->f_bufend - f->f_bufptr) > 0 && - f->f_buf[0] != '\0') - return err_iterbuffered(); - if (!PyArg_ParseTuple(args, "|l:read", &bytesrequested)) - return NULL; - if (bytesrequested < 0) - buffersize = new_buffersize(f, (size_t)0); - else - buffersize = bytesrequested; - if (buffersize > PY_SSIZE_T_MAX) { - PyErr_SetString(PyExc_OverflowError, - "requested number of bytes is more than a Python string can hold"); - return NULL; - } - v = PyString_FromStringAndSize((char *)NULL, buffersize); - if (v == NULL) - return NULL; - bytesread = 0; - for (;;) { - Py_BEGIN_ALLOW_THREADS - errno = 0; - chunksize = Py_UniversalNewlineFread(BUF(v) + bytesread, - buffersize - bytesread, f->f_fp, (PyObject *)f); - Py_END_ALLOW_THREADS - if (chunksize == 0) { - if (!ferror(f->f_fp)) - break; - clearerr(f->f_fp); - /* When in non-blocking mode, data shouldn't - * be discarded if a blocking signal was - * received. That will also happen if - * chunksize != 0, but bytesread < buffersize. */ - if (bytesread > 0 && BLOCKED_ERRNO(errno)) - break; - PyErr_SetFromErrno(PyExc_IOError); - Py_DECREF(v); - return NULL; - } - bytesread += chunksize; - if (bytesread < buffersize) { - clearerr(f->f_fp); - break; - } - if (bytesrequested < 0) { - buffersize = new_buffersize(f, buffersize); - if (_PyString_Resize(&v, buffersize) < 0) - return NULL; - } else { - /* Got what was requested. */ - break; - } - } - if (bytesread != buffersize) - _PyString_Resize(&v, bytesread); - return v; -} - -static PyObject * -file_readinto(PyFileObject *f, PyObject *args) -{ - char *ptr; - Py_ssize_t ntodo; - Py_ssize_t ndone, nnow; - - if (f->f_fp == NULL) - return err_closed(); - if (!f->f_binary) { - PyErr_SetString(PyExc_TypeError, - "readinto() requires binary mode"); - return NULL; - } - /* refuse to mix with f.next() */ - if (f->f_buf != NULL && - (f->f_bufend - f->f_bufptr) > 0 && - f->f_buf[0] != '\0') - return err_iterbuffered(); - if (!PyArg_ParseTuple(args, "w#", &ptr, &ntodo)) - return NULL; - ndone = 0; - while (ntodo > 0) { - Py_BEGIN_ALLOW_THREADS - errno = 0; - nnow = Py_UniversalNewlineFread(ptr+ndone, ntodo, f->f_fp, - (PyObject *)f); - Py_END_ALLOW_THREADS - if (nnow == 0) { - if (!ferror(f->f_fp)) - break; - PyErr_SetFromErrno(PyExc_IOError); - clearerr(f->f_fp); - return NULL; - } - ndone += nnow; - ntodo -= nnow; - } - return PyInt_FromSsize_t(ndone); -} - -/************************************************************************** -Routine to get next line using platform fgets(). - -Under MSVC 6: - -+ MS threadsafe getc is very slow (multiple layers of function calls before+ - after each character, to lock+unlock the stream). -+ The stream-locking functions are MS-internal -- can't access them from user - code. -+ There's nothing Tim could find in the MS C or platform SDK libraries that - can worm around this. -+ MS fgets locks/unlocks only once per line; it's the only hook we have. - -So we use fgets for speed(!), despite that it's painful. - -MS realloc is also slow. - -Reports from other platforms on this method vs getc_unlocked (which MS doesn't -have): - Linux a wash - Solaris a wash - Tru64 Unix getline_via_fgets significantly faster - -CAUTION: The C std isn't clear about this: in those cases where fgets -writes something into the buffer, can it write into any position beyond the -required trailing null byte? MSVC 6 fgets does not, and no platform is (yet) -known on which it does; and it would be a strange way to code fgets. Still, -getline_via_fgets may not work correctly if it does. The std test -test_bufio.py should fail if platform fgets() routinely writes beyond the -trailing null byte. #define DONT_USE_FGETS_IN_GETLINE to disable this code. -**************************************************************************/ - -/* Use this routine if told to, or by default on non-get_unlocked() - * platforms unless told not to. Yikes! Let's spell that out: - * On a platform with getc_unlocked(): - * By default, use getc_unlocked(). - * If you want to use fgets() instead, #define USE_FGETS_IN_GETLINE. - * On a platform without getc_unlocked(): - * By default, use fgets(). - * If you don't want to use fgets(), #define DONT_USE_FGETS_IN_GETLINE. - */ -#if !defined(USE_FGETS_IN_GETLINE) && !defined(HAVE_GETC_UNLOCKED) -#define USE_FGETS_IN_GETLINE -#endif - -#if defined(DONT_USE_FGETS_IN_GETLINE) && defined(USE_FGETS_IN_GETLINE) -#undef USE_FGETS_IN_GETLINE -#endif - -#ifdef USE_FGETS_IN_GETLINE -static PyObject* -getline_via_fgets(FILE *fp) -{ -/* INITBUFSIZE is the maximum line length that lets us get away with the fast - * no-realloc, one-fgets()-call path. Boosting it isn't free, because we have - * to fill this much of the buffer with a known value in order to figure out - * how much of the buffer fgets() overwrites. So if INITBUFSIZE is larger - * than "most" lines, we waste time filling unused buffer slots. 100 is - * surely adequate for most peoples' email archives, chewing over source code, - * etc -- "regular old text files". - * MAXBUFSIZE is the maximum line length that lets us get away with the less - * fast (but still zippy) no-realloc, two-fgets()-call path. See above for - * cautions about boosting that. 300 was chosen because the worst real-life - * text-crunching job reported on Python-Dev was a mail-log crawler where over - * half the lines were 254 chars. - */ -#define INITBUFSIZE 100 -#define MAXBUFSIZE 300 - char* p; /* temp */ - char buf[MAXBUFSIZE]; - PyObject* v; /* the string object result */ - char* pvfree; /* address of next free slot */ - char* pvend; /* address one beyond last free slot */ - size_t nfree; /* # of free buffer slots; pvend-pvfree */ - size_t total_v_size; /* total # of slots in buffer */ - size_t increment; /* amount to increment the buffer */ - size_t prev_v_size; - - /* Optimize for normal case: avoid _PyString_Resize if at all - * possible via first reading into stack buffer "buf". - */ - total_v_size = INITBUFSIZE; /* start small and pray */ - pvfree = buf; - for (;;) { - Py_BEGIN_ALLOW_THREADS - pvend = buf + total_v_size; - nfree = pvend - pvfree; - memset(pvfree, '\n', nfree); - assert(nfree < INT_MAX); /* Should be atmost MAXBUFSIZE */ - p = fgets(pvfree, (int)nfree, fp); - Py_END_ALLOW_THREADS - - if (p == NULL) { - clearerr(fp); - if (PyErr_CheckSignals()) - return NULL; - v = PyString_FromStringAndSize(buf, pvfree - buf); - return v; - } - /* fgets read *something* */ - p = memchr(pvfree, '\n', nfree); - if (p != NULL) { - /* Did the \n come from fgets or from us? - * Since fgets stops at the first \n, and then writes - * \0, if it's from fgets a \0 must be next. But if - * that's so, it could not have come from us, since - * the \n's we filled the buffer with have only more - * \n's to the right. - */ - if (p+1 < pvend && *(p+1) == '\0') { - /* It's from fgets: we win! In particular, - * we haven't done any mallocs yet, and can - * build the final result on the first try. - */ - ++p; /* include \n from fgets */ - } - else { - /* Must be from us: fgets didn't fill the - * buffer and didn't find a newline, so it - * must be the last and newline-free line of - * the file. - */ - assert(p > pvfree && *(p-1) == '\0'); - --p; /* don't include \0 from fgets */ - } - v = PyString_FromStringAndSize(buf, p - buf); - return v; - } - /* yuck: fgets overwrote all the newlines, i.e. the entire - * buffer. So this line isn't over yet, or maybe it is but - * we're exactly at EOF. If we haven't already, try using the - * rest of the stack buffer. - */ - assert(*(pvend-1) == '\0'); - if (pvfree == buf) { - pvfree = pvend - 1; /* overwrite trailing null */ - total_v_size = MAXBUFSIZE; - } - else - break; - } - - /* The stack buffer isn't big enough; malloc a string object and read - * into its buffer. - */ - total_v_size = MAXBUFSIZE << 1; - v = PyString_FromStringAndSize((char*)NULL, (int)total_v_size); - if (v == NULL) - return v; - /* copy over everything except the last null byte */ - memcpy(BUF(v), buf, MAXBUFSIZE-1); - pvfree = BUF(v) + MAXBUFSIZE - 1; - - /* Keep reading stuff into v; if it ever ends successfully, break - * after setting p one beyond the end of the line. The code here is - * very much like the code above, except reads into v's buffer; see - * the code above for detailed comments about the logic. - */ - for (;;) { - Py_BEGIN_ALLOW_THREADS - pvend = BUF(v) + total_v_size; - nfree = pvend - pvfree; - memset(pvfree, '\n', nfree); - assert(nfree < INT_MAX); - p = fgets(pvfree, (int)nfree, fp); - Py_END_ALLOW_THREADS - - if (p == NULL) { - clearerr(fp); - if (PyErr_CheckSignals()) { - Py_DECREF(v); - return NULL; - } - p = pvfree; - break; - } - p = memchr(pvfree, '\n', nfree); - if (p != NULL) { - if (p+1 < pvend && *(p+1) == '\0') { - /* \n came from fgets */ - ++p; - break; - } - /* \n came from us; last line of file, no newline */ - assert(p > pvfree && *(p-1) == '\0'); - --p; - break; - } - /* expand buffer and try again */ - assert(*(pvend-1) == '\0'); - increment = total_v_size >> 2; /* mild exponential growth */ - prev_v_size = total_v_size; - total_v_size += increment; - /* check for overflow */ - if (total_v_size <= prev_v_size || - total_v_size > PY_SSIZE_T_MAX) { - PyErr_SetString(PyExc_OverflowError, - "line is longer than a Python string can hold"); - Py_DECREF(v); - return NULL; - } - if (_PyString_Resize(&v, (int)total_v_size) < 0) - return NULL; - /* overwrite the trailing null byte */ - pvfree = BUF(v) + (prev_v_size - 1); - } - if (BUF(v) + total_v_size != p) - _PyString_Resize(&v, p - BUF(v)); - return v; -#undef INITBUFSIZE -#undef MAXBUFSIZE -} -#endif /* ifdef USE_FGETS_IN_GETLINE */ - -/* Internal routine to get a line. - Size argument interpretation: - > 0: max length; - <= 0: read arbitrary line -*/ - -static PyObject * -get_line(PyFileObject *f, int n) -{ - FILE *fp = f->f_fp; - int c; - char *buf, *end; - size_t total_v_size; /* total # of slots in buffer */ - size_t used_v_size; /* # used slots in buffer */ - size_t increment; /* amount to increment the buffer */ - PyObject *v; - int newlinetypes = f->f_newlinetypes; - int skipnextlf = f->f_skipnextlf; - int univ_newline = f->f_univ_newline; - -#if defined(USE_FGETS_IN_GETLINE) - if (n <= 0 && !univ_newline ) - return getline_via_fgets(fp); -#endif - total_v_size = n > 0 ? n : 100; - v = PyString_FromStringAndSize((char *)NULL, total_v_size); - if (v == NULL) - return NULL; - buf = BUF(v); - end = buf + total_v_size; - - for (;;) { - Py_BEGIN_ALLOW_THREADS - FLOCKFILE(fp); - if (univ_newline) { - c = 'x'; /* Shut up gcc warning */ - while ( buf != end && (c = GETC(fp)) != EOF ) { - if (skipnextlf ) { - skipnextlf = 0; - if (c == '\n') { - /* Seeing a \n here with - * skipnextlf true means we - * saw a \r before. - */ - newlinetypes |= NEWLINE_CRLF; - c = GETC(fp); - if (c == EOF) break; - } else { - newlinetypes |= NEWLINE_CR; - } - } - if (c == '\r') { - skipnextlf = 1; - c = '\n'; - } else if ( c == '\n') - newlinetypes |= NEWLINE_LF; - *buf++ = c; - if (c == '\n') break; - } - if ( c == EOF && skipnextlf ) - newlinetypes |= NEWLINE_CR; - } else /* If not universal newlines use the normal loop */ - while ((c = GETC(fp)) != EOF && - (*buf++ = c) != '\n' && - buf != end) - ; - FUNLOCKFILE(fp); - Py_END_ALLOW_THREADS - f->f_newlinetypes = newlinetypes; - f->f_skipnextlf = skipnextlf; - if (c == '\n') - break; - if (c == EOF) { - if (ferror(fp)) { - PyErr_SetFromErrno(PyExc_IOError); - clearerr(fp); - Py_DECREF(v); - return NULL; - } - clearerr(fp); - if (PyErr_CheckSignals()) { - Py_DECREF(v); - return NULL; - } - break; - } - /* Must be because buf == end */ - if (n > 0) - break; - used_v_size = total_v_size; - increment = total_v_size >> 2; /* mild exponential growth */ - total_v_size += increment; - if (total_v_size > PY_SSIZE_T_MAX) { - PyErr_SetString(PyExc_OverflowError, - "line is longer than a Python string can hold"); - Py_DECREF(v); - return NULL; - } - if (_PyString_Resize(&v, total_v_size) < 0) - return NULL; - buf = BUF(v) + used_v_size; - end = BUF(v) + total_v_size; + else { + if (PyObject_SetAttrString(stream, "name", nameobj) < 0) + PyErr_Clear(); + Py_DECREF(nameobj); } - - used_v_size = buf - BUF(v); - if (used_v_size != total_v_size) - _PyString_Resize(&v, used_v_size); - return v; + return stream; } -/* External C interface */ - PyObject * PyFile_GetLine(PyObject *f, int n) { @@ -1268,18 +58,7 @@ return NULL; } - if (PyFile_Check(f)) { - PyFileObject *fo = (PyFileObject *)f; - if (fo->f_fp == NULL) - return err_closed(); - /* refuse to mix with f.next() */ - if (fo->f_buf != NULL && - (fo->f_bufend - fo->f_bufptr) > 0 && - fo->f_buf[0] != '\0') - return err_iterbuffered(); - result = get_line(fo, n); - } - else { + { PyObject *reader; PyObject *args; @@ -1349,759 +128,6 @@ return result; } -/* Python method */ - -static PyObject * -file_readline(PyFileObject *f, PyObject *args) -{ - int n = -1; - - if (f->f_fp == NULL) - return err_closed(); - /* refuse to mix with f.next() */ - if (f->f_buf != NULL && - (f->f_bufend - f->f_bufptr) > 0 && - f->f_buf[0] != '\0') - return err_iterbuffered(); - if (!PyArg_ParseTuple(args, "|i:readline", &n)) - return NULL; - if (n == 0) - return PyString_FromString(""); - if (n < 0) - n = 0; - return get_line(f, n); -} - -static PyObject * -file_readlines(PyFileObject *f, PyObject *args) -{ - long sizehint = 0; - PyObject *list; - PyObject *line; - char small_buffer[SMALLCHUNK]; - char *buffer = small_buffer; - size_t buffersize = SMALLCHUNK; - PyObject *big_buffer = NULL; - size_t nfilled = 0; - size_t nread; - size_t totalread = 0; - char *p, *q, *end; - int err; - int shortread = 0; - - if (f->f_fp == NULL) - return err_closed(); - /* refuse to mix with f.next() */ - if (f->f_buf != NULL && - (f->f_bufend - f->f_bufptr) > 0 && - f->f_buf[0] != '\0') - return err_iterbuffered(); - if (!PyArg_ParseTuple(args, "|l:readlines", &sizehint)) - return NULL; - if ((list = PyList_New(0)) == NULL) - return NULL; - for (;;) { - if (shortread) - nread = 0; - else { - Py_BEGIN_ALLOW_THREADS - errno = 0; - nread = Py_UniversalNewlineFread(buffer+nfilled, - buffersize-nfilled, f->f_fp, (PyObject *)f); - Py_END_ALLOW_THREADS - shortread = (nread < buffersize-nfilled); - } - if (nread == 0) { - sizehint = 0; - if (!ferror(f->f_fp)) - break; - PyErr_SetFromErrno(PyExc_IOError); - clearerr(f->f_fp); - error: - Py_DECREF(list); - list = NULL; - goto cleanup; - } - totalread += nread; - p = (char *)memchr(buffer+nfilled, '\n', nread); - if (p == NULL) { - /* Need a larger buffer to fit this line */ - nfilled += nread; - buffersize *= 2; - if (buffersize > PY_SSIZE_T_MAX) { - PyErr_SetString(PyExc_OverflowError, - "line is longer than a Python string can hold"); - goto error; - } - if (big_buffer == NULL) { - /* Create the big buffer */ - big_buffer = PyString_FromStringAndSize( - NULL, buffersize); - if (big_buffer == NULL) - goto error; - buffer = PyString_AS_STRING(big_buffer); - memcpy(buffer, small_buffer, nfilled); - } - else { - /* Grow the big buffer */ - if ( _PyString_Resize(&big_buffer, buffersize) < 0 ) - goto error; - buffer = PyString_AS_STRING(big_buffer); - } - continue; - } - end = buffer+nfilled+nread; - q = buffer; - do { - /* Process complete lines */ - p++; - line = PyString_FromStringAndSize(q, p-q); - if (line == NULL) - goto error; - err = PyList_Append(list, line); - Py_DECREF(line); - if (err != 0) - goto error; - q = p; - p = (char *)memchr(q, '\n', end-q); - } while (p != NULL); - /* Move the remaining incomplete line to the start */ - nfilled = end-q; - memmove(buffer, q, nfilled); - if (sizehint > 0) - if (totalread >= (size_t)sizehint) - break; - } - if (nfilled != 0) { - /* Partial last line */ - line = PyString_FromStringAndSize(buffer, nfilled); - if (line == NULL) - goto error; - if (sizehint > 0) { - /* Need to complete the last line */ - PyObject *rest = get_line(f, 0); - if (rest == NULL) { - Py_DECREF(line); - goto error; - } - PyString_Concat(&line, rest); - Py_DECREF(rest); - if (line == NULL) - goto error; - } - err = PyList_Append(list, line); - Py_DECREF(line); - if (err != 0) - goto error; - } - cleanup: - Py_XDECREF(big_buffer); - return list; -} - -static PyObject * -file_write(PyFileObject *f, PyObject *args) -{ - char *s; - Py_ssize_t n, n2; - if (f->f_fp == NULL) - return err_closed(); - if (!PyArg_ParseTuple(args, f->f_binary ? "s#" : "t#", &s, &n)) - return NULL; - Py_BEGIN_ALLOW_THREADS - errno = 0; - n2 = fwrite(s, 1, n, f->f_fp); - Py_END_ALLOW_THREADS - if (n2 != n) { - PyErr_SetFromErrno(PyExc_IOError); - clearerr(f->f_fp); - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -file_writelines(PyFileObject *f, PyObject *seq) -{ -#define CHUNKSIZE 1000 - PyObject *list, *line; - PyObject *it; /* iter(seq) */ - PyObject *result; - int index, islist; - Py_ssize_t i, j, nwritten, len; - - assert(seq != NULL); - if (f->f_fp == NULL) - return err_closed(); - - result = NULL; - list = NULL; - islist = PyList_Check(seq); - if (islist) - it = NULL; - else { - it = PyObject_GetIter(seq); - if (it == NULL) { - PyErr_SetString(PyExc_TypeError, - "writelines() requires an iterable argument"); - return NULL; - } - /* From here on, fail by going to error, to reclaim "it". */ - list = PyList_New(CHUNKSIZE); - if (list == NULL) - goto error; - } - - /* Strategy: slurp CHUNKSIZE lines into a private list, - checking that they are all strings, then write that list - without holding the interpreter lock, then come back for more. */ - for (index = 0; ; index += CHUNKSIZE) { - if (islist) { - Py_XDECREF(list); - list = PyList_GetSlice(seq, index, index+CHUNKSIZE); - if (list == NULL) - goto error; - j = PyList_GET_SIZE(list); - } - else { - for (j = 0; j < CHUNKSIZE; j++) { - line = PyIter_Next(it); - if (line == NULL) { - if (PyErr_Occurred()) - goto error; - break; - } - PyList_SetItem(list, j, line); - } - } - if (j == 0) - break; - - /* Check that all entries are indeed strings. If not, - apply the same rules as for file.write() and - convert the results to strings. This is slow, but - seems to be the only way since all conversion APIs - could potentially execute Python code. */ - for (i = 0; i < j; i++) { - PyObject *v = PyList_GET_ITEM(list, i); - if (!PyString_Check(v)) { - const char *buffer; - if (((f->f_binary && - PyObject_AsReadBuffer(v, - (const void**)&buffer, - &len)) || - PyObject_AsCharBuffer(v, - &buffer, - &len))) { - PyErr_SetString(PyExc_TypeError, - "writelines() argument must be a sequence of strings"); - goto error; - } - line = PyString_FromStringAndSize(buffer, - len); - if (line == NULL) - goto error; - Py_DECREF(v); - PyList_SET_ITEM(list, i, line); - } - } - - /* Since we are releasing the global lock, the - following code may *not* execute Python code. */ - Py_BEGIN_ALLOW_THREADS - errno = 0; - for (i = 0; i < j; i++) { - line = PyList_GET_ITEM(list, i); - len = PyString_GET_SIZE(line); - nwritten = fwrite(PyString_AS_STRING(line), - 1, len, f->f_fp); - if (nwritten != len) { - Py_BLOCK_THREADS - PyErr_SetFromErrno(PyExc_IOError); - clearerr(f->f_fp); - goto error; - } - } - Py_END_ALLOW_THREADS - - if (j < CHUNKSIZE) - break; - } - - Py_INCREF(Py_None); - result = Py_None; - error: - Py_XDECREF(list); - Py_XDECREF(it); - return result; -#undef CHUNKSIZE -} - -static PyObject * -file_self(PyFileObject *f) -{ - if (f->f_fp == NULL) - return err_closed(); - Py_INCREF(f); - return (PyObject *)f; -} - -static PyObject * -file_exit(PyFileObject *f, PyObject *args) -{ - PyObject *ret = file_close(f); - if (!ret) - /* If error occurred, pass through */ - return NULL; - Py_DECREF(ret); - /* We cannot return the result of close since a true - * value will be interpreted as "yes, swallow the - * exception if one was raised inside the with block". */ - Py_RETURN_NONE; -} - -PyDoc_STRVAR(readline_doc, -"readline([size]) -> next line from the file, as a string.\n" -"\n" -"Retain newline. A non-negative size argument limits the maximum\n" -"number of bytes to return (an incomplete line may be returned then).\n" -"Return an empty string at EOF."); - -PyDoc_STRVAR(read_doc, -"read([size]) -> read at most size bytes, returned as a string.\n" -"\n" -"If the size argument is negative or omitted, read until EOF is reached.\n" -"Notice that when in non-blocking mode, less data than what was requested\n" -"may be returned, even if no size parameter was given."); - -PyDoc_STRVAR(write_doc, -"write(str) -> None. Write string str to file.\n" -"\n" -"Note that due to buffering, flush() or close() may be needed before\n" -"the file on disk reflects the data written."); - -PyDoc_STRVAR(fileno_doc, -"fileno() -> integer \"file descriptor\".\n" -"\n" -"This is needed for lower-level file interfaces, such os.read()."); - -PyDoc_STRVAR(seek_doc, -"seek(offset[, whence]) -> None. Move to new file position.\n" -"\n" -"Argument offset is a byte count. Optional argument whence defaults to\n" -"0 (offset from start of file, offset should be >= 0); other values are 1\n" -"(move relative to current position, positive or negative), and 2 (move\n" -"relative to end of file, usually negative, although many platforms allow\n" -"seeking beyond the end of a file). If the file is opened in text mode,\n" -"only offsets returned by tell() are legal. Use of other offsets causes\n" -"undefined behavior." -"\n" -"Note that not all file objects are seekable."); - -#ifdef HAVE_FTRUNCATE -PyDoc_STRVAR(truncate_doc, -"truncate([size]) -> None. Truncate the file to at most size bytes.\n" -"\n" -"Size defaults to the current file position, as returned by tell()."); -#endif - -PyDoc_STRVAR(tell_doc, -"tell() -> current file position, an integer (may be a long integer)."); - -PyDoc_STRVAR(readinto_doc, -"readinto() -> Undocumented. Don't use this; it may go away."); - -PyDoc_STRVAR(readlines_doc, -"readlines([size]) -> list of strings, each a line from the file.\n" -"\n" -"Call readline() repeatedly and return a list of the lines so read.\n" -"The optional size argument, if given, is an approximate bound on the\n" -"total number of bytes in the lines returned."); - -PyDoc_STRVAR(writelines_doc, -"writelines(sequence_of_strings) -> None. Write the strings to the file.\n" -"\n" -"Note that newlines are not added. The sequence can be any iterable object\n" -"producing strings. This is equivalent to calling write() for each string."); - -PyDoc_STRVAR(flush_doc, -"flush() -> None. Flush the internal I/O buffer."); - -PyDoc_STRVAR(close_doc, -"close() -> None or (perhaps) an integer. Close the file.\n" -"\n" -"Sets data attribute .closed to True. A closed file cannot be used for\n" -"further I/O operations. close() may be called more than once without\n" -"error. Some kinds of file objects (for example, opened by popen())\n" -"may return an exit status upon closing."); - -PyDoc_STRVAR(isatty_doc, -"isatty() -> true or false. True if the file is connected to a tty device."); - -PyDoc_STRVAR(enter_doc, - "__enter__() -> self."); - -PyDoc_STRVAR(exit_doc, - "__exit__(*excinfo) -> None. Closes the file."); - -static PyMethodDef file_methods[] = { - {"readline", (PyCFunction)file_readline, METH_VARARGS, readline_doc}, - {"read", (PyCFunction)file_read, METH_VARARGS, read_doc}, - {"write", (PyCFunction)file_write, METH_VARARGS, write_doc}, - {"fileno", (PyCFunction)file_fileno, METH_NOARGS, fileno_doc}, - {"seek", (PyCFunction)file_seek, METH_VARARGS, seek_doc}, -#ifdef HAVE_FTRUNCATE - {"truncate", (PyCFunction)file_truncate, METH_VARARGS, truncate_doc}, -#endif - {"tell", (PyCFunction)file_tell, METH_NOARGS, tell_doc}, - {"readinto", (PyCFunction)file_readinto, METH_VARARGS, readinto_doc}, - {"readlines", (PyCFunction)file_readlines,METH_VARARGS, readlines_doc}, - {"writelines",(PyCFunction)file_writelines, METH_O, writelines_doc}, - {"flush", (PyCFunction)file_flush, METH_NOARGS, flush_doc}, - {"close", (PyCFunction)file_close, METH_NOARGS, close_doc}, - {"isatty", (PyCFunction)file_isatty, METH_NOARGS, isatty_doc}, - {"__enter__", (PyCFunction)file_self, METH_NOARGS, enter_doc}, - {"__exit__", (PyCFunction)file_exit, METH_VARARGS, exit_doc}, - {NULL, NULL} /* sentinel */ -}; - -#define OFF(x) offsetof(PyFileObject, x) - -static PyMemberDef file_memberlist[] = { - {"mode", T_OBJECT, OFF(f_mode), RO, - "file mode ('r', 'U', 'w', 'a', possibly with 'b' or '+' added)"}, - {"name", T_OBJECT, OFF(f_name), RO, - "file name"}, - {"encoding", T_OBJECT, OFF(f_encoding), RO, - "file encoding"}, - /* getattr(f, "closed") is implemented without this table */ - {NULL} /* Sentinel */ -}; - -static PyObject * -get_closed(PyFileObject *f, void *closure) -{ - return PyBool_FromLong((long)(f->f_fp == 0)); -} -static PyObject * -get_newlines(PyFileObject *f, void *closure) -{ - switch (f->f_newlinetypes) { - case NEWLINE_UNKNOWN: - Py_INCREF(Py_None); - return Py_None; - case NEWLINE_CR: - return PyString_FromString("\r"); - case NEWLINE_LF: - return PyString_FromString("\n"); - case NEWLINE_CR|NEWLINE_LF: - return Py_BuildValue("(ss)", "\r", "\n"); - case NEWLINE_CRLF: - return PyString_FromString("\r\n"); - case NEWLINE_CR|NEWLINE_CRLF: - return Py_BuildValue("(ss)", "\r", "\r\n"); - case NEWLINE_LF|NEWLINE_CRLF: - return Py_BuildValue("(ss)", "\n", "\r\n"); - case NEWLINE_CR|NEWLINE_LF|NEWLINE_CRLF: - return Py_BuildValue("(sss)", "\r", "\n", "\r\n"); - default: - PyErr_Format(PyExc_SystemError, - "Unknown newlines value 0x%x\n", - f->f_newlinetypes); - return NULL; - } -} - -static PyGetSetDef file_getsetlist[] = { - {"closed", (getter)get_closed, NULL, "True if the file is closed"}, - {"newlines", (getter)get_newlines, NULL, - "end-of-line convention used in this file"}, - {0}, -}; - -static void -drop_readahead(PyFileObject *f) -{ - if (f->f_buf != NULL) { - PyMem_Free(f->f_buf); - f->f_buf = NULL; - } -} - -/* Make sure that file has a readahead buffer with at least one byte - (unless at EOF) and no more than bufsize. Returns negative value on - error, will set MemoryError if bufsize bytes cannot be allocated. */ -static int -readahead(PyFileObject *f, int bufsize) -{ - Py_ssize_t chunksize; - - if (f->f_buf != NULL) { - if( (f->f_bufend - f->f_bufptr) >= 1) - return 0; - else - drop_readahead(f); - } - if ((f->f_buf = (char *)PyMem_Malloc(bufsize)) == NULL) { - PyErr_NoMemory(); - return -1; - } - Py_BEGIN_ALLOW_THREADS - errno = 0; - chunksize = Py_UniversalNewlineFread( - f->f_buf, bufsize, f->f_fp, (PyObject *)f); - Py_END_ALLOW_THREADS - if (chunksize == 0) { - if (ferror(f->f_fp)) { - PyErr_SetFromErrno(PyExc_IOError); - clearerr(f->f_fp); - drop_readahead(f); - return -1; - } - } - f->f_bufptr = f->f_buf; - f->f_bufend = f->f_buf + chunksize; - return 0; -} - -/* Used by file_iternext. The returned string will start with 'skip' - uninitialized bytes followed by the remainder of the line. Don't be - horrified by the recursive call: maximum recursion depth is limited by - logarithmic buffer growth to about 50 even when reading a 1gb line. */ - -static PyStringObject * -readahead_get_line_skip(PyFileObject *f, int skip, int bufsize) -{ - PyStringObject* s; - char *bufptr; - char *buf; - Py_ssize_t len; - - if (f->f_buf == NULL) - if (readahead(f, bufsize) < 0) - return NULL; - - len = f->f_bufend - f->f_bufptr; - if (len == 0) - return (PyStringObject *) - PyString_FromStringAndSize(NULL, skip); - bufptr = (char *)memchr(f->f_bufptr, '\n', len); - if (bufptr != NULL) { - bufptr++; /* Count the '\n' */ - len = bufptr - f->f_bufptr; - s = (PyStringObject *) - PyString_FromStringAndSize(NULL, skip+len); - if (s == NULL) - return NULL; - memcpy(PyString_AS_STRING(s)+skip, f->f_bufptr, len); - f->f_bufptr = bufptr; - if (bufptr == f->f_bufend) - drop_readahead(f); - } else { - bufptr = f->f_bufptr; - buf = f->f_buf; - f->f_buf = NULL; /* Force new readahead buffer */ - assert(skip+len < INT_MAX); - s = readahead_get_line_skip( - f, (int)(skip+len), bufsize + (bufsize>>2) ); - if (s == NULL) { - PyMem_Free(buf); - return NULL; - } - memcpy(PyString_AS_STRING(s)+skip, bufptr, len); - PyMem_Free(buf); - } - return s; -} - -/* A larger buffer size may actually decrease performance. */ -#define READAHEAD_BUFSIZE 8192 - -static PyObject * -file_iternext(PyFileObject *f) -{ - PyStringObject* l; - - if (f->f_fp == NULL) - return err_closed(); - - l = readahead_get_line_skip(f, 0, READAHEAD_BUFSIZE); - if (l == NULL || PyString_GET_SIZE(l) == 0) { - Py_XDECREF(l); - return NULL; - } - return (PyObject *)l; -} - - -static PyObject * -file_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *self; - static PyObject *not_yet_string; - - PyErr_SetString(PyExc_SystemError, "attempt to create old file"); - return NULL; - - assert(type != NULL && type->tp_alloc != NULL); - - if (not_yet_string == NULL) { - not_yet_string = PyString_FromString(""); - if (not_yet_string == NULL) - return NULL; - } - - self = type->tp_alloc(type, 0); - if (self != NULL) { - /* Always fill in the name and mode, so that nobody else - needs to special-case NULLs there. */ - Py_INCREF(not_yet_string); - ((PyFileObject *)self)->f_name = not_yet_string; - Py_INCREF(not_yet_string); - ((PyFileObject *)self)->f_mode = not_yet_string; - Py_INCREF(Py_None); - ((PyFileObject *)self)->f_encoding = Py_None; - ((PyFileObject *)self)->weakreflist = NULL; - } - return self; -} - -static int -file_init(PyObject *self, PyObject *args, PyObject *kwds) -{ - PyFileObject *foself = (PyFileObject *)self; - int ret = 0; - static char *kwlist[] = {"name", "mode", "buffering", 0}; - char *name = NULL; - char *mode = "r"; - int bufsize = -1; - int wideargument = 0; - - assert(PyFile_Check(self)); - if (foself->f_fp != NULL) { - /* Have to close the existing file first. */ - PyObject *closeresult = file_close(foself); - if (closeresult == NULL) - return -1; - Py_DECREF(closeresult); - } - -#ifdef Py_WIN_WIDE_FILENAMES - if (GetVersion() < 0x80000000) { /* On NT, so wide API available */ - PyObject *po; - if (PyArg_ParseTupleAndKeywords(args, kwds, "U|si:file", - kwlist, &po, &mode, &bufsize)) { - wideargument = 1; - if (fill_file_fields(foself, NULL, po, mode, - fclose) == NULL) - goto Error; - } else { - /* Drop the argument parsing error as narrow - strings are also valid. */ - PyErr_Clear(); - } - } -#endif - - if (!wideargument) { - PyObject *o_name; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "et|si:file", kwlist, - Py_FileSystemDefaultEncoding, - &name, - &mode, &bufsize)) - return -1; - - /* We parse again to get the name as a PyObject */ - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|si:file", - kwlist, &o_name, &mode, - &bufsize)) - goto Error; - - if (fill_file_fields(foself, NULL, o_name, mode, - fclose) == NULL) - goto Error; - } - if (open_the_file(foself, name, mode) == NULL) - goto Error; - foself->f_setbuf = NULL; - PyFile_SetBufSize(self, bufsize); - goto Done; - -Error: - ret = -1; - /* fall through */ -Done: - PyMem_Free(name); /* free the encoded string */ - return ret; -} - -PyDoc_VAR(file_doc) = -PyDoc_STR( -"file(name[, mode[, buffering]]) -> file object\n" -"\n" -"Open a file. The mode can be 'r', 'w' or 'a' for reading (default),\n" -"writing or appending. The file will be created if it doesn't exist\n" -"when opened for writing or appending; it will be truncated when\n" -"opened for writing. Add a 'b' to the mode for binary files.\n" -"Add a '+' to the mode to allow simultaneous reading and writing.\n" -"If the buffering argument is given, 0 means unbuffered, 1 means line\n" -"buffered, and larger numbers specify the buffer size.\n" -) -PyDoc_STR( -"Add a 'U' to mode to open the file for input with universal newline\n" -"support. Any line ending in the input file will be seen as a '\\n'\n" -"in Python. Also, a file so opened gains the attribute 'newlines';\n" -"the value for this attribute is one of None (no newline read yet),\n" -"'\\r', '\\n', '\\r\\n' or a tuple containing all the newline types seen.\n" -"\n" -"'U' cannot be combined with 'w' or '+' mode.\n" -); - -PyTypeObject PyFile_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "file", - sizeof(PyFileObject), - 0, - (destructor)file_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)file_repr, /* tp_repr */ - 0, /* tp_as_number */ - 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_BASETYPE, /* tp_flags */ - file_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - offsetof(PyFileObject, weakreflist), /* tp_weaklistoffset */ - (getiterfunc)file_self, /* tp_iter */ - (iternextfunc)file_iternext, /* tp_iternext */ - file_methods, /* tp_methods */ - file_memberlist, /* tp_members */ - file_getsetlist, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - file_init, /* tp_init */ - PyType_GenericAlloc, /* tp_alloc */ - file_new, /* tp_new */ - PyObject_Del, /* tp_free */ -}; - /* Interfaces to write objects/strings to file-like objects */ int @@ -2112,28 +138,6 @@ PyErr_SetString(PyExc_TypeError, "writeobject with NULL file"); return -1; } - else if (PyFile_Check(f)) { - FILE *fp = PyFile_AsFile(f); - PyObject *enc = ((PyFileObject*)f)->f_encoding; - int result; - if (fp == NULL) { - err_closed(); - return -1; - } - if ((flags & Py_PRINT_RAW) && - PyUnicode_Check(v) && enc != Py_None) { - char *cenc = PyString_AS_STRING(enc); - value = PyUnicode_AsEncodedString(v, cenc, "strict"); - if (value == NULL) - return -1; - } else { - value = v; - Py_INCREF(value); - } - result = PyObject_Print(value, fp, flags); - Py_DECREF(value); - return result; - } writer = PyObject_GetAttrString(f, "write"); if (writer == NULL) return -1; @@ -2176,15 +180,6 @@ "null file for PyFile_WriteString"); return -1; } - else if (PyFile_Check(f)) { - FILE *fp = PyFile_AsFile(f); - if (fp == NULL) { - err_closed(); - return -1; - } - fputs(s, fp); - return 0; - } else if (!PyErr_Occurred()) { PyObject *v = PyString_FromString(s); int err; @@ -2205,7 +200,8 @@ -1 is returned on failure. */ -int PyObject_AsFileDescriptor(PyObject *o) +int +PyObject_AsFileDescriptor(PyObject *o) { int fd; PyObject *meth; @@ -2255,10 +251,6 @@ return fd; } -/* From here on we need access to the real fgets and fread */ -#undef fgets -#undef fread - /* ** Py_UniversalNewlineFgets is an fgets variation that understands ** all of \r, \n and \r\n conventions. @@ -2280,18 +272,10 @@ int c; int newlinetypes = 0; int skipnextlf = 0; - int univ_newline = 1; if (fobj) { - if (!PyFile_Check(fobj)) { - errno = ENXIO; /* What can you do... */ - return NULL; - } - univ_newline = ((PyFileObject *)fobj)->f_univ_newline; - if ( !univ_newline ) - return fgets(buf, n, stream); - newlinetypes = ((PyFileObject *)fobj)->f_newlinetypes; - skipnextlf = ((PyFileObject *)fobj)->f_skipnextlf; + errno = ENXIO; /* What can you do... */ + return NULL; } FLOCKFILE(stream); c = 'x'; /* Shut up gcc warning */ @@ -2331,10 +315,7 @@ newlinetypes |= NEWLINE_CR; FUNLOCKFILE(stream); *p = '\0'; - if (fobj) { - ((PyFileObject *)fobj)->f_newlinetypes = newlinetypes; - ((PyFileObject *)fobj)->f_skipnextlf = skipnextlf; - } else if ( skipnextlf ) { + if ( skipnextlf ) { /* If we have no file object we cannot save the ** skipnextlf flag. We have to readahead, which ** will cause a pause if we're reading from an @@ -2351,88 +332,6 @@ return buf; } -/* -** Py_UniversalNewlineFread is an fread variation that understands -** all of \r, \n and \r\n conventions. -** The stream should be opened in binary mode. -** fobj must be a PyFileObject. In this case there -** is no readahead but in stead a flag is used to skip a following -** \n on the next read. Also, if the file is open in binary mode -** the whole conversion is skipped. Finally, the routine keeps track of -** the different types of newlines seen. -*/ -size_t -Py_UniversalNewlineFread(char *buf, size_t n, - FILE *stream, PyObject *fobj) -{ - char *dst = buf; - PyFileObject *f = (PyFileObject *)fobj; - int newlinetypes, skipnextlf; - - assert(buf != NULL); - assert(stream != NULL); - - if (!fobj || !PyFile_Check(fobj)) { - errno = ENXIO; /* What can you do... */ - return 0; - } - if (!f->f_univ_newline) - return fread(buf, 1, n, stream); - newlinetypes = f->f_newlinetypes; - skipnextlf = f->f_skipnextlf; - /* Invariant: n is the number of bytes remaining to be filled - * in the buffer. - */ - while (n) { - size_t nread; - int shortread; - char *src = dst; - - nread = fread(dst, 1, n, stream); - assert(nread <= n); - if (nread == 0) - break; - - n -= nread; /* assuming 1 byte out for each in; will adjust */ - shortread = n != 0; /* true iff EOF or error */ - while (nread--) { - char c = *src++; - if (c == '\r') { - /* Save as LF and set flag to skip next LF. */ - *dst++ = '\n'; - skipnextlf = 1; - } - else if (skipnextlf && c == '\n') { - /* Skip LF, and remember we saw CR LF. */ - skipnextlf = 0; - newlinetypes |= NEWLINE_CRLF; - ++n; - } - else { - /* Normal char to be stored in buffer. Also - * update the newlinetypes flag if either this - * is an LF or the previous char was a CR. - */ - if (c == '\n') - newlinetypes |= NEWLINE_LF; - else if (skipnextlf) - newlinetypes |= NEWLINE_CR; - *dst++ = c; - skipnextlf = 0; - } - } - if (shortread) { - /* If this is EOF, update type flags. */ - if (skipnextlf && feof(stream)) - newlinetypes |= NEWLINE_CR; - break; - } - } - f->f_newlinetypes = newlinetypes; - f->f_skipnextlf = skipnextlf; - return dst - buf; -} - #ifdef __cplusplus } #endif Modified: python/branches/py3k-struni/Parser/tokenizer.c ============================================================================== --- python/branches/py3k-struni/Parser/tokenizer.c (original) +++ python/branches/py3k-struni/Parser/tokenizer.c Wed Jun 13 01:30:11 2007 @@ -669,66 +669,6 @@ PyMem_FREE(tok); } -#if !defined(PGEN) -static int -tok_stdin_decode(struct tok_state *tok, char **inp) -{ - PyObject *enc, *sysstdin, *decoded, *utf8; - const char *encoding; - char *converted; - - if (PySys_GetFile((char *)"stdin", NULL) != stdin) - return 0; - sysstdin = PySys_GetObject("stdin"); - if (sysstdin == NULL || !PyFile_Check(sysstdin)) - return 0; - - enc = ((PyFileObject *)sysstdin)->f_encoding; - if (enc == NULL || !PyString_Check(enc)) - return 0; - Py_INCREF(enc); - - encoding = PyString_AsString(enc); - decoded = PyUnicode_Decode(*inp, strlen(*inp), encoding, NULL); - if (decoded == NULL) - goto error_clear; - - utf8 = PyUnicode_AsEncodedString(decoded, "utf-8", NULL); - Py_DECREF(decoded); - if (utf8 == NULL) - goto error_clear; - - assert(PyBytes_Check(utf8)); - converted = new_string(PyBytes_AS_STRING(utf8), - PyBytes_GET_SIZE(utf8)); - Py_DECREF(utf8); - if (converted == NULL) - goto error_nomem; - - PyMem_FREE(*inp); - *inp = converted; - if (tok->encoding != NULL) - PyMem_FREE(tok->encoding); - tok->encoding = new_string(encoding, strlen(encoding)); - if (tok->encoding == NULL) - goto error_nomem; - - Py_DECREF(enc); - return 0; - -error_nomem: - Py_DECREF(enc); - tok->done = E_NOMEM; - return -1; - -error_clear: - /* Fallback to iso-8859-1: for backward compatibility */ - Py_DECREF(enc); - PyErr_Clear(); - return 0; -} -#endif - /* Get next char, updating state; error code goes into tok->done */ static int @@ -768,10 +708,6 @@ PyMem_FREE(newtok); tok->done = E_EOF; } -#if !defined(PGEN) - else if (tok_stdin_decode(tok, &newtok) != 0) - PyMem_FREE(newtok); -#endif else if (tok->start != NULL) { size_t start = tok->start - tok->buf; size_t oldlen = tok->cur - tok->buf; Modified: python/branches/py3k-struni/Python/bltinmodule.c ============================================================================== --- python/branches/py3k-struni/Python/bltinmodule.c (original) +++ python/branches/py3k-struni/Python/bltinmodule.c Wed Jun 13 01:30:11 2007 @@ -659,8 +659,7 @@ locals = globals; if (!PyString_Check(prog) && !PyUnicode_Check(prog) && - !PyCode_Check(prog) && - !PyFile_Check(prog)) { + !PyCode_Check(prog)) { PyErr_Format(PyExc_TypeError, "exec() arg 1 must be a string, file, or code " "object, not %.100s", prog->ob_type->tp_name); @@ -692,18 +691,6 @@ } v = PyEval_EvalCode((PyCodeObject *) prog, globals, locals); } - else if (PyFile_Check(prog)) { - FILE *fp = PyFile_AsFile(prog); - char *name = PyString_AsString(PyFile_Name(prog)); - PyCompilerFlags cf; - cf.cf_flags = 0; - if (PyEval_MergeCompilerFlags(&cf)) - v = PyRun_FileFlags(fp, name, Py_file_input, globals, - locals, &cf); - else - v = PyRun_File(fp, name, Py_file_input, globals, - locals); - } else { char *str = source_as_string(prog); PyCompilerFlags cf; Modified: python/branches/py3k-struni/Python/import.c ============================================================================== --- python/branches/py3k-struni/Python/import.c (original) +++ python/branches/py3k-struni/Python/import.c Wed Jun 13 01:30:11 2007 @@ -2764,19 +2764,21 @@ get_file(char *pathname, PyObject *fob, char *mode) { FILE *fp; + if (mode[0] == 'U') + mode = "r" PY_STDIOTEXTMODE; if (fob == NULL) { - if (mode[0] == 'U') - mode = "r" PY_STDIOTEXTMODE; fp = fopen(pathname, mode); - if (fp == NULL) - PyErr_SetFromErrno(PyExc_IOError); } else { - fp = PyFile_AsFile(fob); - if (fp == NULL) - PyErr_SetString(PyExc_ValueError, - "bad/closed file object"); + int fd = PyObject_AsFileDescriptor(fob); + if (fd == -1) + return NULL; + /* XXX This will leak a FILE struct. Fix this!!!! + (But it doesn't leak a file descrioptor!) */ + fp = fdopen(fd, mode); } + if (fp == NULL) + PyErr_SetFromErrno(PyExc_IOError); return fp; } @@ -2788,8 +2790,8 @@ PyObject *fob = NULL; PyObject *m; FILE *fp; - if (!PyArg_ParseTuple(args, "ss|O!:load_compiled", &name, &pathname, - &PyFile_Type, &fob)) + if (!PyArg_ParseTuple(args, "ss|O:load_compiled", + &name, &pathname, &fob)) return NULL; fp = get_file(pathname, fob, "rb"); if (fp == NULL) @@ -2810,8 +2812,8 @@ PyObject *fob = NULL; PyObject *m; FILE *fp = NULL; - if (!PyArg_ParseTuple(args, "ss|O!:load_dynamic", &name, &pathname, - &PyFile_Type, &fob)) + if (!PyArg_ParseTuple(args, "ss|O:load_dynamic", + &name, &pathname, &fob)) return NULL; if (fob) { fp = get_file(pathname, fob, "r"); @@ -2832,8 +2834,8 @@ PyObject *fob = NULL; PyObject *m; FILE *fp; - if (!PyArg_ParseTuple(args, "ss|O!:load_source", &name, &pathname, - &PyFile_Type, &fob)) + if (!PyArg_ParseTuple(args, "ss|O:load_source", + &name, &pathname, &fob)) return NULL; fp = get_file(pathname, fob, "r"); if (fp == NULL) @@ -2873,12 +2875,7 @@ if (fob == Py_None) fp = NULL; else { - if (!PyFile_Check(fob)) { - PyErr_SetString(PyExc_ValueError, - "load_module arg#2 should be a file or None"); - return NULL; - } - fp = get_file(pathname, fob, mode); + fp = get_file(NULL, fob, mode); if (fp == NULL) return NULL; } Modified: python/branches/py3k-struni/Python/marshal.c ============================================================================== --- python/branches/py3k-struni/Python/marshal.c (original) +++ python/branches/py3k-struni/Python/marshal.c Wed Jun 13 01:30:11 2007 @@ -1138,81 +1138,52 @@ static PyObject * marshal_dump(PyObject *self, PyObject *args) { - WFILE wf; + /* XXX Quick hack -- need to do this differently */ PyObject *x; PyObject *f; int version = Py_MARSHAL_VERSION; + PyObject *s; + PyObject *res; if (!PyArg_ParseTuple(args, "OO|i:dump", &x, &f, &version)) return NULL; - if (!PyFile_Check(f)) { - /* XXX Quick hack -- need to do this differently */ - PyObject *s = PyMarshal_WriteObjectToString(x, version); - PyObject *res = NULL; - if (s != NULL) { - res = PyObject_CallMethod(f, "write", "O", s); - Py_DECREF(s); - } - return res; - } - wf.fp = PyFile_AsFile(f); - wf.str = NULL; - wf.ptr = wf.end = NULL; - wf.error = 0; - wf.depth = 0; - wf.strings = (version > 0) ? PyDict_New() : 0; - wf.version = version; - w_object(x, &wf); - Py_XDECREF(wf.strings); - if (wf.error) { - PyErr_SetString(PyExc_ValueError, - (wf.error==1)?"unmarshallable object" - :"object too deeply nested to marshal"); + s = PyMarshal_WriteObjectToString(x, version); + if (s == NULL) return NULL; - } - Py_INCREF(Py_None); - return Py_None; + res = PyObject_CallMethod(f, "write", "O", s); + Py_DECREF(s); + return res; } static PyObject * marshal_load(PyObject *self, PyObject *f) { + /* XXX Quick hack -- need to do this differently */ + PyObject *data, *result; RFILE rf; - PyObject *result; - if (!PyFile_Check(f)) { - /* XXX Quick hack -- need to do this differently */ - PyObject *data, *result; - RFILE rf; - data = PyObject_CallMethod(f, "read", ""); - if (data == NULL) - return NULL; - rf.fp = NULL; - if (PyString_Check(data)) { - rf.ptr = PyString_AS_STRING(data); - rf.end = rf.ptr + PyString_GET_SIZE(data); - } - else if (PyBytes_Check(data)) { - rf.ptr = PyBytes_AS_STRING(data); - rf.end = rf.ptr + PyBytes_GET_SIZE(data); - } - else { - PyErr_Format(PyExc_TypeError, - "f.read() returned neither string " - "nor bytes but %.100s", - data->ob_type->tp_name); - Py_DECREF(data); - return NULL; - } - rf.strings = PyList_New(0); - result = read_object(&rf); - Py_DECREF(rf.strings); + data = PyObject_CallMethod(f, "read", ""); + if (data == NULL) + return NULL; + rf.fp = NULL; + if (PyString_Check(data)) { + rf.ptr = PyString_AS_STRING(data); + rf.end = rf.ptr + PyString_GET_SIZE(data); + } + else if (PyBytes_Check(data)) { + rf.ptr = PyBytes_AS_STRING(data); + rf.end = rf.ptr + PyBytes_GET_SIZE(data); + } + else { + PyErr_Format(PyExc_TypeError, + "f.read() returned neither string " + "nor bytes but %.100s", + data->ob_type->tp_name); Py_DECREF(data); - return result; + return NULL; } - rf.fp = PyFile_AsFile(f); rf.strings = PyList_New(0); - rf.depth = 0; result = read_object(&rf); Py_DECREF(rf.strings); + Py_DECREF(data); return result; } Modified: python/branches/py3k-struni/Python/pythonrun.c ============================================================================== --- python/branches/py3k-struni/Python/pythonrun.c (original) +++ python/branches/py3k-struni/Python/pythonrun.c Wed Jun 13 01:30:11 2007 @@ -155,7 +155,6 @@ #if defined(HAVE_LANGINFO_H) && defined(CODESET) char *codeset; char *saved_locale; - PyObject *sys_stream, *sys_isatty; #endif extern void _Py_ReadyTypes(void); @@ -273,39 +272,6 @@ free(saved_locale); if (codeset) { - sys_stream = PySys_GetObject("stdin"); - sys_isatty = PyObject_CallMethod(sys_stream, "isatty", ""); - if (!sys_isatty) - PyErr_Clear(); - if(sys_isatty && PyObject_IsTrue(sys_isatty) && - PyFile_Check(sys_stream)) { - if (!PyFile_SetEncoding(sys_stream, codeset)) - Py_FatalError("Cannot set codeset of stdin"); - } - Py_XDECREF(sys_isatty); - - sys_stream = PySys_GetObject("stdout"); - sys_isatty = PyObject_CallMethod(sys_stream, "isatty", ""); - if (!sys_isatty) - PyErr_Clear(); - if(sys_isatty && PyObject_IsTrue(sys_isatty) && - PyFile_Check(sys_stream)) { - if (!PyFile_SetEncoding(sys_stream, codeset)) - Py_FatalError("Cannot set codeset of stdout"); - } - Py_XDECREF(sys_isatty); - - sys_stream = PySys_GetObject("stderr"); - sys_isatty = PyObject_CallMethod(sys_stream, "isatty", ""); - if (!sys_isatty) - PyErr_Clear(); - if(sys_isatty && PyObject_IsTrue(sys_isatty) && - PyFile_Check(sys_stream)) { - if (!PyFile_SetEncoding(sys_stream, codeset)) - Py_FatalError("Cannot set codeset of stderr"); - } - Py_XDECREF(sys_isatty); - if (!Py_FileSystemDefaultEncoding) Py_FileSystemDefaultEncoding = codeset; else Modified: python/branches/py3k-struni/Python/sysmodule.c ============================================================================== --- python/branches/py3k-struni/Python/sysmodule.c (original) +++ python/branches/py3k-struni/Python/sysmodule.c Wed Jun 13 01:30:11 2007 @@ -55,18 +55,6 @@ return PyDict_GetItemString(sd, name); } -FILE * -PySys_GetFile(char *name, FILE *def) -{ - FILE *fp = NULL; - PyObject *v = PySys_GetObject(name); - if (v != NULL && PyFile_Check(v)) - fp = PyFile_AsFile(v); - if (fp == NULL) - fp = def; - return fp; -} - int PySys_SetObject(char *name, PyObject *v) { @@ -1353,25 +1341,21 @@ { PyObject *file; PyObject *error_type, *error_value, *error_traceback; + char buffer[1001]; + int written; PyErr_Fetch(&error_type, &error_value, &error_traceback); file = PySys_GetObject(name); - if (file == NULL || PyFile_AsFile(file) == fp) - vfprintf(fp, format, va); - else { - char buffer[1001]; - const int written = PyOS_vsnprintf(buffer, sizeof(buffer), - format, va); - if (PyFile_WriteString(buffer, file) != 0) { + written = PyOS_vsnprintf(buffer, sizeof(buffer), format, va); + if (PyFile_WriteString(buffer, file) != 0) { + PyErr_Clear(); + fputs(buffer, fp); + } + if (written < 0 || (size_t)written >= sizeof(buffer)) { + const char *truncated = "... truncated"; + if (PyFile_WriteString(truncated, file) != 0) { PyErr_Clear(); - fputs(buffer, fp); - } - if (written < 0 || (size_t)written >= sizeof(buffer)) { - const char *truncated = "... truncated"; - if (PyFile_WriteString(truncated, file) != 0) { - PyErr_Clear(); - fputs(truncated, fp); - } + fputs(truncated, fp); } } PyErr_Restore(error_type, error_value, error_traceback); Modified: python/branches/py3k-struni/runtests.sh ============================================================================== --- python/branches/py3k-struni/runtests.sh (original) +++ python/branches/py3k-struni/runtests.sh Wed Jun 13 01:30:11 2007 @@ -24,8 +24,8 @@ >BAD >SKIPPED -# The -uall flag (edit this file to change). -UALL="-uall" +# The -u flag (edit this file to change). +UFLAG="-unetwork" # Compute the list of tests to run. case $# in @@ -41,7 +41,7 @@ for T in $TESTS do echo -n $T - if $PYTHON Lib/test/regrtest.py $UALL $T >OUT/$T.out 2>&1 + if $PYTHON Lib/test/regrtest.py $UFLAG $T >OUT/$T.out 2>&1 then if grep -q "1 test skipped:" OUT/$T.out then @@ -55,6 +55,6 @@ echo " BAD" echo $T >>BAD echo "---------- Re-running test in verbose mode ----------" >>OUT/$T - $PYTHON Lib/test/regrtest.py -v $UALL $T >>OUT/$T.out 2>&1 + $PYTHON Lib/test/regrtest.py -v $UFLAG $T >>OUT/$T.out 2>&1 fi done From python-3000-checkins at python.org Wed Jun 13 02:03:12 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Wed, 13 Jun 2007 02:03:12 +0200 (CEST) Subject: [Python-3000-checkins] r55944 - python/branches/py3k-struni/Modules/bz2module.c Message-ID: <20070613000312.ED96F1E400D@bag.python.org> Author: guido.van.rossum Date: Wed Jun 13 02:03:05 2007 New Revision: 55944 Modified: python/branches/py3k-struni/Modules/bz2module.c Log: Checkpoint: half-fixed the bz2 module. 'U' is no longer supported. Modified: python/branches/py3k-struni/Modules/bz2module.c ============================================================================== --- python/branches/py3k-struni/Modules/bz2module.c (original) +++ python/branches/py3k-struni/Modules/bz2module.c Wed Jun 13 02:03:05 2007 @@ -96,16 +96,12 @@ typedef struct { PyObject_HEAD - PyObject *file; + FILE *rawfp; char* f_buf; /* Allocated readahead buffer */ char* f_bufend; /* Points after last occupied position */ char* f_bufptr; /* Current buffer position */ - int f_univ_newline; /* Handle any newline convention */ - int f_newlinetypes; /* Types of newlines seen */ - int f_skipnextlf; /* Skip next \n */ - BZFILE *fp; int mode; Py_off_t pos; @@ -233,9 +229,6 @@ size_t increment; /* amount to increment the buffer */ PyObject *v; int bzerror; - int newlinetypes = f->f_newlinetypes; - int skipnextlf = f->f_skipnextlf; - int univ_newline = f->f_univ_newline; total_v_size = n > 0 ? n : 100; v = PyBytes_FromStringAndSize((char *)NULL, total_v_size); @@ -247,47 +240,12 @@ for (;;) { Py_BEGIN_ALLOW_THREADS - if (univ_newline) { - while (1) { - BZ2_bzRead(&bzerror, f->fp, &c, 1); - f->pos++; - if (bzerror != BZ_OK || buf == end) - break; - if (skipnextlf) { - skipnextlf = 0; - if (c == '\n') { - /* Seeing a \n here with - * skipnextlf true means we - * saw a \r before. - */ - newlinetypes |= NEWLINE_CRLF; - BZ2_bzRead(&bzerror, f->fp, - &c, 1); - if (bzerror != BZ_OK) - break; - } else { - newlinetypes |= NEWLINE_CR; - } - } - if (c == '\r') { - skipnextlf = 1; - c = '\n'; - } else if ( c == '\n') - newlinetypes |= NEWLINE_LF; - *buf++ = c; - if (c == '\n') break; - } - if (bzerror == BZ_STREAM_END && skipnextlf) - newlinetypes |= NEWLINE_CR; - } else /* If not universal newlines use the normal loop */ - do { - BZ2_bzRead(&bzerror, f->fp, &c, 1); - f->pos++; - *buf++ = c; - } while (bzerror == BZ_OK && c != '\n' && buf != end); + do { + BZ2_bzRead(&bzerror, f->fp, &c, 1); + f->pos++; + *buf++ = c; + } while (bzerror == BZ_OK && c != '\n' && buf != end); Py_END_ALLOW_THREADS - f->f_newlinetypes = newlinetypes; - f->f_skipnextlf = skipnextlf; if (bzerror == BZ_STREAM_END) { f->size = f->pos; f->mode = MODE_READ_EOF; @@ -329,74 +287,6 @@ return v; } -/* This is a hacked version of Python's - * fileobject.c:Py_UniversalNewlineFread(). */ -size_t -Util_UnivNewlineRead(int *bzerror, BZFILE *stream, - char* buf, size_t n, BZ2FileObject *f) -{ - char *dst = buf; - int newlinetypes, skipnextlf; - - assert(buf != NULL); - assert(stream != NULL); - - if (!f->f_univ_newline) - return BZ2_bzRead(bzerror, stream, buf, n); - - newlinetypes = f->f_newlinetypes; - skipnextlf = f->f_skipnextlf; - - /* Invariant: n is the number of bytes remaining to be filled - * in the buffer. - */ - while (n) { - size_t nread; - int shortread; - char *src = dst; - - nread = BZ2_bzRead(bzerror, stream, dst, n); - assert(nread <= n); - n -= nread; /* assuming 1 byte out for each in; will adjust */ - shortread = n != 0; /* true iff EOF or error */ - while (nread--) { - char c = *src++; - if (c == '\r') { - /* Save as LF and set flag to skip next LF. */ - *dst++ = '\n'; - skipnextlf = 1; - } - else if (skipnextlf && c == '\n') { - /* Skip LF, and remember we saw CR LF. */ - skipnextlf = 0; - newlinetypes |= NEWLINE_CRLF; - ++n; - } - else { - /* Normal char to be stored in buffer. Also - * update the newlinetypes flag if either this - * is an LF or the previous char was a CR. - */ - if (c == '\n') - newlinetypes |= NEWLINE_LF; - else if (skipnextlf) - newlinetypes |= NEWLINE_CR; - *dst++ = c; - skipnextlf = 0; - } - } - if (shortread) { - /* If this is EOF, update type flags. */ - if (skipnextlf && *bzerror == BZ_STREAM_END) - newlinetypes |= NEWLINE_CR; - break; - } - } - f->f_newlinetypes = newlinetypes; - f->f_skipnextlf = skipnextlf; - return dst - buf; -} - /* This is a hacked version of Python's fileobject.c:drop_readahead(). */ static void Util_DropReadAhead(BZ2FileObject *f) @@ -429,8 +319,7 @@ return -1; } Py_BEGIN_ALLOW_THREADS - chunksize = Util_UnivNewlineRead(&bzerror, f->fp, f->f_buf, - bufsize, f); + chunksize = BZ2_bzRead(&bzerror, f->fp, f->f_buf, bufsize); Py_END_ALLOW_THREADS f->pos += chunksize; if (bzerror == BZ_STREAM_END) { @@ -548,10 +437,9 @@ for (;;) { Py_BEGIN_ALLOW_THREADS - chunksize = Util_UnivNewlineRead(&bzerror, self->fp, - BUF(ret)+bytesread, - buffersize-bytesread, - self); + chunksize = BZ2_bzRead(&bzerror, self->fp, + BUF(ret)+bytesread, + buffersize-bytesread); self->pos += chunksize; Py_END_ALLOW_THREADS bytesread += chunksize; @@ -685,9 +573,8 @@ for (;;) { Py_BEGIN_ALLOW_THREADS - nread = Util_UnivNewlineRead(&bzerror, self->fp, - buffer+nfilled, - buffersize-nfilled, self); + nread = BZ2_bzRead(&bzerror, self->fp, + buffer+nfilled, buffersize-nfilled); self->pos += nread; Py_END_ALLOW_THREADS if (bzerror == BZ_STREAM_END) { @@ -1043,10 +930,8 @@ assert(self->mode != MODE_READ_EOF); for (;;) { Py_BEGIN_ALLOW_THREADS - chunksize = Util_UnivNewlineRead( - &bzerror, self->fp, - buffer, buffersize, - self); + chunksize = BZ2_bzRead(&bzerror, self->fp, + buffer, buffersize); self->pos += chunksize; Py_END_ALLOW_THREADS @@ -1075,19 +960,14 @@ offset -= self->pos; } else { /* we cannot move back, so rewind the stream */ - FILE *fp = NULL; /* XXX temporary!!! */ BZ2_bzReadClose(&bzerror, self->fp); if (bzerror != BZ_OK) { Util_CatchBZ2Error(bzerror); goto cleanup; } - ret = PyObject_CallMethod(self->file, "seek", "(i)", 0); - if (!ret) - goto cleanup; - Py_DECREF(ret); - ret = NULL; + rewind(self->rawfp); self->pos = 0; - self->fp = BZ2_bzReadOpen(&bzerror, fp, + self->fp = BZ2_bzReadOpen(&bzerror, self->rawfp, 0, 0, NULL, 0); if (bzerror != BZ_OK) { Util_CatchBZ2Error(bzerror); @@ -1110,8 +990,7 @@ * condition above). buffersize is 8192. */ readsize = (size_t)(offset-bytesread); Py_BEGIN_ALLOW_THREADS - chunksize = Util_UnivNewlineRead(&bzerror, self->fp, - buffer, readsize, self); + chunksize = BZ2_bzRead(&bzerror, self->fp, buffer, readsize); self->pos += chunksize; Py_END_ALLOW_THREADS bytesread += chunksize; @@ -1177,6 +1056,10 @@ PyObject *ret = NULL; int bzerror = BZ_OK; + if (self->mode == MODE_CLOSED) { + Py_RETURN_NONE; + } + ACQUIRE_LOCK(self); switch (self->mode) { case MODE_READ: @@ -1189,11 +1072,14 @@ break; } self->mode = MODE_CLOSED; - ret = PyObject_CallMethod(self->file, "close", NULL); - if (bzerror != BZ_OK) { + fclose(self->rawfp); + self->rawfp = NULL; + if (bzerror == BZ_OK) { + Py_INCREF(Py_None); + ret = Py_None; + } + else { Util_CatchBZ2Error(bzerror); - Py_XDECREF(ret); - ret = NULL; } RELEASE_LOCK(self); @@ -1218,63 +1104,15 @@ /* ===================================================================== */ /* Getters and setters of BZ2File. */ -/* This is a hacked version of Python's fileobject.c:get_newlines(). */ -static PyObject * -BZ2File_get_newlines(BZ2FileObject *self, void *closure) -{ - switch (self->f_newlinetypes) { - case NEWLINE_UNKNOWN: - Py_INCREF(Py_None); - return Py_None; - case NEWLINE_CR: - return PyBytes_FromStringAndSize("\r", 1); - case NEWLINE_LF: - return PyBytes_FromStringAndSize("\n", 1); - case NEWLINE_CR|NEWLINE_LF: - return Py_BuildValue("(ss)", "\r", "\n"); - case NEWLINE_CRLF: - return PyBytes_FromStringAndSize("\r\n", 2); - case NEWLINE_CR|NEWLINE_CRLF: - return Py_BuildValue("(ss)", "\r", "\r\n"); - case NEWLINE_LF|NEWLINE_CRLF: - return Py_BuildValue("(ss)", "\n", "\r\n"); - case NEWLINE_CR|NEWLINE_LF|NEWLINE_CRLF: - return Py_BuildValue("(sss)", "\r", "\n", "\r\n"); - default: - PyErr_Format(PyExc_SystemError, - "Unknown newlines value 0x%x\n", - self->f_newlinetypes); - return NULL; - } -} - static PyObject * BZ2File_get_closed(BZ2FileObject *self, void *closure) { return PyInt_FromLong(self->mode == MODE_CLOSED); } -static PyObject * -BZ2File_get_mode(BZ2FileObject *self, void *closure) -{ - return PyObject_GetAttrString(self->file, "mode"); -} - -static PyObject * -BZ2File_get_name(BZ2FileObject *self, void *closure) -{ - return PyObject_GetAttrString(self->file, "name"); -} - static PyGetSetDef BZ2File_getset[] = { {"closed", (getter)BZ2File_get_closed, NULL, "True if the file is closed"}, - {"newlines", (getter)BZ2File_get_newlines, NULL, - "end-of-line convention used in this file"}, - {"mode", (getter)BZ2File_get_mode, NULL, - "file mode ('r', 'w', or 'U')"}, - {"name", (getter)BZ2File_get_name, NULL, - "file name"}, {NULL} /* Sentinel */ }; @@ -1286,9 +1124,8 @@ BZ2File_init(BZ2FileObject *self, PyObject *args, PyObject *kwargs) { static char *kwlist[] = {"filename", "mode", "buffering", - "compresslevel", 0}; - FILE *fp = NULL; /* XXX temporary!!! */ - PyObject *name; + "compresslevel", 0}; + char *name; char *mode = "r"; int buffering = -1; int compresslevel = 9; @@ -1297,7 +1134,7 @@ self->size = -1; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|sii:BZ2File", + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|sii:BZ2File", kwlist, &name, &mode, &buffering, &compresslevel)) return -1; @@ -1321,14 +1158,6 @@ case 'b': break; - case 'U': -#ifdef __VMS - self->f_univ_newline = 0; -#else - self->f_univ_newline = 1; -#endif - break; - default: error = 1; break; @@ -1349,10 +1178,12 @@ mode = (mode_char == 'r') ? "rb" : "wb"; - self->file = NULL; /* XXX io.open(name, mode, buffering); */ - PyErr_SetString(PyExc_RuntimeError, "can't open bz2 files yet"); - if (self->file == NULL) + self->rawfp = fopen(name, mode); + if (self->rawfp == NULL) { + PyErr_SetFromErrno(PyExc_IOError); return -1; + } + /* XXX Ignore buffering */ /* From now on, we have stuff to dealloc, so jump to error label * instead of returning */ @@ -1366,12 +1197,10 @@ #endif if (mode_char == 'r') - self->fp = BZ2_bzReadOpen(&bzerror, - fp, + self->fp = BZ2_bzReadOpen(&bzerror, self->rawfp, 0, 0, NULL, 0); else - self->fp = BZ2_bzWriteOpen(&bzerror, - fp, + self->fp = BZ2_bzWriteOpen(&bzerror, self->rawfp, compresslevel, 0, 0); if (bzerror != BZ_OK) { @@ -1384,7 +1213,8 @@ return 0; error: - Py_CLEAR(self->file); + fclose(self->rawfp); + self->rawfp = NULL; #ifdef WITH_THREAD if (self->lock) { PyThread_free_lock(self->lock); @@ -1413,7 +1243,8 @@ break; } Util_DropReadAhead(self); - Py_XDECREF(self->file); + if (self->rawfp != NULL) + fclose(self->rawfp); self->ob_type->tp_free((PyObject *)self); } From nnorwitz at gmail.com Wed Jun 13 02:47:36 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Tue, 12 Jun 2007 20:47:36 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures basics (1) Message-ID: <20070613004736.GA18401@python.psfb.org> test_grammar test_opcodes test_dict test_builtin test_exceptions test test_exceptions failed -- Traceback (most recent call last): File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 186, in testSettingException test_capi1() File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 155, in test_capi1 import _testcapi ImportError: No module named _testcapi test_types test_unittest test_doctest test_doctest2 test_StringIO test___all__ test___future__ test__locale test_abc test_aepack test_aepack skipped -- No module named aepack test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_buffer test_bufio test_bytes test_bz2 test_cProfile test_calendar test_call test_capi test_capi skipped -- No module named _testcapi test_cfgparser test_cgi test_charmapcodec test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_cn skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_hk test_codecmaps_hk skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_jp test_codecmaps_jp skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_kr test_codecmaps_kr skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_tw test_codecmaps_tw skipped -- Use of the `urlfetch' resource not enabled test_codecs test_codecs skipped -- No module named _testcapi test_codeop test_coding test_collections test_colorsys test_commands test_compare test_compile test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictviews test_difflib test_dircache test_dis test_distutils test_dl test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_ftplib test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getargs2 skipped -- No module named _testcapi test_getopt test_gettext test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imaplib test_imp test_import test_importhooks test_index test_inspect test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_keywordonlyarg test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_listcomps test_locale test_logging test_long test_long_future test_longexp test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_metaclass test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_normalization test_normalization skipped -- Use of the `urlfetch' resource not enabled test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [12922 refs] [12922 refs] [12922 refs] test_poplib test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [13806 refs] [13806 refs] test_random test_re test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sgmllib test_shelve test_shlex test_shutil test_signal test_site test_slice test_smtplib test_socket test_socket_ssl test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strptime test_struct test_structmembers test_structmembers skipped -- No module named _testcapi test_structseq test_subprocess [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [16188 refs] [13132 refs] [12916 refs] [12917 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] . [12916 refs] [12916 refs] this bit of output is from a test of stdout in a different process ... [12916 refs] [12916 refs] [13132 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_super test_symtable test_syntax test_sys [12916 refs] [12916 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [12918 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_tuple test_typechecks test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_unpack test_unpack_ex test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmlrpc test_xpickle test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zlib 285 tests OK. 1 test failed: test_exceptions 32 tests skipped: test_aepack test_applesingle test_bsddb3 test_capi test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_curses test_getargs2 test_ioctl test_linuxaudiodev test_macostools test_normalization test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socketserver test_startfile test_structmembers test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_getargs2 test_capi test_tcl test_ioctl test_structmembers test_codecs [628122 refs] From nnorwitz at gmail.com Wed Jun 13 02:53:25 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Tue, 12 Jun 2007 20:53:25 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures opt (1) Message-ID: <20070613005325.GA19109@python.psfb.org> test_grammar test_opcodes test_dict test_builtin test_exceptions test test_exceptions failed -- Traceback (most recent call last): File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 186, in testSettingException test_capi1() File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 155, in test_capi1 import _testcapi ImportError: No module named _testcapi test_types test_unittest test_doctest test_doctest2 test_StringIO test___all__ test___future__ test__locale test_abc test_aepack test_aepack skipped -- No module named aepack test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_buffer test_bufio test_bytes test_bz2 test_cProfile test_calendar test_call test_capi test_capi skipped -- No module named _testcapi test_cfgparser test_cgi test_charmapcodec test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_cn skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_hk test_codecmaps_hk skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_jp test_codecmaps_jp skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_kr test_codecmaps_kr skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_tw test_codecmaps_tw skipped -- Use of the `urlfetch' resource not enabled test_codecs test_codecs skipped -- No module named _testcapi test_codeop test_coding test_collections test_colorsys test_commands test_compare test_compile test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictviews test_difflib test_dircache test_dis test_distutils [16353 refs] test_dl test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_ftplib test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getargs2 skipped -- No module named _testcapi test_getopt test_gettext test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imaplib test_imp test_import test_importhooks test_index test_inspect test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_keywordonlyarg test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_listcomps test_locale test_logging test_long test_long_future test_longexp test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_metaclass test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_normalization test_normalization skipped -- Use of the `urlfetch' resource not enabled test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [12922 refs] [12922 refs] [12922 refs] test_poplib test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [13806 refs] [13806 refs] test_random test_re test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sgmllib test_shelve test_shlex test_shutil test_signal test_site test_slice test_smtplib test_socket test_socket_ssl test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strptime test_struct test_structmembers test_structmembers skipped -- No module named _testcapi test_structseq test_subprocess [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [16188 refs] [13132 refs] [12916 refs] [12917 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] . [12916 refs] [12916 refs] this bit of output is from a test of stdout in a different process ... [12916 refs] [12916 refs] [13132 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_super test_symtable test_syntax test_sys [12916 refs] [12916 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [12918 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_tuple test_typechecks test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_unpack test_unpack_ex test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmlrpc test_xpickle test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zlib 285 tests OK. 1 test failed: test_exceptions 32 tests skipped: test_aepack test_applesingle test_bsddb3 test_capi test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_curses test_getargs2 test_ioctl test_linuxaudiodev test_macostools test_normalization test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socketserver test_startfile test_structmembers test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_getargs2 test_capi test_tcl test_ioctl test_structmembers test_codecs [627318 refs] From python-3000-checkins at python.org Wed Jun 13 03:04:35 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Wed, 13 Jun 2007 03:04:35 +0200 (CEST) Subject: [Python-3000-checkins] r55945 - python/branches/py3k-struni/Objects/unicodeobject.c Message-ID: <20070613010435.AE7B31E4009@bag.python.org> Author: guido.van.rossum Date: Wed Jun 13 03:04:27 2007 New Revision: 55945 Modified: python/branches/py3k-struni/Objects/unicodeobject.c Log: Make it compile with GCC 2.96. Modified: python/branches/py3k-struni/Objects/unicodeobject.c ============================================================================== --- python/branches/py3k-struni/Objects/unicodeobject.c (original) +++ python/branches/py3k-struni/Objects/unicodeobject.c Wed Jun 13 03:04:27 2007 @@ -803,11 +803,13 @@ case 'S': case 'R': { + Py_UNICODE *ucopy; + Py_ssize_t usize; + Py_ssize_t upos; /* unused, since we already have the result */ (void) va_arg(vargs, PyObject *); - Py_UNICODE *ucopy = PyUnicode_AS_UNICODE(*callresult); - Py_ssize_t usize = PyUnicode_GET_SIZE(*callresult); - Py_ssize_t upos; + ucopy = PyUnicode_AS_UNICODE(*callresult); + usize = PyUnicode_GET_SIZE(*callresult); for (upos = 0; upos forget it */ From python-3000-checkins at python.org Wed Jun 13 03:46:34 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Wed, 13 Jun 2007 03:46:34 +0200 (CEST) Subject: [Python-3000-checkins] r55946 - in python/branches/py3k-struni: Lib/test/test_bz2.py Modules/bz2module.c Message-ID: <20070613014634.396FE1E4004@bag.python.org> Author: guido.van.rossum Date: Wed Jun 13 03:46:31 2007 New Revision: 55946 Modified: python/branches/py3k-struni/Lib/test/test_bz2.py python/branches/py3k-struni/Modules/bz2module.c Log: Fix bz2_test.py by removing the tests for universal newline mode. If you want text support, wrap a TextIOWrapper around it. Remove references to universal newlines from the BZ2File docstring. Modified: python/branches/py3k-struni/Lib/test/test_bz2.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_bz2.py (original) +++ python/branches/py3k-struni/Lib/test/test_bz2.py Wed Jun 13 03:46:31 2007 @@ -112,22 +112,6 @@ self.assertEqual(list(iter(bz2f)), sio.readlines()) bz2f.close() - def testUniversalNewlinesLF(self): - # "Test BZ2File.read() with universal newlines (\\n)" - self.createTempFile() - bz2f = BZ2File(self.filename, "rU") - self.assertEqual(bz2f.read(), self.TEXT) - self.assertEqual(bz2f.newlines, b"\n") - bz2f.close() - - def testUniversalNewlinesCRLF(self): - # "Test BZ2File.read() with universal newlines (\\r\\n)" - self.createTempFile(crlf=1) - bz2f = BZ2File(self.filename, "rU") - self.assertEqual(bz2f.read(), self.TEXT) - self.assertEqual(bz2f.newlines, b"\r\n") - bz2f.close() - def testWrite(self): # "Test BZ2File.write()" bz2f = BZ2File(self.filename, "w") @@ -240,16 +224,6 @@ # "Test opening a nonexistent file" self.assertRaises(IOError, BZ2File, "/non/existent") - def testModeU(self): - # Bug #1194181: bz2.BZ2File opened for write with mode "U" - self.createTempFile() - bz2f = BZ2File(self.filename, "U") - bz2f.close() - f = open(self.filename, "rb") - f.seek(0, 2) - self.assertEqual(f.tell(), len(self.DATA)) - f.close() - def testBug1191043(self): # readlines() for files containing no newline data = b'BZh91AY&SY\xd9b\x89]\x00\x00\x00\x03\x80\x04\x00\x02\x00\x0c\x00 \x00!\x9ah3M\x13<]\xc9\x14\xe1BCe\x8a%t' Modified: python/branches/py3k-struni/Modules/bz2module.c ============================================================================== --- python/branches/py3k-struni/Modules/bz2module.c (original) +++ python/branches/py3k-struni/Modules/bz2module.c Wed Jun 13 03:46:31 2007 @@ -1294,17 +1294,8 @@ exist, and truncated otherwise. If the buffering argument is given, 0 means\n\ unbuffered, and larger numbers specify the buffer size. If compresslevel\n\ is given, must be a number between 1 and 9.\n\ -") -PyDoc_STR( -"\n\ -Add a 'U' to mode to open the file for input with universal newline\n\ -support. Any line ending in the input file will be seen as a '\\n' in\n\ -Python. Also, a file so opened gains the attribute 'newlines'; the value\n\ -for this attribute is one of None (no newline read yet), '\\r', '\\n',\n\ -'\\r\\n' or a tuple containing all the newline types seen. Universal\n\ -newlines are available only when reading.\n\ -") -; +Data read is always returned in bytes; data written ought to be bytes.\n\ +"); static PyTypeObject BZ2File_Type = { PyObject_HEAD_INIT(NULL) From nnorwitz at gmail.com Wed Jun 13 03:51:55 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Tue, 12 Jun 2007 21:51:55 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures refleak (1) Message-ID: <20070613015155.GA24601@python.psfb.org> test_threading_local leaked [0, -1, 1] references, sum=0 test_urllib2_localnet leaked [3, 3, 3] references, sum=9 From python-3000-checkins at python.org Wed Jun 13 03:55:51 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Wed, 13 Jun 2007 03:55:51 +0200 (CEST) Subject: [Python-3000-checkins] r55947 - python/branches/py3k-struni/Lib/test/test_os.py Message-ID: <20070613015551.C249F1E4002@bag.python.org> Author: guido.van.rossum Date: Wed Jun 13 03:55:50 2007 New Revision: 55947 Modified: python/branches/py3k-struni/Lib/test/test_os.py Log: Make test_tmpfile() pass. (And hence test_os.py as a whole passes.) tmpfile() now is a binary file. Modified: python/branches/py3k-struni/Lib/test/test_os.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_os.py (original) +++ python/branches/py3k-struni/Lib/test/test_os.py Wed Jun 13 03:55:50 2007 @@ -61,10 +61,10 @@ return fp = os.tmpfile() fp.write("foobar") - fp.seek(0,0) + fp.seek(0) s = fp.read() fp.close() - self.assert_(s == "foobar") + self.assertEquals(s, b"foobar") def test_tmpnam(self): import sys From nnorwitz at gmail.com Wed Jun 13 04:03:15 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Tue, 12 Jun 2007 22:03:15 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures all (1) Message-ID: <20070613020315.GA26399@python.psfb.org> test_grammar test_opcodes test_dict test_builtin test_exceptions test test_exceptions failed -- Traceback (most recent call last): File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 186, in testSettingException test_capi1() File "/tmp/python-test-3.0/local/lib/python3.0/test/test_exceptions.py", line 155, in test_capi1 import _testcapi ImportError: No module named _testcapi test_types test_unittest test_doctest test_doctest2 test_StringIO test___all__ test___future__ test__locale test_abc test_aepack test_aepack skipped -- No module named aepack test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb3 test_buffer test_bufio test_bytes test_bz2 test_cProfile test_calendar test_call test_capi test_capi skipped -- No module named _testcapi test_cfgparser test_cgi test_charmapcodec test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codecs skipped -- No module named _testcapi test_codeop test_coding test_collections test_colorsys test_commands test_compare test_compile test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictviews test_difflib test_dircache test_dis test_distutils test_dl test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_ftplib test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getargs2 skipped -- No module named _testcapi test_getopt test_gettext test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imaplib test_imp test_import test_importhooks test_index test_inspect test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_keywordonlyarg test_largefile test_list test_listcomps test_locale test_logging test_long test_long_future test_longexp test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_metaclass test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [12922 refs] [12922 refs] [12922 refs] test_poplib test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [13806 refs] [13806 refs] test_random test_re test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sgmllib test_shelve test_shlex test_shutil test_signal test_site test_slice test_smtplib test_socket test_socket_ssl test_socketserver test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strptime test_struct test_structmembers test_structmembers skipped -- No module named _testcapi test_structseq test_subprocess [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [16188 refs] [13132 refs] [12916 refs] [12917 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] . [12916 refs] [12916 refs] this bit of output is from a test of stdout in a different process ... [12916 refs] [12916 refs] [13132 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_super test_symtable test_syntax test_sys [12916 refs] [12916 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [12918 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_tokenize test_trace test_traceback test_tuple test_typechecks test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_unpack test_unpack_ex test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllibnet test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmlrpc test_xpickle test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zlib 296 tests OK. 1 test failed: test_exceptions 18 tests skipped: test_aepack test_applesingle test_capi test_codecs test_getargs2 test_ioctl test_macostools test_pep277 test_plistlib test_scriptpackages test_startfile test_structmembers test_sunaudiodev test_tcl test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_getargs2 test_capi test_tcl test_ioctl test_structmembers test_codecs [642099 refs] From python-3000-checkins at python.org Wed Jun 13 06:56:35 2007 From: python-3000-checkins at python.org (neal.norwitz) Date: Wed, 13 Jun 2007 06:56:35 +0200 (CEST) Subject: [Python-3000-checkins] r55954 - in python/branches/p3yk: Include/pyport.h Lib/platform.py PCbuild/_bsddb.vcproj PCbuild/_ssl.mak PCbuild/build_ssl.bat PCbuild/build_ssl.py Tools/buildbot/build-amd64.bat Tools/buildbot/external-amd64.bat Message-ID: <20070613045635.5A4D11E4008@bag.python.org> Author: neal.norwitz Date: Wed Jun 13 06:56:32 2007 New Revision: 55954 Added: python/branches/p3yk/Tools/buildbot/external-amd64.bat - copied unchanged from r55948, python/trunk/Tools/buildbot/external-amd64.bat Modified: python/branches/p3yk/ (props changed) python/branches/p3yk/Include/pyport.h python/branches/p3yk/Lib/platform.py python/branches/p3yk/PCbuild/_bsddb.vcproj python/branches/p3yk/PCbuild/_ssl.mak python/branches/p3yk/PCbuild/build_ssl.bat python/branches/p3yk/PCbuild/build_ssl.py python/branches/p3yk/Tools/buildbot/build-amd64.bat Log: Merged revisions 55913-55950 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r55926 | marc-andre.lemburg | 2007-06-12 02:09:58 -0700 (Tue, 12 Jun 2007) | 3 lines Apply patch #1734945 to support TurboLinux as distribution. ........ r55927 | marc-andre.lemburg | 2007-06-12 02:26:49 -0700 (Tue, 12 Jun 2007) | 3 lines Add patch #1726668: Windows Vista support. ........ r55929 | thomas.heller | 2007-06-12 08:36:22 -0700 (Tue, 12 Jun 2007) | 1 line Checkout, but do not yet try to build, exernal sources. ........ r55930 | thomas.heller | 2007-06-12 09:08:27 -0700 (Tue, 12 Jun 2007) | 6 lines Add bufferoverflowU.lib to the libraries needed by _ssl (is this the right thing to do?). Set the /XP64 /RETAIL build enviroment in the makefile when building ReleaseAMD64. ........ r55931 | thomas.heller | 2007-06-12 09:23:19 -0700 (Tue, 12 Jun 2007) | 5 lines Revert this change, since it breaks the win32 build: Add bufferoverflowU.lib to the libraries needed by _ssl (is this the right thing to do?). ........ r55934 | thomas.heller | 2007-06-12 10:28:31 -0700 (Tue, 12 Jun 2007) | 3 lines Specify the bufferoverflowU.lib to the makefile on the command line (for ReleaseAMD64 builds). ........ r55937 | thomas.heller | 2007-06-12 12:02:59 -0700 (Tue, 12 Jun 2007) | 3 lines Add bufferoverflowU.lib to PCBuild\_bsddb.vcproj. Build sqlite3.dll and bsddb. ........ r55938 | thomas.heller | 2007-06-12 12:56:12 -0700 (Tue, 12 Jun 2007) | 2 lines Don't rebuild Berkeley DB if not needed (this was committed by accident). ........ r55948 | martin.v.loewis | 2007-06-12 20:42:19 -0700 (Tue, 12 Jun 2007) | 3 lines Provide PY_LLONG_MAX on all systems having long long. Will backport to 2.5. ........ Modified: python/branches/p3yk/Include/pyport.h ============================================================================== --- python/branches/p3yk/Include/pyport.h (original) +++ python/branches/p3yk/Include/pyport.h Wed Jun 13 06:56:32 2007 @@ -51,14 +51,20 @@ #ifndef PY_LONG_LONG #define PY_LONG_LONG long long #if defined(LLONG_MAX) +/* If LLONG_MAX is defined in limits.h, use that. */ #define PY_LLONG_MIN LLONG_MIN #define PY_LLONG_MAX LLONG_MAX #define PY_ULLONG_MAX ULLONG_MAX -#elif defined(__s390__) -/* Apparently, S390 Linux has long long, but no LLONG_MAX */ -#define PY_LLONG_MAX 9223372036854775807LL +#elif defined(__LONG_LONG_MAX__) +/* Otherwise, if GCC has a builtin define, use that. */ +#define PY_LLONG_MAX __LONG_LONG_MAX__ +#define PY_LLONG_MIN (-PY_LLONG_MAX-1) +#define PY_ULLONG_MAX (__LONG_LONG_MAX__*2ULL + 1ULL) +#else +/* Otherwise, rely on two's complement. */ +#define PY_ULLONG_MAX (~0ULL) +#define PY_LLONG_MAX ((long long)(PY_ULLONG_MAX>>1)) #define PY_LLONG_MIN (-PY_LLONG_MAX-1) -#define PY_ULLONG_MAX 18446744073709551615ULL #endif /* LLONG_MAX */ #endif #endif /* HAVE_LONG_LONG */ Modified: python/branches/p3yk/Lib/platform.py ============================================================================== --- python/branches/p3yk/Lib/platform.py (original) +++ python/branches/p3yk/Lib/platform.py Wed Jun 13 06:56:32 2007 @@ -242,7 +242,7 @@ _supported_dists = ('SuSE', 'debian', 'fedora', 'redhat', 'centos', 'mandrake', 'rocks', 'slackware', 'yellowdog', - 'gentoo', 'UnitedLinux') + 'gentoo', 'UnitedLinux', 'turbolinux') def _parse_release_file(firstline): @@ -600,6 +600,16 @@ release = '2003Server' else: release = 'post2003' + elif maj == 6: + if min == 0: + # Per http://msdn2.microsoft.com/en-us/library/ms724429.aspx + productType = GetVersionEx(1)[8] + if productType == 1: # VER_NT_WORKSTATION + release = 'Vista' + else: + release = '2008Server' + else: + release = 'post2008Server' else: if not release: # E.g. Win3.1 with win32s @@ -1064,6 +1074,16 @@ # (_syscmd_ver() tends to return the vendor name as well) if system == 'Microsoft Windows': system = 'Windows' + elif system == 'Microsoft' and release == 'Windows': + # Under Windows Vista and Windows Server 2008, + # Microsoft changed the output of the ver command. The + # release is no longer printed. This causes the + # system and release to be misidentified. + system = 'Windows' + if '6.0' == version[:3]: + release = 'Vista' + else: + release = '' # In case we still don't know anything useful, we'll try to # help ourselves Modified: python/branches/p3yk/PCbuild/_bsddb.vcproj ============================================================================== --- python/branches/p3yk/PCbuild/_bsddb.vcproj (original) +++ python/branches/p3yk/PCbuild/_bsddb.vcproj Wed Jun 13 06:56:32 2007 @@ -213,7 +213,7 @@ test_threading_local leaked [-10, 10, -91] references, sum=-91 test_urllib2_localnet leaked [3, 3, 3] references, sum=9 From python-3000-checkins at python.org Wed Jun 13 18:22:48 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Wed, 13 Jun 2007 18:22:48 +0200 (CEST) Subject: [Python-3000-checkins] r55959 - python/branches/p3yk/Modules/_testcapimodule.c Message-ID: <20070613162248.E9A2E1E4002@bag.python.org> Author: guido.van.rossum Date: Wed Jun 13 18:22:41 2007 New Revision: 55959 Modified: python/branches/p3yk/Modules/_testcapimodule.c Log: Fix a compilation warning. Modified: python/branches/p3yk/Modules/_testcapimodule.c ============================================================================== --- python/branches/p3yk/Modules/_testcapimodule.c (original) +++ python/branches/p3yk/Modules/_testcapimodule.c Wed Jun 13 18:22:41 2007 @@ -728,7 +728,7 @@ e->tv_sec -=1; e->tv_usec += 1000000; } - printf("Test %d: %d.%06ds\n", test, (int)e->tv_sec, e->tv_usec); + printf("Test %d: %d.%06ds\n", test, (int)e->tv_sec, (int)e->tv_usec); } static PyObject * From python-3000-checkins at python.org Wed Jun 13 18:27:51 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Wed, 13 Jun 2007 18:27:51 +0200 (CEST) Subject: [Python-3000-checkins] r55960 - python/branches/py3k-struni/Objects/typeobject.c Message-ID: <20070613162751.C2D4F1E4005@bag.python.org> Author: guido.van.rossum Date: Wed Jun 13 18:27:47 2007 New Revision: 55960 Modified: python/branches/py3k-struni/Objects/typeobject.c Log: Discard unused function. Modified: python/branches/py3k-struni/Objects/typeobject.c ============================================================================== --- python/branches/py3k-struni/Objects/typeobject.c (original) +++ python/branches/py3k-struni/Objects/typeobject.c Wed Jun 13 18:27:47 2007 @@ -1582,40 +1582,6 @@ return 1; } -/* Replace Unicode objects in slots. */ - -static PyObject * -_unicode_to_string(PyObject *slots, Py_ssize_t nslots) -{ - PyObject *tmp = NULL; - PyObject *slot_name, *new_name; - Py_ssize_t i; - - for (i = 0; i < nslots; i++) { - if (PyUnicode_Check(slot_name = PyTuple_GET_ITEM(slots, i))) { - if (tmp == NULL) { - tmp = PySequence_List(slots); - if (tmp == NULL) - return NULL; - } - new_name = _PyUnicode_AsDefaultEncodedString(slot_name, - NULL); - if (new_name == NULL) { - Py_DECREF(tmp); - return NULL; - } - Py_INCREF(new_name); - PyList_SET_ITEM(tmp, i, new_name); - Py_DECREF(slot_name); - } - } - if (tmp != NULL) { - slots = PyList_AsTuple(tmp); - Py_DECREF(tmp); - } - return slots; -} - /* Forward */ static int object_init(PyObject *self, PyObject *args, PyObject *kwds); From python-3000-checkins at python.org Wed Jun 13 18:28:31 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Wed, 13 Jun 2007 18:28:31 +0200 (CEST) Subject: [Python-3000-checkins] r55961 - in python/branches/py3k-struni/Modules: _cursesmodule.c _sqlite/cursor.c Message-ID: <20070613162831.7A9C31E4004@bag.python.org> Author: guido.van.rossum Date: Wed Jun 13 18:28:25 2007 New Revision: 55961 Modified: python/branches/py3k-struni/Modules/_cursesmodule.c python/branches/py3k-struni/Modules/_sqlite/cursor.c Log: Shut up compiler warnings. Modified: python/branches/py3k-struni/Modules/_cursesmodule.c ============================================================================== --- python/branches/py3k-struni/Modules/_cursesmodule.c (original) +++ python/branches/py3k-struni/Modules/_cursesmodule.c Wed Jun 13 18:28:25 2007 @@ -1745,7 +1745,9 @@ static PyObject * PyCurses_GetWin(PyCursesWindowObject *self, PyObject *temp) { +#if 0 WINDOW *win; +#endif PyCursesInitialised Modified: python/branches/py3k-struni/Modules/_sqlite/cursor.c ============================================================================== --- python/branches/py3k-struni/Modules/_sqlite/cursor.c (original) +++ python/branches/py3k-struni/Modules/_sqlite/cursor.c Wed Jun 13 18:28:25 2007 @@ -36,10 +36,10 @@ PyObject* pysqlite_cursor_iternext(pysqlite_Cursor* self); -static pysqlite_StatementKind detect_statement_type(char* statement) +static pysqlite_StatementKind detect_statement_type(const char* statement) { char buf[20]; - char* src; + const char* src; char* dst; src = statement; From python-3000-checkins at python.org Wed Jun 13 20:09:17 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Wed, 13 Jun 2007 20:09:17 +0200 (CEST) Subject: [Python-3000-checkins] r55963 - in python/branches/py3k-struni: Doc/api/exceptions.tex Doc/lib/libctypes.tex Doc/lib/libdecimal.tex Doc/lib/libexcs.tex Doc/lib/libftplib.tex Doc/lib/libfuncs.tex Doc/lib/libhttplib.tex Doc/lib/libpoplib.tex Doc/lib/libsmtplib.tex Doc/lib/libsocket.tex Doc/lib/libtelnetlib.tex Doc/lib/libthreading.tex Doc/lib/liburllib2.tex Doc/ref/ref2.tex Doc/ref/ref3.tex Doc/tut/tut.tex Doc/whatsnew/whatsnew26.tex Include/abstract.h Include/longobject.h Include/object.h Include/pyerrors.h Include/pyport.h Lib/CGIHTTPServer.py Lib/_abcoll.py Lib/_strptime.py Lib/anydbm.py Lib/bsddb/__init__.py Lib/bsddb/dbshelve.py Lib/bsddb/dbtables.py Lib/bsddb/test/test_1413192.py Lib/bsddb/test/test_basics.py Lib/bsddb/test/test_env_close.py Lib/bsddb/test/test_sequence.py Lib/collections.py Lib/ctypes/__init__.py Lib/ctypes/_endian.py Lib/ctypes/test/test_init.py Lib/ctypes/test/test_numbers.py Lib/dbhash.py Lib/distutils/ccompiler.py Lib/distutils/cmd.py Lib/distutils/command/build_py.py Lib/distutils/command/build_scripts.py Lib/distutils/command/install_scripts.py Lib/distutils/command/register.py Lib/distutils/dir_util.py Lib/distutils/mwerkscompiler.py Lib/distutils/tests/support.py Lib/distutils/tests/test_build_py.py Lib/dumbdbm.py Lib/ftplib.py Lib/imputil.py Lib/mailbox.py Lib/mhlib.py Lib/os.py Lib/plat-atheos/IN.py Lib/plat-mac/aepack.py Lib/plat-mac/bundlebuilder.py Lib/plat-mac/macostools.py Lib/plat-mac/plistlib.py Lib/plat-sunos5/IN.py Lib/plat-sunos5/STROPTS.py Lib/plat-unixware7/IN.py Lib/plat-unixware7/STROPTS.py Lib/platform.py Lib/pty.py Lib/random.py Lib/repr.py Lib/sqlite3/test/dbapi.py Lib/stat.py Lib/tarfile.py Lib/tempfile.py Lib/test/exception_hierarchy.txt Lib/test/list_tests.py Lib/test/output/test_class Lib/test/output/test_tokenize Lib/test/regrtest.py Lib/test/string_tests.py Lib/test/test_abc.py Lib/test/test_array.py Lib/test/test_builtin.py Lib/test/test_bytes.py Lib/test/test_cgi.py Lib/test/test_class.py Lib/test/test_collections.py Lib/test/test_compile.py Lib/test/test_descr.py Lib/test/test_dumbdbm.py Lib/test/test_format.py Lib/test/test_grammar.py Lib/test/test_hexoct.py Lib/test/test_list.py Lib/test/test_long.py Lib/test/test_multibytecodec.py Lib/test/test_peepholer.py Lib/test/test_pep352.py Lib/test/test_repr.py Lib/test/test_str.py Lib/test/test_strptime.py Lib/test/test_structmembers.py Lib/test/test_subprocess.py Lib/test/test_sundry.py Lib/test/test_super.py Lib/test/test_tarfile.py Lib/test/test_tempfile.py Lib/test/test_threading.py Lib/test/test_tuple.py Lib/test/test_unicode.py Lib/test/test_unicode_file.py Lib/test/test_unittest.py Lib/test/test_urllib2.py Lib/test/test_urllib2_localnet.py Lib/test/test_urllib2net.py Lib/test/test_userlist.py Lib/test/test_uu.py Lib/test/test_weakref.py Lib/test/test_xmlrpc.py Lib/test/test_zipimport.py Lib/test/tf_inherit_check.py Lib/test/tokenize_tests.txt Lib/threading.py Lib/tokenize.py Lib/urllib2.py Lib/uu.py Lib/weakref.py Lib/xml/dom/domreg.py Misc/ACKS Misc/NEWS Misc/Vim/python.vim Misc/build.sh Misc/cheatsheet Misc/python-mode.el Misc/valgrind-python.supp Modules/_bsddb.c Modules/_ctypes/_ctypes.c Modules/_ctypes/callbacks.c Modules/_ctypes/callproc.c Modules/_ctypes/cfield.c Modules/_ctypes/ctypes.h Modules/_ctypes/libffi/src/x86/ffi.c Modules/_ctypes/libffi/src/x86/ffi64.c Modules/_ctypes/stgdict.c Modules/_sqlite/cache.c Modules/_sqlite/module.c Modules/_testcapimodule.c Modules/cjkcodecs/multibytecodec.c Modules/getbuildinfo.c Modules/socketmodule.c Objects/abstract.c Objects/bufferobject.c Objects/exceptions.c Objects/intobject.c Objects/longobject.c Objects/stringobject.c Objects/typeobject.c Objects/unicodeobject.c PC/os2emx/python25.def PC/os2vacpp/python.def PC/pyconfig.h PCbuild/_bsddb.vcproj PCbuild/_ssl.mak PCbuild/build_ssl.bat PCbuild/build_ssl.py PCbuild/pcbuild.sln Parser/tokenizer.c Python/ast.c Python/bltinmodule.c Python/compile.c Python/mystrtoul.c Python/peephole.c Python/structmember.c Python/symtable.c README Tools/buildbot/build-amd64.bat Tools/buildbot/clean-amd64.bat Tools/buildbot/external-amd64.bat Tools/buildbot/test-amd64.bat Tools/i18n/msgfmt.py Tools/pybench/Arithmetic.py Tools/pybench/CommandLine.py Tools/pybench/Numbers.py Tools/pybench/systimes.py Tools/scripts/classfix.py Tools/scripts/fixcid.py Tools/scripts/ftpmirror.py Tools/scripts/linktree.py Tools/scripts/methfix.py Tools/scripts/pathfix.py Tools/scripts/reindent.py Tools/scripts/which.py Tools/unicode/makeunicodedata.py Tools/webchecker/websucker.py configure configure.in setup.py Message-ID: <20070613180917.3C5161E4002@bag.python.org> Author: guido.van.rossum Date: Wed Jun 13 20:07:49 2007 New Revision: 55963 Added: python/branches/py3k-struni/Lib/_abcoll.py - copied unchanged from r55959, python/branches/p3yk/Lib/_abcoll.py python/branches/py3k-struni/Lib/test/test_abc.py - copied unchanged from r55959, python/branches/p3yk/Lib/test/test_abc.py python/branches/py3k-struni/Lib/test/test_super.py - copied unchanged from r55959, python/branches/p3yk/Lib/test/test_super.py python/branches/py3k-struni/Lib/test/test_urllib2_localnet.py - copied unchanged from r55959, python/branches/p3yk/Lib/test/test_urllib2_localnet.py python/branches/py3k-struni/Tools/buildbot/build-amd64.bat - copied unchanged from r55959, python/branches/p3yk/Tools/buildbot/build-amd64.bat python/branches/py3k-struni/Tools/buildbot/clean-amd64.bat - copied unchanged from r55959, python/branches/p3yk/Tools/buildbot/clean-amd64.bat python/branches/py3k-struni/Tools/buildbot/external-amd64.bat - copied unchanged from r55959, python/branches/p3yk/Tools/buildbot/external-amd64.bat python/branches/py3k-struni/Tools/buildbot/test-amd64.bat - copied unchanged from r55959, python/branches/p3yk/Tools/buildbot/test-amd64.bat Modified: python/branches/py3k-struni/ (props changed) python/branches/py3k-struni/Doc/api/exceptions.tex python/branches/py3k-struni/Doc/lib/libctypes.tex python/branches/py3k-struni/Doc/lib/libdecimal.tex python/branches/py3k-struni/Doc/lib/libexcs.tex python/branches/py3k-struni/Doc/lib/libftplib.tex python/branches/py3k-struni/Doc/lib/libfuncs.tex python/branches/py3k-struni/Doc/lib/libhttplib.tex python/branches/py3k-struni/Doc/lib/libpoplib.tex python/branches/py3k-struni/Doc/lib/libsmtplib.tex python/branches/py3k-struni/Doc/lib/libsocket.tex python/branches/py3k-struni/Doc/lib/libtelnetlib.tex python/branches/py3k-struni/Doc/lib/libthreading.tex python/branches/py3k-struni/Doc/lib/liburllib2.tex python/branches/py3k-struni/Doc/ref/ref2.tex python/branches/py3k-struni/Doc/ref/ref3.tex python/branches/py3k-struni/Doc/tut/tut.tex python/branches/py3k-struni/Doc/whatsnew/whatsnew26.tex python/branches/py3k-struni/Include/abstract.h python/branches/py3k-struni/Include/longobject.h python/branches/py3k-struni/Include/object.h python/branches/py3k-struni/Include/pyerrors.h python/branches/py3k-struni/Include/pyport.h python/branches/py3k-struni/Lib/CGIHTTPServer.py python/branches/py3k-struni/Lib/_strptime.py python/branches/py3k-struni/Lib/anydbm.py python/branches/py3k-struni/Lib/bsddb/__init__.py python/branches/py3k-struni/Lib/bsddb/dbshelve.py python/branches/py3k-struni/Lib/bsddb/dbtables.py python/branches/py3k-struni/Lib/bsddb/test/test_1413192.py python/branches/py3k-struni/Lib/bsddb/test/test_basics.py python/branches/py3k-struni/Lib/bsddb/test/test_env_close.py python/branches/py3k-struni/Lib/bsddb/test/test_sequence.py python/branches/py3k-struni/Lib/collections.py python/branches/py3k-struni/Lib/ctypes/__init__.py python/branches/py3k-struni/Lib/ctypes/_endian.py python/branches/py3k-struni/Lib/ctypes/test/test_init.py python/branches/py3k-struni/Lib/ctypes/test/test_numbers.py python/branches/py3k-struni/Lib/dbhash.py python/branches/py3k-struni/Lib/distutils/ccompiler.py python/branches/py3k-struni/Lib/distutils/cmd.py python/branches/py3k-struni/Lib/distutils/command/build_py.py python/branches/py3k-struni/Lib/distutils/command/build_scripts.py python/branches/py3k-struni/Lib/distutils/command/install_scripts.py python/branches/py3k-struni/Lib/distutils/command/register.py python/branches/py3k-struni/Lib/distutils/dir_util.py python/branches/py3k-struni/Lib/distutils/mwerkscompiler.py python/branches/py3k-struni/Lib/distutils/tests/support.py python/branches/py3k-struni/Lib/distutils/tests/test_build_py.py python/branches/py3k-struni/Lib/dumbdbm.py python/branches/py3k-struni/Lib/ftplib.py python/branches/py3k-struni/Lib/imputil.py python/branches/py3k-struni/Lib/mailbox.py python/branches/py3k-struni/Lib/mhlib.py python/branches/py3k-struni/Lib/os.py python/branches/py3k-struni/Lib/plat-atheos/IN.py python/branches/py3k-struni/Lib/plat-mac/aepack.py python/branches/py3k-struni/Lib/plat-mac/bundlebuilder.py python/branches/py3k-struni/Lib/plat-mac/macostools.py python/branches/py3k-struni/Lib/plat-mac/plistlib.py python/branches/py3k-struni/Lib/plat-sunos5/IN.py python/branches/py3k-struni/Lib/plat-sunos5/STROPTS.py python/branches/py3k-struni/Lib/plat-unixware7/IN.py python/branches/py3k-struni/Lib/plat-unixware7/STROPTS.py python/branches/py3k-struni/Lib/platform.py python/branches/py3k-struni/Lib/pty.py python/branches/py3k-struni/Lib/random.py python/branches/py3k-struni/Lib/repr.py python/branches/py3k-struni/Lib/sqlite3/test/dbapi.py python/branches/py3k-struni/Lib/stat.py python/branches/py3k-struni/Lib/tarfile.py python/branches/py3k-struni/Lib/tempfile.py python/branches/py3k-struni/Lib/test/exception_hierarchy.txt python/branches/py3k-struni/Lib/test/list_tests.py python/branches/py3k-struni/Lib/test/output/test_class python/branches/py3k-struni/Lib/test/output/test_tokenize python/branches/py3k-struni/Lib/test/regrtest.py python/branches/py3k-struni/Lib/test/string_tests.py python/branches/py3k-struni/Lib/test/test_array.py python/branches/py3k-struni/Lib/test/test_builtin.py python/branches/py3k-struni/Lib/test/test_bytes.py python/branches/py3k-struni/Lib/test/test_cgi.py python/branches/py3k-struni/Lib/test/test_class.py python/branches/py3k-struni/Lib/test/test_collections.py python/branches/py3k-struni/Lib/test/test_compile.py python/branches/py3k-struni/Lib/test/test_descr.py python/branches/py3k-struni/Lib/test/test_dumbdbm.py python/branches/py3k-struni/Lib/test/test_format.py python/branches/py3k-struni/Lib/test/test_grammar.py python/branches/py3k-struni/Lib/test/test_hexoct.py python/branches/py3k-struni/Lib/test/test_list.py python/branches/py3k-struni/Lib/test/test_long.py python/branches/py3k-struni/Lib/test/test_multibytecodec.py python/branches/py3k-struni/Lib/test/test_peepholer.py python/branches/py3k-struni/Lib/test/test_pep352.py python/branches/py3k-struni/Lib/test/test_repr.py python/branches/py3k-struni/Lib/test/test_str.py python/branches/py3k-struni/Lib/test/test_strptime.py python/branches/py3k-struni/Lib/test/test_structmembers.py python/branches/py3k-struni/Lib/test/test_subprocess.py python/branches/py3k-struni/Lib/test/test_sundry.py python/branches/py3k-struni/Lib/test/test_tarfile.py python/branches/py3k-struni/Lib/test/test_tempfile.py python/branches/py3k-struni/Lib/test/test_threading.py python/branches/py3k-struni/Lib/test/test_tuple.py python/branches/py3k-struni/Lib/test/test_unicode.py python/branches/py3k-struni/Lib/test/test_unicode_file.py python/branches/py3k-struni/Lib/test/test_unittest.py python/branches/py3k-struni/Lib/test/test_urllib2.py python/branches/py3k-struni/Lib/test/test_urllib2net.py python/branches/py3k-struni/Lib/test/test_userlist.py python/branches/py3k-struni/Lib/test/test_uu.py python/branches/py3k-struni/Lib/test/test_weakref.py python/branches/py3k-struni/Lib/test/test_xmlrpc.py python/branches/py3k-struni/Lib/test/test_zipimport.py python/branches/py3k-struni/Lib/test/tf_inherit_check.py python/branches/py3k-struni/Lib/test/tokenize_tests.txt python/branches/py3k-struni/Lib/threading.py python/branches/py3k-struni/Lib/tokenize.py python/branches/py3k-struni/Lib/urllib2.py python/branches/py3k-struni/Lib/uu.py python/branches/py3k-struni/Lib/weakref.py python/branches/py3k-struni/Lib/xml/dom/domreg.py python/branches/py3k-struni/Misc/ACKS python/branches/py3k-struni/Misc/NEWS python/branches/py3k-struni/Misc/Vim/python.vim python/branches/py3k-struni/Misc/build.sh python/branches/py3k-struni/Misc/cheatsheet python/branches/py3k-struni/Misc/python-mode.el python/branches/py3k-struni/Misc/valgrind-python.supp python/branches/py3k-struni/Modules/_bsddb.c python/branches/py3k-struni/Modules/_ctypes/_ctypes.c python/branches/py3k-struni/Modules/_ctypes/callbacks.c python/branches/py3k-struni/Modules/_ctypes/callproc.c python/branches/py3k-struni/Modules/_ctypes/cfield.c python/branches/py3k-struni/Modules/_ctypes/ctypes.h python/branches/py3k-struni/Modules/_ctypes/libffi/src/x86/ffi.c python/branches/py3k-struni/Modules/_ctypes/libffi/src/x86/ffi64.c python/branches/py3k-struni/Modules/_ctypes/stgdict.c python/branches/py3k-struni/Modules/_sqlite/cache.c python/branches/py3k-struni/Modules/_sqlite/module.c python/branches/py3k-struni/Modules/_testcapimodule.c python/branches/py3k-struni/Modules/cjkcodecs/multibytecodec.c python/branches/py3k-struni/Modules/getbuildinfo.c python/branches/py3k-struni/Modules/socketmodule.c python/branches/py3k-struni/Objects/abstract.c python/branches/py3k-struni/Objects/bufferobject.c python/branches/py3k-struni/Objects/exceptions.c python/branches/py3k-struni/Objects/intobject.c python/branches/py3k-struni/Objects/longobject.c python/branches/py3k-struni/Objects/stringobject.c python/branches/py3k-struni/Objects/typeobject.c python/branches/py3k-struni/Objects/unicodeobject.c python/branches/py3k-struni/PC/os2emx/python25.def python/branches/py3k-struni/PC/os2vacpp/python.def python/branches/py3k-struni/PC/pyconfig.h python/branches/py3k-struni/PCbuild/_bsddb.vcproj python/branches/py3k-struni/PCbuild/_ssl.mak python/branches/py3k-struni/PCbuild/build_ssl.bat python/branches/py3k-struni/PCbuild/build_ssl.py python/branches/py3k-struni/PCbuild/pcbuild.sln python/branches/py3k-struni/Parser/tokenizer.c python/branches/py3k-struni/Python/ast.c python/branches/py3k-struni/Python/bltinmodule.c python/branches/py3k-struni/Python/compile.c python/branches/py3k-struni/Python/mystrtoul.c python/branches/py3k-struni/Python/peephole.c python/branches/py3k-struni/Python/structmember.c python/branches/py3k-struni/Python/symtable.c python/branches/py3k-struni/README python/branches/py3k-struni/Tools/i18n/msgfmt.py python/branches/py3k-struni/Tools/pybench/Arithmetic.py python/branches/py3k-struni/Tools/pybench/CommandLine.py python/branches/py3k-struni/Tools/pybench/Numbers.py python/branches/py3k-struni/Tools/pybench/systimes.py python/branches/py3k-struni/Tools/scripts/classfix.py python/branches/py3k-struni/Tools/scripts/fixcid.py python/branches/py3k-struni/Tools/scripts/ftpmirror.py python/branches/py3k-struni/Tools/scripts/linktree.py python/branches/py3k-struni/Tools/scripts/methfix.py python/branches/py3k-struni/Tools/scripts/pathfix.py python/branches/py3k-struni/Tools/scripts/reindent.py (props changed) python/branches/py3k-struni/Tools/scripts/which.py python/branches/py3k-struni/Tools/unicode/makeunicodedata.py python/branches/py3k-struni/Tools/webchecker/websucker.py python/branches/py3k-struni/configure python/branches/py3k-struni/configure.in python/branches/py3k-struni/setup.py Log: Merged revisions 55817-55961 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/p3yk ................ r55837 | guido.van.rossum | 2007-06-08 16:04:42 -0700 (Fri, 08 Jun 2007) | 2 lines PEP 3119 -- the abc module. ................ r55838 | guido.van.rossum | 2007-06-08 17:38:55 -0700 (Fri, 08 Jun 2007) | 2 lines Implement part of PEP 3119 -- One Trick Ponies. ................ r55847 | guido.van.rossum | 2007-06-09 08:28:06 -0700 (Sat, 09 Jun 2007) | 2 lines Different way to do one trick ponies, allowing registration (per PEP strawman). ................ r55849 | guido.van.rossum | 2007-06-09 18:06:38 -0700 (Sat, 09 Jun 2007) | 3 lines Make sure that the magic looking for __hash__ (etc.) doesn't apply to real subclasses of Hashable. ................ r55852 | guido.van.rossum | 2007-06-10 08:29:51 -0700 (Sun, 10 Jun 2007) | 2 lines Add some more examples, e.g. generators and dict views. ................ r55853 | guido.van.rossum | 2007-06-10 08:31:59 -0700 (Sun, 10 Jun 2007) | 2 lines keys() and items() *are* containers -- just values() isn't. ................ r55864 | georg.brandl | 2007-06-10 15:29:40 -0700 (Sun, 10 Jun 2007) | 2 lines PEP 3127: new octal literals, binary literals. ................ r55865 | georg.brandl | 2007-06-10 15:31:37 -0700 (Sun, 10 Jun 2007) | 2 lines Some octal literal fixes in Tools. ................ r55866 | georg.brandl | 2007-06-10 15:37:43 -0700 (Sun, 10 Jun 2007) | 2 lines Tokenizer changes for PEP 3127. ................ r55867 | georg.brandl | 2007-06-10 15:37:55 -0700 (Sun, 10 Jun 2007) | 2 lines Some docs for PEP 3127. ................ r55868 | georg.brandl | 2007-06-10 15:44:39 -0700 (Sun, 10 Jun 2007) | 2 lines Missed a place in intobject.c. Is that used anymore anyway? ................ r55871 | neal.norwitz | 2007-06-10 18:31:49 -0700 (Sun, 10 Jun 2007) | 182 lines Merged revisions 55729-55868 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r55731 | neal.norwitz | 2007-06-01 00:29:12 -0700 (Fri, 01 Jun 2007) | 7 lines SF 1668596/1720897: distutils now copies data files even if package_dir is empty. This needs to be backported. I'm too tired tonight. It would be great if someone backports this if the buildbots are ok with it. Otherwise, I will try to get to it tomorrow. ........ r55732 | georg.brandl | 2007-06-01 04:33:33 -0700 (Fri, 01 Jun 2007) | 2 lines Bug #1722484: remove docstrings again when running with -OO. ........ r55735 | georg.brandl | 2007-06-01 12:20:27 -0700 (Fri, 01 Jun 2007) | 2 lines Fix wrong issue number. ........ r55739 | brett.cannon | 2007-06-01 20:02:29 -0700 (Fri, 01 Jun 2007) | 3 lines Have configure raise an error when building on AtheOS. Code specific to AtheOS will be removed in Python 2.7. ........ r55746 | neal.norwitz | 2007-06-02 11:33:53 -0700 (Sat, 02 Jun 2007) | 1 line Update expected birthday of 2.6 ........ r55751 | neal.norwitz | 2007-06-03 13:32:50 -0700 (Sun, 03 Jun 2007) | 10 lines Backout the original 'fix' to 1721309 which had no effect. Different versions of Berkeley DB handle this differently. The comments and bug report should have the details. Memory is allocated in 4.4 (and presumably earlier), but not in 4.5. Thus 4.5 has the free error, but not earlier versions. Mostly update comments, plus make the free conditional. This fix was already applied to the 2.5 branch. ........ r55752 | brett.cannon | 2007-06-03 16:13:41 -0700 (Sun, 03 Jun 2007) | 6 lines Make _strptime.TimeRE().pattern() use ``\s+`` for matching whitespace instead of ``\s*``. This prevents patterns from "stealing" bits from other patterns in order to make a match work. Closes bug #1730389. Will be backported. ........ r55766 | hyeshik.chang | 2007-06-05 11:16:52 -0700 (Tue, 05 Jun 2007) | 4 lines Fix build on FreeBSD. Bluetooth HCI API in FreeBSD is quite different from Linux's. Just fix the build for now but the code doesn't support the complete capability of HCI on FreeBSD yet. ........ r55770 | hyeshik.chang | 2007-06-05 11:58:51 -0700 (Tue, 05 Jun 2007) | 4 lines Bug #1728403: Fix a bug that CJKCodecs StreamReader hangs when it reads a file that ends with incomplete sequence and sizehint argument for .read() is specified. ........ r55775 | hyeshik.chang | 2007-06-05 12:28:15 -0700 (Tue, 05 Jun 2007) | 2 lines Fix for Windows: close a temporary file before trying to delete it. ........ r55783 | guido.van.rossum | 2007-06-05 14:24:47 -0700 (Tue, 05 Jun 2007) | 2 lines Patch by Tim Delany (missing DECREF). SF #1731330. ........ r55785 | collin.winter | 2007-06-05 17:17:35 -0700 (Tue, 05 Jun 2007) | 3 lines Patch #1731049: make threading.py use a proper "raise" when checking internal state, rather than assert statements (which get stripped out by -O). ........ r55786 | facundo.batista | 2007-06-06 08:13:37 -0700 (Wed, 06 Jun 2007) | 4 lines FTP.ntransfercmd method now uses create_connection when passive, using the timeout received in connection time. ........ r55792 | facundo.batista | 2007-06-06 10:15:23 -0700 (Wed, 06 Jun 2007) | 7 lines Added an optional timeout parameter to function urllib2.urlopen, with tests in test_urllib2net.py (must have network resource enabled to execute them). Also modified test_urllib2.py because testing mock classes must take it into acount. Docs are also updated. ........ r55793 | thomas.heller | 2007-06-06 13:19:19 -0700 (Wed, 06 Jun 2007) | 1 line Build _ctypes and _ctypes_test in the ReleaseAMD64 configuration. ........ r55802 | georg.brandl | 2007-06-07 06:23:24 -0700 (Thu, 07 Jun 2007) | 3 lines Disallow function calls like foo(None=1). Backport from py3k rev. 55708 by Guido. ........ r55804 | georg.brandl | 2007-06-07 06:30:24 -0700 (Thu, 07 Jun 2007) | 2 lines Make reindent.py executable. ........ r55805 | georg.brandl | 2007-06-07 06:34:10 -0700 (Thu, 07 Jun 2007) | 2 lines Patch #1667860: Fix UnboundLocalError in urllib2. ........ r55821 | kristjan.jonsson | 2007-06-07 16:53:49 -0700 (Thu, 07 Jun 2007) | 1 line Fixing changes to getbuildinfo.c that broke linux builds ........ r55828 | thomas.heller | 2007-06-08 09:10:27 -0700 (Fri, 08 Jun 2007) | 1 line Make this test work with older Python releases where struct has no 't' format character. ........ r55829 | martin.v.loewis | 2007-06-08 10:29:20 -0700 (Fri, 08 Jun 2007) | 3 lines Bug #1733488: Fix compilation of bufferobject.c on AIX. Will backport to 2.5. ........ r55831 | thomas.heller | 2007-06-08 11:20:09 -0700 (Fri, 08 Jun 2007) | 2 lines [ 1715718 ] x64 clean compile patch for _ctypes, by Kristj?n Valur with small modifications. ........ r55832 | thomas.heller | 2007-06-08 12:01:06 -0700 (Fri, 08 Jun 2007) | 1 line Fix gcc warnings intruduced by passing Py_ssize_t to PyErr_Format calls. ........ r55833 | thomas.heller | 2007-06-08 12:08:31 -0700 (Fri, 08 Jun 2007) | 2 lines Fix wrong documentation, and correct the punktuation. Closes [1700455]. ........ r55834 | thomas.heller | 2007-06-08 12:14:23 -0700 (Fri, 08 Jun 2007) | 1 line Fix warnings by using proper function prototype. ........ r55839 | neal.norwitz | 2007-06-08 20:36:34 -0700 (Fri, 08 Jun 2007) | 7 lines Prevent expandtabs() on string and unicode objects from causing a segfault when a large width is passed on 32-bit platforms. Found by Google. It would be good for people to review this especially carefully and verify I don't have an off by one error and there is no other way to cause overflow. ........ r55841 | neal.norwitz | 2007-06-08 21:48:22 -0700 (Fri, 08 Jun 2007) | 1 line Use macro version of GET_SIZE to avoid Coverity warning (#150) about a possible error. ........ r55842 | martin.v.loewis | 2007-06-09 00:42:52 -0700 (Sat, 09 Jun 2007) | 3 lines Patch #1733960: Allow T_LONGLONG to accept ints. Will backport to 2.5. ........ r55843 | martin.v.loewis | 2007-06-09 00:58:05 -0700 (Sat, 09 Jun 2007) | 2 lines Fix Windows build. ........ r55845 | martin.v.loewis | 2007-06-09 03:10:26 -0700 (Sat, 09 Jun 2007) | 2 lines Provide LLONG_MAX for S390. ........ r55854 | thomas.heller | 2007-06-10 08:59:17 -0700 (Sun, 10 Jun 2007) | 4 lines First version of build scripts for Windows/AMD64 (no external components are built yet, and 'kill_python' is disabled). ........ r55855 | thomas.heller | 2007-06-10 10:55:51 -0700 (Sun, 10 Jun 2007) | 3 lines For now, disable the _bsddb, _sqlite3, _ssl, _testcapi, _tkinter modules in the ReleaseAMD64 configuration because they do not compile. ........ r55856 | thomas.heller | 2007-06-10 11:27:54 -0700 (Sun, 10 Jun 2007) | 1 line Need to set the environment variables, otherwise devenv.com is not found. ........ r55860 | thomas.heller | 2007-06-10 14:01:17 -0700 (Sun, 10 Jun 2007) | 1 line Revert commit 55855. ........ ................ r55880 | neal.norwitz | 2007-06-10 22:07:36 -0700 (Sun, 10 Jun 2007) | 5 lines Fix the refleak counter on test_collections. The ABC metaclass creates a registry which must be cleared on each run. Otherwise, there *seem* to be refleaks when there really aren't any. (The class is held within the registry even though it's no longer needed.) ................ r55884 | neal.norwitz | 2007-06-10 22:46:33 -0700 (Sun, 10 Jun 2007) | 1 line These tests have been removed, so they are no longer needed here ................ r55886 | georg.brandl | 2007-06-11 00:26:37 -0700 (Mon, 11 Jun 2007) | 3 lines Optimize access to True and False in the compiler (if True) and the peepholer (LOAD_NAME True). ................ r55905 | georg.brandl | 2007-06-11 10:02:26 -0700 (Mon, 11 Jun 2007) | 5 lines Remove __oct__ and __hex__ and use __index__ for converting non-ints before formatting in a base. Add a bin() builtin. ................ r55906 | georg.brandl | 2007-06-11 10:04:44 -0700 (Mon, 11 Jun 2007) | 2 lines int(x, 0) does not "guess". ................ r55907 | georg.brandl | 2007-06-11 10:05:47 -0700 (Mon, 11 Jun 2007) | 2 lines Add a comment to explain that nb_oct and nb_hex are nonfunctional. ................ r55908 | guido.van.rossum | 2007-06-11 10:49:18 -0700 (Mon, 11 Jun 2007) | 2 lines Get rid of unused imports and comment. ................ r55910 | guido.van.rossum | 2007-06-11 13:05:17 -0700 (Mon, 11 Jun 2007) | 2 lines _Abstract.__new__ now requires either no arguments or __init__ overridden. ................ r55911 | guido.van.rossum | 2007-06-11 13:07:49 -0700 (Mon, 11 Jun 2007) | 7 lines Move the collections ABCs to a separate file, _abcoll.py, in order to avoid needing to import _collections.so during the bootstrap (this will become apparent in the next submit of os.py). Add (plain and mutable) ABCs for Set, Mapping, Sequence. ................ r55912 | guido.van.rossum | 2007-06-11 13:09:31 -0700 (Mon, 11 Jun 2007) | 2 lines Rewrite the _Environ class to use the new collections ABCs. ................ r55913 | guido.van.rossum | 2007-06-11 13:59:45 -0700 (Mon, 11 Jun 2007) | 72 lines Merged revisions 55869-55912 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r55869 | neal.norwitz | 2007-06-10 17:42:11 -0700 (Sun, 10 Jun 2007) | 1 line Add Atul Varma for patch # 1667860 ........ r55870 | neal.norwitz | 2007-06-10 18:22:03 -0700 (Sun, 10 Jun 2007) | 1 line Ignore valgrind problems on Ubuntu from ld ........ r55872 | neal.norwitz | 2007-06-10 18:48:46 -0700 (Sun, 10 Jun 2007) | 2 lines Ignore config.status.lineno which seems new (new autoconf?) ........ r55873 | neal.norwitz | 2007-06-10 19:14:39 -0700 (Sun, 10 Jun 2007) | 1 line Prevent these tests from running on Win64 since they don\'t apply there either ........ r55874 | neal.norwitz | 2007-06-10 19:16:10 -0700 (Sun, 10 Jun 2007) | 5 lines Fix a bug when there was a newline in the string expandtabs was called on. This also catches another condition that can overflow. Will backport. ........ r55879 | neal.norwitz | 2007-06-10 21:52:37 -0700 (Sun, 10 Jun 2007) | 1 line Prevent hang if the port cannot be opened. ........ r55881 | neal.norwitz | 2007-06-10 22:28:45 -0700 (Sun, 10 Jun 2007) | 4 lines Add all of the distuils modules that don't seem to have explicit tests. :-( Move an import in mworkscompiler so that this module can be imported on any platform. Hopefully this works on all platforms. ........ r55882 | neal.norwitz | 2007-06-10 22:35:10 -0700 (Sun, 10 Jun 2007) | 4 lines SF #1734732, lower case the module names per PEP 8. Will backport. ........ r55885 | neal.norwitz | 2007-06-10 23:16:48 -0700 (Sun, 10 Jun 2007) | 4 lines Not sure why this only fails sometimes on Unix machines. Better to disable it and only import msvccompiler on Windows since that's the only place it can work anyways. ........ r55887 | neal.norwitz | 2007-06-11 00:29:43 -0700 (Mon, 11 Jun 2007) | 4 lines Bug #1734723: Fix repr.Repr() so it doesn't ignore the maxtuple attribute. Will backport ........ r55889 | neal.norwitz | 2007-06-11 00:36:24 -0700 (Mon, 11 Jun 2007) | 1 line Reflow long line ........ r55896 | thomas.heller | 2007-06-11 08:58:33 -0700 (Mon, 11 Jun 2007) | 3 lines Use "O&" in calls to PyArg_Parse when we need a 'void*' instead of "k" or "K" codes. ........ r55901 | facundo.batista | 2007-06-11 09:27:08 -0700 (Mon, 11 Jun 2007) | 5 lines Added versionchanged flag to all the methods which received a new optional timeout parameter, and a versionadded flag to the socket.create_connection function. ........ ................ r55914 | guido.van.rossum | 2007-06-11 14:19:50 -0700 (Mon, 11 Jun 2007) | 3 lines New super() implementation, for PEP 3135 (though the PEP is not yet updated to this design, and small tweaks may still be made later). ................ r55923 | guido.van.rossum | 2007-06-11 21:15:24 -0700 (Mon, 11 Jun 2007) | 4 lines I'm guessing this module broke when Neal ripped out the types module -- it used 'list' both as a local variable and as the built-in list type. Renamed the local variable since that was easier. ................ r55924 | guido.van.rossum | 2007-06-11 21:20:05 -0700 (Mon, 11 Jun 2007) | 5 lines Change all occurrences of super(, ) to super(). Seems to have worked, all the tests still pass. Exception: test_descr and test_descrtut, which have tons of these and are there to test the various usages. ................ r55939 | collin.winter | 2007-06-12 13:57:33 -0700 (Tue, 12 Jun 2007) | 1 line Patch #1735485: remove StandardError from the exception hierarchy. ................ r55954 | neal.norwitz | 2007-06-12 21:56:32 -0700 (Tue, 12 Jun 2007) | 51 lines Merged revisions 55913-55950 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r55926 | marc-andre.lemburg | 2007-06-12 02:09:58 -0700 (Tue, 12 Jun 2007) | 3 lines Apply patch #1734945 to support TurboLinux as distribution. ........ r55927 | marc-andre.lemburg | 2007-06-12 02:26:49 -0700 (Tue, 12 Jun 2007) | 3 lines Add patch #1726668: Windows Vista support. ........ r55929 | thomas.heller | 2007-06-12 08:36:22 -0700 (Tue, 12 Jun 2007) | 1 line Checkout, but do not yet try to build, exernal sources. ........ r55930 | thomas.heller | 2007-06-12 09:08:27 -0700 (Tue, 12 Jun 2007) | 6 lines Add bufferoverflowU.lib to the libraries needed by _ssl (is this the right thing to do?). Set the /XP64 /RETAIL build enviroment in the makefile when building ReleaseAMD64. ........ r55931 | thomas.heller | 2007-06-12 09:23:19 -0700 (Tue, 12 Jun 2007) | 5 lines Revert this change, since it breaks the win32 build: Add bufferoverflowU.lib to the libraries needed by _ssl (is this the right thing to do?). ........ r55934 | thomas.heller | 2007-06-12 10:28:31 -0700 (Tue, 12 Jun 2007) | 3 lines Specify the bufferoverflowU.lib to the makefile on the command line (for ReleaseAMD64 builds). ........ r55937 | thomas.heller | 2007-06-12 12:02:59 -0700 (Tue, 12 Jun 2007) | 3 lines Add bufferoverflowU.lib to PCBuild\_bsddb.vcproj. Build sqlite3.dll and bsddb. ........ r55938 | thomas.heller | 2007-06-12 12:56:12 -0700 (Tue, 12 Jun 2007) | 2 lines Don't rebuild Berkeley DB if not needed (this was committed by accident). ........ r55948 | martin.v.loewis | 2007-06-12 20:42:19 -0700 (Tue, 12 Jun 2007) | 3 lines Provide PY_LLONG_MAX on all systems having long long. Will backport to 2.5. ........ ................ r55959 | guido.van.rossum | 2007-06-13 09:22:41 -0700 (Wed, 13 Jun 2007) | 2 lines Fix a compilation warning. ................ Modified: python/branches/py3k-struni/Doc/api/exceptions.tex ============================================================================== --- python/branches/py3k-struni/Doc/api/exceptions.tex (original) +++ python/branches/py3k-struni/Doc/api/exceptions.tex Wed Jun 13 20:07:49 2007 @@ -381,7 +381,6 @@ \begin{tableiii}{l|l|c}{cdata}{C Name}{Python Name}{Notes} \lineiii{PyExc_BaseException\ttindex{PyExc_BaseException}}{\exception{BaseException}}{(1), (4)} \lineiii{PyExc_Exception\ttindex{PyExc_Exception}}{\exception{Exception}}{(1)} - \lineiii{PyExc_StandardError\ttindex{PyExc_StandardError}}{\exception{StandardError}}{(1)} \lineiii{PyExc_ArithmeticError\ttindex{PyExc_ArithmeticError}}{\exception{ArithmeticError}}{(1)} \lineiii{PyExc_LookupError\ttindex{PyExc_LookupError}}{\exception{LookupError}}{(1)} \lineiii{PyExc_AssertionError\ttindex{PyExc_AssertionError}}{\exception{AssertionError}}{} Modified: python/branches/py3k-struni/Doc/lib/libctypes.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libctypes.tex (original) +++ python/branches/py3k-struni/Doc/lib/libctypes.tex Wed Jun 13 20:07:49 2007 @@ -437,8 +437,8 @@ expecting pointers to mutable memory. If you need mutable memory blocks, ctypes has a \code{create{\_}string{\_}buffer} function which creates these in various ways. The current memory block contents can be -accessed (or changed) with the \code{raw} property, if you want to access -it as NUL terminated string, use the \code{string} property: +accessed (or changed) with the \code{raw} property; if you want to access +it as NUL terminated string, use the \code{value} property: \begin{verbatim} >>> from ctypes import * >>> p = create_string_buffer(3) # create a 3 byte buffer, initialized to NUL bytes Modified: python/branches/py3k-struni/Doc/lib/libdecimal.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libdecimal.tex (original) +++ python/branches/py3k-struni/Doc/lib/libdecimal.tex Wed Jun 13 20:07:49 2007 @@ -845,7 +845,7 @@ The following table summarizes the hierarchy of signals: \begin{verbatim} - exceptions.ArithmeticError(exceptions.StandardError) + exceptions.ArithmeticError(exceptions.Exception) DecimalException Clamped DivisionByZero(DecimalException, exceptions.ZeroDivisionError) Modified: python/branches/py3k-struni/Doc/lib/libexcs.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libexcs.tex (original) +++ python/branches/py3k-struni/Doc/lib/libexcs.tex Wed Jun 13 20:07:49 2007 @@ -64,13 +64,6 @@ \versionchanged[Changed to inherit from \exception{BaseException}]{2.5} \end{excdesc} -\begin{excdesc}{StandardError} -The base class for all built-in exceptions except -\exception{StopIteration}, \exception{GeneratorExit}, -\exception{KeyboardInterrupt} and \exception{SystemExit}. -\exception{StandardError} itself is derived from \exception{Exception}. -\end{excdesc} - \begin{excdesc}{ArithmeticError} The base class for those built-in exceptions that are raised for various arithmetic errors: \exception{OverflowError}, @@ -143,9 +136,9 @@ \begin{excdesc}{GeneratorExit} Raise when a generator's \method{close()} method is called. - It directly inherits from \exception{Exception} instead of - \exception{StandardError} since it is technically not an error. \versionadded{2.5} + \versionchanged[Changed to inherit from Exception instead of + StandardError]{3.0} \end{excdesc} \begin{excdesc}{IOError} @@ -257,10 +250,9 @@ \begin{excdesc}{StopIteration} Raised by builtin \function{next()} and an iterator's \method{__next__()} method to signal that there are no further values. - This is derived from \exception{Exception} rather than - \exception{StandardError}, since this is not considered an error in - its normal application. \versionadded{2.2} + \versionchanged[Changed to inherit from Exception instead of + StandardError]{3.0} \end{excdesc} @@ -304,7 +296,7 @@ Instances have an attribute \member{code} which is set to the proposed exit status or error message (defaulting to \code{None}). Also, this exception derives directly from \exception{BaseException} and - not \exception{StandardError}, since it is not technically an error. + not \exception{Exception}, since it is not technically an error. A call to \function{sys.exit()} is translated into an exception so that clean-up handlers (\keyword{finally} clauses of \keyword{try} statements) @@ -315,7 +307,7 @@ \function{fork()}). The exception inherits from \exception{BaseException} instead of - \exception{StandardError} or \exception{Exception} so that it is not + \exception{Exception} so that it is not accidentally caught by code that catches \exception{Exception}. This allows the exception to properly propagate up and cause the interpreter to exit. \versionchanged[Changed to inherit from \exception{BaseException}]{2.5} Modified: python/branches/py3k-struni/Doc/lib/libftplib.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libftplib.tex (original) +++ python/branches/py3k-struni/Doc/lib/libftplib.tex Wed Jun 13 20:07:49 2007 @@ -46,6 +46,7 @@ The optional \var{timeout} parameter specifies a timeout in seconds for the connection attempt (if is not specified, or passed as None, the global default timeout setting will be used). +\versionchanged[\var{timeout} was added]{2.6} \end{classdesc} \begin{datadesc}{all_errors} @@ -117,6 +118,8 @@ object timeout is used (the timeout that you passed when instantiating the class); if the object timeout is also None, the global default timeout setting will be used. + +\versionchanged[\var{timeout} was added]{2.6} \end{methoddesc} \begin{methoddesc}[FTP]{getwelcome}{} Modified: python/branches/py3k-struni/Doc/lib/libfuncs.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libfuncs.tex (original) +++ python/branches/py3k-struni/Doc/lib/libfuncs.tex Wed Jun 13 20:07:49 2007 @@ -104,6 +104,14 @@ \versionadded{2.3} \end{funcdesc} +\begin{funcdesc}{bin}{x} + Convert an integer number to a binary string. + The result is a valid Python expression. If \var{x} is not a Python + \class{int} object, it has to define an \method{__index__} method + that returns an integer. + \versionadded{3.0} +\end{funcdesc} + \begin{funcdesc}{bool}{\optional{x}} Convert a value to a Boolean, using the standard truth testing procedure. If \var{x} is false or omitted, this returns @@ -540,8 +548,10 @@ \end{funcdesc} \begin{funcdesc}{hex}{x} - Convert an integer number (of any size) to a hexadecimal string. - The result is a valid Python expression. + Convert an integer number to a hexadecimal string. + The result is a valid Python expression. If \var{x} is not a Python + \class{int} object, it has to define an \method{__index__} method + that returns an integer. \versionchanged[Formerly only returned an unsigned literal]{2.4} \end{funcdesc} @@ -559,8 +569,7 @@ representable as a Python integer, possibly embedded in whitespace. The \var{radix} parameter gives the base for the conversion and may be any integer in the range [2, 36], or zero. If - \var{radix} is zero, the proper radix is guessed based on the - contents of string; the interpretation is the same as for integer + \var{radix} is zero, the interpretation is the same as for integer literals. If \var{radix} is specified and \var{x} is not a string, \exception{TypeError} is raised. Otherwise, the argument may be a plain or @@ -707,8 +716,10 @@ \end{funcdesc} \begin{funcdesc}{oct}{x} - Convert an integer number (of any size) to an octal string. The - result is a valid Python expression. + Convert an integer number to an octal string. The + result is a valid Python expression. If \var{x} is not a Python + \class{int} object, it has to define an \method{__index__} method + that returns an integer. \versionchanged[Formerly only returned an unsigned literal]{2.4} \end{funcdesc} Modified: python/branches/py3k-struni/Doc/lib/libhttplib.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libhttplib.tex (original) +++ python/branches/py3k-struni/Doc/lib/libhttplib.tex Wed Jun 13 20:07:49 2007 @@ -49,6 +49,7 @@ >>> h3 = httplib.HTTPConnection('www.cwi.nl', 80, timeout=10) \end{verbatim} \versionadded{2.0} +\versionchanged[\var{timeout} was added]{2.6} \end{classdesc} \begin{classdesc}{HTTPSConnection}{host\optional{, port\optional{, @@ -63,6 +64,7 @@ \warning{This does not do any certificate verification!} \versionadded{2.0} +\versionchanged[\var{timeout} was added]{2.6} \end{classdesc} \begin{classdesc}{HTTPResponse}{sock\optional{, debuglevel=0}\optional{, strict=0}} Modified: python/branches/py3k-struni/Doc/lib/libpoplib.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libpoplib.tex (original) +++ python/branches/py3k-struni/Doc/lib/libpoplib.tex Wed Jun 13 20:07:49 2007 @@ -35,6 +35,8 @@ The optional \var{timeout} parameter specifies a timeout in seconds for the connection attempt (if not specified, or passed as None, the global default timeout setting will be used). + +\versionchanged[\var{timeout} was added]{2.6} \end{classdesc} \begin{classdesc}{POP3_SSL}{host\optional{, port\optional{, keyfile\optional{, certfile}}}} Modified: python/branches/py3k-struni/Doc/lib/libsmtplib.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libsmtplib.tex (original) +++ python/branches/py3k-struni/Doc/lib/libsmtplib.tex Wed Jun 13 20:07:49 2007 @@ -29,6 +29,8 @@ For normal use, you should only require the initialization/connect, \method{sendmail()}, and \method{quit()} methods. An example is included below. + +\versionchanged[\var{timeout} was added]{2.6} \end{classdesc} \begin{classdesc}{SMTP_SSL}{\optional{host\optional{, port\optional{, @@ -45,6 +47,8 @@ The optional \var{timeout} parameter specifies a timeout in seconds for the connection attempt (if not specified, or passed as None, the global default timeout setting will be used). + +\versionchanged[\var{timeout} was added]{2.6} \end{classdesc} \begin{classdesc}{LMTP}{\optional{host\optional{, port\optional{, Modified: python/branches/py3k-struni/Doc/lib/libsocket.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libsocket.tex (original) +++ python/branches/py3k-struni/Doc/lib/libsocket.tex Wed Jun 13 20:07:49 2007 @@ -177,6 +177,7 @@ application-level code. Passing the optional \var{timeout} parameter will set the timeout on the socket instance (if it is not given or \code{None}, the global default timeout setting is used). +\versionadded{2.6} \end{funcdesc} \begin{funcdesc}{getaddrinfo}{host, port\optional{, family\optional{, Modified: python/branches/py3k-struni/Doc/lib/libtelnetlib.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libtelnetlib.tex (original) +++ python/branches/py3k-struni/Doc/lib/libtelnetlib.tex Wed Jun 13 20:07:49 2007 @@ -40,6 +40,7 @@ raise \exception{EOFError} when the end of the connection is read, because they can return an empty string for other reasons. See the individual descriptions below. +\versionchanged[\var{timeout} was added]{2.6} \end{classdesc} @@ -123,6 +124,7 @@ timeout setting will be used). Do not try to reopen an already connected instance. +\versionchanged[\var{timeout} was added]{2.6} \end{methoddesc} \begin{methoddesc}[Telnet]{msg}{msg\optional{, *args}} Modified: python/branches/py3k-struni/Doc/lib/libthreading.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libthreading.tex (original) +++ python/branches/py3k-struni/Doc/lib/libthreading.tex Wed Jun 13 20:07:49 2007 @@ -174,11 +174,14 @@ unlocked, then the \method{acquire()} call resets it to locked and returns. The \method{release()} method should only be called in the locked state; it changes the state to unlocked and returns -immediately. When more than one thread is blocked in -\method{acquire()} waiting for the state to turn to unlocked, only one -thread proceeds when a \method{release()} call resets the state to -unlocked; which one of the waiting threads proceeds is not defined, -and may vary across implementations. +immediately. If an attempt is made to release an unlocked lock, a +\exception{RuntimeError} will be raised. + +When more than one thread is blocked in \method{acquire()} waiting for +the state to turn to unlocked, only one thread proceeds when a +\method{release()} call resets the state to unlocked; which one of the +waiting threads proceeds is not defined, and may vary across +implementations. All methods are executed atomically. @@ -257,8 +260,9 @@ decrement the recursion level is still nonzero, the lock remains locked and owned by the calling thread. -Only call this method when the calling thread owns the lock. -Do not call this method when the lock is unlocked. +Only call this method when the calling thread owns the lock. A +\exception{RuntimeError} is raised if this method is called when the +lock is unlocked. There is no return value. \end{methoddesc} @@ -275,7 +279,8 @@ methods that call the corresponding methods of the associated lock. It also has a \method{wait()} method, and \method{notify()} and \method{notifyAll()} methods. These three must only be called when -the calling thread has acquired the lock. +the calling thread has acquired the lock, otherwise a +\exception{RuntimeError} is raised. The \method{wait()} method releases the lock, and then blocks until it is awakened by a \method{notify()} or \method{notifyAll()} call for @@ -343,9 +348,9 @@ \end{methoddesc} \begin{methoddesc}{wait}{\optional{timeout}} -Wait until notified or until a timeout occurs. -This must only be called when the calling thread has acquired the -lock. +Wait until notified or until a timeout occurs. If the calling thread +has not acquired the lock when this method is called, a +\exception{RuntimeError} is raised. This method releases the underlying lock, and then blocks until it is awakened by a \method{notify()} or \method{notifyAll()} call for the @@ -367,9 +372,10 @@ \end{methoddesc} \begin{methoddesc}{notify}{} -Wake up a thread waiting on this condition, if any. -This must only be called when the calling thread has acquired the -lock. +Wake up a thread waiting on this condition, if any. Wait until +notified or until a timeout occurs. If the calling thread has not +acquired the lock when this method is called, a +\exception{RuntimeError} is raised. This method wakes up one of the threads waiting for the condition variable, if any are waiting; it is a no-op if no threads are waiting. @@ -386,7 +392,9 @@ \begin{methoddesc}{notifyAll}{} Wake up all threads waiting on this condition. This method acts like -\method{notify()}, but wakes up all waiting threads instead of one. +\method{notify()}, but wakes up all waiting threads instead of one. If +the calling thread has not acquired the lock when this method is +called, a \exception{RuntimeError} is raised. \end{methoddesc} @@ -404,8 +412,9 @@ calls \method{release()}. \begin{classdesc}{Semaphore}{\optional{value}} -The optional argument gives the initial value for the internal -counter; it defaults to \code{1}. +The optional argument gives the initial \var{value} for the internal +counter; it defaults to \code{1}. If the \var{value} given is less +than 0, \exception{ValueError} is raised. \end{classdesc} \begin{methoddesc}{acquire}{\optional{blocking}} @@ -586,9 +595,12 @@ \begin{methoddesc}{start}{} Start the thread's activity. -This must be called at most once per thread object. It -arranges for the object's \method{run()} method to be invoked in a -separate thread of control. +It must be called at most once per thread object. It arranges for the +object's \method{run()} method to be invoked in a separate thread of +control. + +This method will raise a \exception{RuntimeException} if called more +than once on the same thread object. \end{methoddesc} \begin{methoddesc}{run}{} @@ -618,11 +630,10 @@ A thread can be \method{join()}ed many times. -A thread cannot join itself because this would cause a -deadlock. - -It is an error to attempt to \method{join()} a thread before it has -been started. +\method{join()} may throw a \exception{RuntimeError}, if an attempt is +made to join the current thread as that would cause a deadlock. It is +also an error to \method{join()} a thread before it has been started +and attempts to do so raises same exception. \end{methoddesc} \begin{methoddesc}{getName}{} @@ -651,7 +662,8 @@ \begin{methoddesc}{setDaemon}{daemonic} Set the thread's daemon flag to the Boolean value \var{daemonic}. -This must be called before \method{start()} is called. +This must be called before \method{start()} is called, otherwise +\exception{RuntimeError} is raised. The initial value is inherited from the creating thread. Modified: python/branches/py3k-struni/Doc/lib/liburllib2.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/liburllib2.tex (original) +++ python/branches/py3k-struni/Doc/lib/liburllib2.tex Wed Jun 13 20:07:49 2007 @@ -14,7 +14,7 @@ The \module{urllib2} module defines the following functions: -\begin{funcdesc}{urlopen}{url\optional{, data}} +\begin{funcdesc}{urlopen}{url\optional{, data}\optional{, timeout}} Open the URL \var{url}, which can be either a string or a \class{Request} object. @@ -27,6 +27,11 @@ \function{urllib.urlencode()} function takes a mapping or sequence of 2-tuples and returns a string in this format. +The optional \var{timeout} parameter specifies a timeout in seconds for the +connection attempt (if not specified, or passed as None, the global default +timeout setting will be used). This actually only work for HTTP, HTTPS, FTP +and FTPS connections. + This function returns a file-like object with two additional methods: \begin{itemize} @@ -40,6 +45,8 @@ Note that \code{None} may be returned if no handler handles the request (though the default installed global \class{OpenerDirector} uses \class{UnknownHandler} to ensure this never happens). + +\versionchanged[\var{timeout} was added]{2.6} \end{funcdesc} \begin{funcdesc}{install_opener}{opener} @@ -351,12 +358,18 @@ \end{itemize} \end{methoddesc} -\begin{methoddesc}[OpenerDirector]{open}{url\optional{, data}} +\begin{methoddesc}[OpenerDirector]{open}{url\optional{, data}{\optional{, timeout}}} Open the given \var{url} (which can be a request object or a string), optionally passing the given \var{data}. Arguments, return values and exceptions raised are the same as those of \function{urlopen()} (which simply calls the \method{open()} method -on the currently installed global \class{OpenerDirector}). +on the currently installed global \class{OpenerDirector}). The optional +\var{timeout} parameter specifies a timeout in seconds for the connection +attempt (if not specified, or passed as None, the global default timeout +setting will be used; this actually only work for HTTP, HTTPS, FTP +and FTPS connections). + +\versionchanged[\var{timeout} was added]{2.6} \end{methoddesc} \begin{methoddesc}[OpenerDirector]{error}{proto\optional{, Modified: python/branches/py3k-struni/Doc/ref/ref2.tex ============================================================================== --- python/branches/py3k-struni/Doc/ref/ref2.tex (original) +++ python/branches/py3k-struni/Doc/ref/ref2.tex Wed Jun 13 20:07:49 2007 @@ -565,6 +565,7 @@ \index{floating point literal} \index{hexadecimal literal} \index{octal literal} +\index{binary literal} \index{decimal literal} \index{imaginary literal} \index{complex!literal} @@ -574,35 +575,32 @@ `\code{-}' and the literal \code{1}. -\subsection{Integer and long integer literals\label{integers}} +\subsection{Integer literals\label{integers}} -Integer and long integer literals are described by the following +Integer literals are described by the following lexical definitions: \begin{productionlist} - \production{longinteger} - {\token{integer} ("l" | "L")} \production{integer} {\token{decimalinteger} | \token{octinteger} | \token{hexinteger}} \production{decimalinteger} - {\token{nonzerodigit} \token{digit}* | "0"} + {\token{nonzerodigit} \token{digit}* | "0"+} \production{octinteger} - {"0" \token{octdigit}+} + {"0" ("o" | "O") \token{octdigit}+} \production{hexinteger} {"0" ("x" | "X") \token{hexdigit}+} + \production{bininteger} + {"0" ("b" | "B") \token{bindigit}+} \production{nonzerodigit} {"1"..."9"} \production{octdigit} {"0"..."7"} \production{hexdigit} {\token{digit} | "a"..."f" | "A"..."F"} + \production{bindigit} + {"0"..."1"} \end{productionlist} -Although both lower case \character{l} and upper case \character{L} are -allowed as suffix for long integers, it is strongly recommended to always -use \character{L}, since the letter \character{l} looks too much like the -digit \character{1}. - Plain integer literals that are above the largest representable plain integer (e.g., 2147483647 when using 32-bit arithmetic) are accepted as if they were long integers instead.\footnote{In versions of Python @@ -613,13 +611,16 @@ from their unsigned value.} There is no limit for long integer literals apart from what can be stored in available memory. -Some examples of plain integer literals (first row) and long integer -literals (second and third rows): +Note that leading zeros in a non-zero decimal number are not allowed. +This is for disambiguation with C-style octal literals, which Python +used before version 3.0. + +Some examples of integer literals: \begin{verbatim} -7 2147483647 0177 -3L 79228162514264337593543950336L 0377L 0x100000000L - 79228162514264337593543950336 0xdeadbeef +7 2147483647 0o177 0b100110111 +3 79228162514264337593543950336 0o377 0x100000000 + 79228162514264337593543950336 0xdeadbeef \end{verbatim} @@ -644,12 +645,10 @@ {("e" | "E") ["+" | "-"] \token{digit}+} \end{productionlist} -Note that the integer and exponent parts of floating point numbers -can look like octal integers, but are interpreted using radix 10. For -example, \samp{077e010} is legal, and denotes the same number -as \samp{77e10}. -The allowed range of floating point literals is -implementation-dependent. +Note that the integer and exponent parts are always interpreted using +radix 10. For example, \samp{077e010} is legal, and denotes the same +number as \samp{77e10}. +The allowed range of floating point literals is implementation-dependent. Some examples of floating point literals: \begin{verbatim} Modified: python/branches/py3k-struni/Doc/ref/ref3.tex ============================================================================== --- python/branches/py3k-struni/Doc/ref/ref3.tex (original) +++ python/branches/py3k-struni/Doc/ref/ref3.tex Wed Jun 13 20:07:49 2007 @@ -2033,17 +2033,11 @@ the appropriate type. \end{methoddesc} -\begin{methoddesc}[numeric object]{__oct__}{self} -\methodline[numeric object]{__hex__}{self} -Called to implement the built-in functions -\function{oct()}\bifuncindex{oct} and -\function{hex()}\bifuncindex{hex}. Should return a string value. -\end{methoddesc} - \begin{methoddesc}[numeric object]{__index__}{self} Called to implement \function{operator.index()}. Also called whenever -Python needs an integer object (such as in slicing). Must return an -integer (int or long). +Python needs an integer object (such as in slicing, or in the built-in +\function{bin()}, \function{hex()} and \function{oct()} functions). +Must return an integer (int or long). \versionadded{2.5} \end{methoddesc} Modified: python/branches/py3k-struni/Doc/tut/tut.tex ============================================================================== --- python/branches/py3k-struni/Doc/tut/tut.tex (original) +++ python/branches/py3k-struni/Doc/tut/tut.tex Wed Jun 13 20:07:49 2007 @@ -2689,7 +2689,7 @@ 'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'ReferenceError', 'RuntimeError', - 'RuntimeWarning', 'StandardError', 'StopIteration', 'SyntaxError', + 'RuntimeWarning', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'True', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', @@ -2734,9 +2734,9 @@ hierarchical filesystem): \begin{verbatim} -Sound/ Top-level package +sound/ Top-level package __init__.py Initialize the sound package - Formats/ Subpackage for file format conversions + formats/ Subpackage for file format conversions __init__.py wavread.py wavwrite.py @@ -2745,13 +2745,13 @@ auread.py auwrite.py ... - Effects/ Subpackage for sound effects + effects/ Subpackage for sound effects __init__.py echo.py surround.py reverse.py ... - Filters/ Subpackage for filters + filters/ Subpackage for filters __init__.py equalizer.py vocoder.py @@ -2774,20 +2774,20 @@ package, for example: \begin{verbatim} -import Sound.Effects.echo +import sound.effects.echo \end{verbatim} -This loads the submodule \module{Sound.Effects.echo}. It must be referenced +This loads the submodule \module{sound.effects.echo}. It must be referenced with its full name. \begin{verbatim} -Sound.Effects.echo.echofilter(input, output, delay=0.7, atten=4) +sound.effects.echo.echofilter(input, output, delay=0.7, atten=4) \end{verbatim} An alternative way of importing the submodule is: \begin{verbatim} -from Sound.Effects import echo +from sound.effects import echo \end{verbatim} This also loads the submodule \module{echo}, and makes it available without @@ -2800,7 +2800,7 @@ Yet another variation is to import the desired function or variable directly: \begin{verbatim} -from Sound.Effects.echo import echofilter +from sound.effects.echo import echofilter \end{verbatim} Again, this loads the submodule \module{echo}, but this makes its function @@ -2827,7 +2827,7 @@ %The \code{__all__} Attribute \ttindex{__all__} -Now what happens when the user writes \code{from Sound.Effects import +Now what happens when the user writes \code{from sound.effects import *}? Ideally, one would hope that this somehow goes out to the filesystem, finds which submodules are present in the package, and imports them all. Unfortunately, this operation does not work very @@ -2849,19 +2849,19 @@ up-to-date when a new version of the package is released. Package authors may also decide not to support it, if they don't see a use for importing * from their package. For example, the file -\file{Sounds/Effects/__init__.py} could contain the following code: +\file{sounds/effects/__init__.py} could contain the following code: \begin{verbatim} __all__ = ["echo", "surround", "reverse"] \end{verbatim} -This would mean that \code{from Sound.Effects import *} would -import the three named submodules of the \module{Sound} package. +This would mean that \code{from sound.effects import *} would +import the three named submodules of the \module{sound} package. -If \code{__all__} is not defined, the statement \code{from Sound.Effects +If \code{__all__} is not defined, the statement \code{from sound.effects import *} does \emph{not} import all submodules from the package -\module{Sound.Effects} into the current namespace; it only ensures that the -package \module{Sound.Effects} has been imported (possibly running any +\module{sound.effects} into the current namespace; it only ensures that the +package \module{sound.effects} has been imported (possibly running any initialization code in \file{__init__.py}) and then imports whatever names are defined in the package. This includes any names defined (and submodules explicitly loaded) by \file{__init__.py}. It also includes any @@ -2869,14 +2869,14 @@ import statements. Consider this code: \begin{verbatim} -import Sound.Effects.echo -import Sound.Effects.surround -from Sound.Effects import * +import sound.effects.echo +import sound.effects.surround +from sound.effects import * \end{verbatim} In this example, the echo and surround modules are imported in the current namespace because they are defined in the -\module{Sound.Effects} package when the \code{from...import} statement +\module{sound.effects} package when the \code{from...import} statement is executed. (This also works when \code{__all__} is defined.) Note that in general the practice of importing \code{*} from a module or @@ -2904,12 +2904,12 @@ statement looks for a top-level module with the given name. When packages are structured into subpackages (as with the -\module{Sound} package in the example), there's no shortcut to refer +\module{sound} package in the example), there's no shortcut to refer to submodules of sibling packages - the full name of the subpackage must be used. For example, if the module -\module{Sound.Filters.vocoder} needs to use the \module{echo} module -in the \module{Sound.Effects} package, it can use \code{from -Sound.Effects import echo}. +\module{sound.filters.vocoder} needs to use the \module{echo} module +in the \module{sound.effects} package, it can use \code{from +sound.effects import echo}. Starting with Python 2.5, in addition to the implicit relative imports described above, you can write explicit relative imports with the @@ -2920,8 +2920,8 @@ \begin{verbatim} from . import echo -from .. import Formats -from ..Filters import equalizer +from .. import formats +from ..filters import equalizer \end{verbatim} Note that both explicit and implicit relative imports are based on the Modified: python/branches/py3k-struni/Doc/whatsnew/whatsnew26.tex ============================================================================== --- python/branches/py3k-struni/Doc/whatsnew/whatsnew26.tex (original) +++ python/branches/py3k-struni/Doc/whatsnew/whatsnew26.tex Wed Jun 13 20:07:49 2007 @@ -53,7 +53,7 @@ \tableofcontents 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 late 2007. +for Python 2.6 has been set; it will probably be released in mid 2008. % Compare with previous release in 2 - 3 sentences here. Modified: python/branches/py3k-struni/Include/abstract.h ============================================================================== --- python/branches/py3k-struni/Include/abstract.h (original) +++ python/branches/py3k-struni/Include/abstract.h Wed Jun 13 20:07:49 2007 @@ -851,6 +851,14 @@ expression: o1 |= o2. */ + PyAPI_FUNC(PyObject *) PyNumber_ToBase(PyObject *n, int base); + + /* + Returns the integer n converted to a string with a base, with a base + marker of 0b, 0o or 0x prefixed if applicable. + If n is not an int object, it is converted with PyNumber_Index first. + */ + /* Sequence protocol:*/ Modified: python/branches/py3k-struni/Include/longobject.h ============================================================================== --- python/branches/py3k-struni/Include/longobject.h (original) +++ python/branches/py3k-struni/Include/longobject.h Wed Jun 13 20:07:49 2007 @@ -109,6 +109,11 @@ unsigned char* bytes, size_t n, int little_endian, int is_signed); + +/* _PyLong_Format: Convert the long to a string object with given base, + appending a base prefix of 0[box] if base is 2, 8 or 16. */ +PyAPI_FUNC(PyObject *) _PyLong_Format(PyObject *aa, int base); + #ifdef __cplusplus } #endif Modified: python/branches/py3k-struni/Include/object.h ============================================================================== --- python/branches/py3k-struni/Include/object.h (original) +++ python/branches/py3k-struni/Include/object.h Wed Jun 13 20:07:49 2007 @@ -171,6 +171,7 @@ unaryfunc nb_int; unaryfunc nb_long; unaryfunc nb_float; + /* NB: nb_oct and nb_hex are not used anymore. */ unaryfunc nb_oct; unaryfunc nb_hex; Modified: python/branches/py3k-struni/Include/pyerrors.h ============================================================================== --- python/branches/py3k-struni/Include/pyerrors.h (original) +++ python/branches/py3k-struni/Include/pyerrors.h Wed Jun 13 20:07:49 2007 @@ -105,7 +105,6 @@ PyAPI_DATA(PyObject *) PyExc_Exception; PyAPI_DATA(PyObject *) PyExc_StopIteration; PyAPI_DATA(PyObject *) PyExc_GeneratorExit; -PyAPI_DATA(PyObject *) PyExc_StandardError; PyAPI_DATA(PyObject *) PyExc_ArithmeticError; PyAPI_DATA(PyObject *) PyExc_LookupError; Modified: python/branches/py3k-struni/Include/pyport.h ============================================================================== --- python/branches/py3k-struni/Include/pyport.h (original) +++ python/branches/py3k-struni/Include/pyport.h Wed Jun 13 20:07:49 2007 @@ -50,6 +50,22 @@ #ifdef HAVE_LONG_LONG #ifndef PY_LONG_LONG #define PY_LONG_LONG long long +#if defined(LLONG_MAX) +/* If LLONG_MAX is defined in limits.h, use that. */ +#define PY_LLONG_MIN LLONG_MIN +#define PY_LLONG_MAX LLONG_MAX +#define PY_ULLONG_MAX ULLONG_MAX +#elif defined(__LONG_LONG_MAX__) +/* Otherwise, if GCC has a builtin define, use that. */ +#define PY_LLONG_MAX __LONG_LONG_MAX__ +#define PY_LLONG_MIN (-PY_LLONG_MAX-1) +#define PY_ULLONG_MAX (__LONG_LONG_MAX__*2ULL + 1ULL) +#else +/* Otherwise, rely on two's complement. */ +#define PY_ULLONG_MAX (~0ULL) +#define PY_LLONG_MAX ((long long)(PY_ULLONG_MAX>>1)) +#define PY_LLONG_MIN (-PY_LLONG_MAX-1) +#endif /* LLONG_MAX */ #endif #endif /* HAVE_LONG_LONG */ Modified: python/branches/py3k-struni/Lib/CGIHTTPServer.py ============================================================================== --- python/branches/py3k-struni/Lib/CGIHTTPServer.py (original) +++ python/branches/py3k-struni/Lib/CGIHTTPServer.py Wed Jun 13 20:07:49 2007 @@ -353,7 +353,7 @@ st = os.stat(path) except os.error: return False - return st.st_mode & 0111 != 0 + return st.st_mode & 0o111 != 0 def test(HandlerClass = CGIHTTPRequestHandler, Modified: python/branches/py3k-struni/Lib/_strptime.py ============================================================================== --- python/branches/py3k-struni/Lib/_strptime.py (original) +++ python/branches/py3k-struni/Lib/_strptime.py Wed Jun 13 20:07:49 2007 @@ -107,7 +107,7 @@ # magical; just happened to have used it everywhere else where a # static date was needed. am_pm = [] - for hour in (01,22): + for hour in (1, 22): time_tuple = time.struct_time((1999,3,17,hour,44,55,2,76,0)) am_pm.append(time.strftime("%p", time_tuple).lower()) self.am_pm = am_pm @@ -186,7 +186,7 @@ self.locale_time = locale_time else: self.locale_time = LocaleTime() - base = super(TimeRE, self) + base = super() base.__init__({ # The " \d" part of the regex is to make %c from ANSI C work 'd': r"(?P3[0-1]|[1-2]\d|0[1-9]|[1-9]| [1-9])", @@ -250,7 +250,7 @@ regex_chars = re_compile(r"([\\.^$*+?\(\){}\[\]|])") format = regex_chars.sub(r"\\\1", format) whitespace_replacement = re_compile('\s+') - format = whitespace_replacement.sub('\s*', format) + format = whitespace_replacement.sub('\s+', format) while '%' in format: directive_index = format.index('%')+1 processed_format = "%s%s%s" % (processed_format, Modified: python/branches/py3k-struni/Lib/anydbm.py ============================================================================== --- python/branches/py3k-struni/Lib/anydbm.py (original) +++ python/branches/py3k-struni/Lib/anydbm.py Wed Jun 13 20:07:49 2007 @@ -3,7 +3,7 @@ Instead of import dbm - d = dbm.open(file, 'w', 0666) + d = dbm.open(file, 'w', 0o666) use @@ -63,7 +63,7 @@ error = tuple(_errors) -def open(file, flag = 'r', mode = 0666): +def open(file, flag = 'r', mode = 0o666): # guess the type of an existing database from whichdb import whichdb result=whichdb(file) Modified: python/branches/py3k-struni/Lib/bsddb/__init__.py ============================================================================== --- python/branches/py3k-struni/Lib/bsddb/__init__.py (original) +++ python/branches/py3k-struni/Lib/bsddb/__init__.py Wed Jun 13 20:07:49 2007 @@ -294,7 +294,7 @@ #---------------------------------------------------------------------- # Compatibility object factory functions -def hashopen(file, flag='c', mode=0666, pgsize=None, ffactor=None, nelem=None, +def hashopen(file, flag='c', mode=0o666, pgsize=None, ffactor=None, nelem=None, cachesize=None, lorder=None, hflags=0): flags = _checkflag(flag, file) @@ -310,7 +310,7 @@ #---------------------------------------------------------------------- -def btopen(file, flag='c', mode=0666, +def btopen(file, flag='c', mode=0o666, btflags=0, cachesize=None, maxkeypage=None, minkeypage=None, pgsize=None, lorder=None): @@ -328,7 +328,7 @@ #---------------------------------------------------------------------- -def rnopen(file, flag='c', mode=0666, +def rnopen(file, flag='c', mode=0o666, rnflags=0, cachesize=None, pgsize=None, lorder=None, rlen=None, delim=None, source=None, pad=None): Modified: python/branches/py3k-struni/Lib/bsddb/dbshelve.py ============================================================================== --- python/branches/py3k-struni/Lib/bsddb/dbshelve.py (original) +++ python/branches/py3k-struni/Lib/bsddb/dbshelve.py Wed Jun 13 20:07:49 2007 @@ -40,7 +40,7 @@ #------------------------------------------------------------------------ -def open(filename, flags=db.DB_CREATE, mode=0660, filetype=db.DB_HASH, +def open(filename, flags=db.DB_CREATE, mode=0o660, filetype=db.DB_HASH, dbenv=None, dbname=None): """ A simple factory function for compatibility with the standard Modified: python/branches/py3k-struni/Lib/bsddb/dbtables.py ============================================================================== --- python/branches/py3k-struni/Lib/bsddb/dbtables.py (original) +++ python/branches/py3k-struni/Lib/bsddb/dbtables.py Wed Jun 13 20:07:49 2007 @@ -38,7 +38,7 @@ class DBIncompleteError(Exception): pass -class TableDBError(StandardError): +class TableDBError(Exception): pass class TableAlreadyExists(TableDBError): pass @@ -134,9 +134,9 @@ class bsdTableDB : - def __init__(self, filename, dbhome, create=0, truncate=0, mode=0600, + def __init__(self, filename, dbhome, create=0, truncate=0, mode=0o600, recover=0, dbflags=0): - """bsdTableDB(filename, dbhome, create=0, truncate=0, mode=0600) + """bsdTableDB(filename, dbhome, create=0, truncate=0, mode=0o600) Open database name in the dbhome BerkeleyDB directory. Use keyword arguments when calling this constructor. Modified: python/branches/py3k-struni/Lib/bsddb/test/test_1413192.py ============================================================================== --- python/branches/py3k-struni/Lib/bsddb/test/test_1413192.py (original) +++ python/branches/py3k-struni/Lib/bsddb/test/test_1413192.py Wed Jun 13 20:07:49 2007 @@ -18,4 +18,4 @@ the_txn = env.txn_begin() map = db.DB(env) -map.open('xxx.db', "p", db.DB_HASH, db.DB_CREATE, 0666, txn=the_txn) +map.open('xxx.db', "p", db.DB_HASH, db.DB_CREATE, 0o666, txn=the_txn) Modified: python/branches/py3k-struni/Lib/bsddb/test/test_basics.py ============================================================================== --- python/branches/py3k-struni/Lib/bsddb/test/test_basics.py (original) +++ python/branches/py3k-struni/Lib/bsddb/test/test_basics.py Wed Jun 13 20:07:49 2007 @@ -44,7 +44,7 @@ dbtype = db.DB_UNKNOWN # must be set in derived class dbopenflags = 0 dbsetflags = 0 - dbmode = 0660 + dbmode = 0o660 dbname = None useEnv = 0 envflags = 0 Modified: python/branches/py3k-struni/Lib/bsddb/test/test_env_close.py ============================================================================== --- python/branches/py3k-struni/Lib/bsddb/test/test_env_close.py (original) +++ python/branches/py3k-struni/Lib/bsddb/test/test_env_close.py Wed Jun 13 20:07:49 2007 @@ -50,10 +50,10 @@ dbenv = db.DBEnv() dbenv.open(self.homeDir, db.DB_INIT_CDB| db.DB_CREATE |db.DB_THREAD|db.DB_INIT_MPOOL, - 0666) + 0o666) d = db.DB(dbenv) - d.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0666) + d.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0o666) try: dbenv.close() @@ -75,10 +75,10 @@ dbenv = db.DBEnv() dbenv.open(self.homeDir, db.DB_INIT_CDB| db.DB_CREATE |db.DB_THREAD|db.DB_INIT_MPOOL, - 0666) + 0o666) d = db.DB(dbenv) - d.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0666) + d.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0o666) try: dbenv.close() Modified: python/branches/py3k-struni/Lib/bsddb/test/test_sequence.py ============================================================================== --- python/branches/py3k-struni/Lib/bsddb/test/test_sequence.py (original) +++ python/branches/py3k-struni/Lib/bsddb/test/test_sequence.py Wed Jun 13 20:07:49 2007 @@ -26,9 +26,9 @@ tempfile.tempdir = None self.dbenv = db.DBEnv() - self.dbenv.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL, 0666) + self.dbenv.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL, 0o666) self.d = db.DB(self.dbenv) - self.d.open(self.filename, db.DB_BTREE, db.DB_CREATE, 0666) + self.d.open(self.filename, db.DB_BTREE, db.DB_CREATE, 0o666) def tearDown(self): if hasattr(self, 'seq'): Modified: python/branches/py3k-struni/Lib/collections.py ============================================================================== --- python/branches/py3k-struni/Lib/collections.py (original) +++ python/branches/py3k-struni/Lib/collections.py Wed Jun 13 20:07:49 2007 @@ -4,6 +4,13 @@ from operator import itemgetter as _itemgetter 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__ + + def NamedTuple(typename, s): """Returns a new subclass of tuple with named fields. Modified: python/branches/py3k-struni/Lib/ctypes/__init__.py ============================================================================== --- python/branches/py3k-struni/Lib/ctypes/__init__.py (original) +++ python/branches/py3k-struni/Lib/ctypes/__init__.py Wed Jun 13 20:07:49 2007 @@ -149,7 +149,7 @@ _type_ = "O" def __repr__(self): try: - return super(py_object, self).__repr__() + return super().__repr__() except ValueError: return "%s()" % type(self).__name__ _check_size(py_object, "P") Modified: python/branches/py3k-struni/Lib/ctypes/_endian.py ============================================================================== --- python/branches/py3k-struni/Lib/ctypes/_endian.py (original) +++ python/branches/py3k-struni/Lib/ctypes/_endian.py Wed Jun 13 20:07:49 2007 @@ -29,7 +29,7 @@ rest = desc[2:] fields.append((name, _other_endian(typ)) + rest) value = fields - super(_swapped_meta, self).__setattr__(attrname, value) + super().__setattr__(attrname, value) ################################################################ Modified: python/branches/py3k-struni/Lib/ctypes/test/test_init.py ============================================================================== --- python/branches/py3k-struni/Lib/ctypes/test/test_init.py (original) +++ python/branches/py3k-struni/Lib/ctypes/test/test_init.py Wed Jun 13 20:07:49 2007 @@ -7,7 +7,7 @@ new_was_called = False def __new__(cls): - result = super(X, cls).__new__(cls) + result = super().__new__(cls) result.new_was_called = True return result Modified: python/branches/py3k-struni/Lib/ctypes/test/test_numbers.py ============================================================================== --- python/branches/py3k-struni/Lib/ctypes/test/test_numbers.py (original) +++ python/branches/py3k-struni/Lib/ctypes/test/test_numbers.py Wed Jun 13 20:07:49 2007 @@ -117,7 +117,10 @@ def test_sizes(self): for t in signed_types + unsigned_types + float_types + bool_types: - size = struct.calcsize(t._type_) + try: + size = struct.calcsize(t._type_) + except struct.error: + continue # sizeof of the type... self.failUnlessEqual(sizeof(t), size) # and sizeof of an instance Modified: python/branches/py3k-struni/Lib/dbhash.py ============================================================================== --- python/branches/py3k-struni/Lib/dbhash.py (original) +++ python/branches/py3k-struni/Lib/dbhash.py Wed Jun 13 20:07:49 2007 @@ -12,5 +12,5 @@ error = bsddb.error # Exported for anydbm -def open(file, flag = 'r', mode=0666): +def open(file, flag = 'r', mode=0o666): return bsddb.hashopen(file, flag, mode) Modified: python/branches/py3k-struni/Lib/distutils/ccompiler.py ============================================================================== --- python/branches/py3k-struni/Lib/distutils/ccompiler.py (original) +++ python/branches/py3k-struni/Lib/distutils/ccompiler.py Wed Jun 13 20:07:49 2007 @@ -1040,7 +1040,7 @@ def move_file (self, src, dst): return move_file (src, dst, dry_run=self.dry_run) - def mkpath (self, name, mode=0777): + def mkpath (self, name, mode=0o777): mkpath (name, mode, self.dry_run) Modified: python/branches/py3k-struni/Lib/distutils/cmd.py ============================================================================== --- python/branches/py3k-struni/Lib/distutils/cmd.py (original) +++ python/branches/py3k-struni/Lib/distutils/cmd.py Wed Jun 13 20:07:49 2007 @@ -356,7 +356,7 @@ util.execute(func, args, msg, dry_run=self.dry_run) - def mkpath (self, name, mode=0777): + def mkpath (self, name, mode=0o777): dir_util.mkpath(name, mode, dry_run=self.dry_run) Modified: python/branches/py3k-struni/Lib/distutils/command/build_py.py ============================================================================== --- python/branches/py3k-struni/Lib/distutils/command/build_py.py (original) +++ python/branches/py3k-struni/Lib/distutils/command/build_py.py Wed Jun 13 20:07:49 2007 @@ -114,7 +114,9 @@ build_dir = os.path.join(*([self.build_lib] + package.split('.'))) # Length of path to strip from found files - plen = len(src_dir)+1 + plen = 0 + if src_dir: + plen = len(src_dir)+1 # Strip directory from globbed filenames filenames = [ Modified: python/branches/py3k-struni/Lib/distutils/command/build_scripts.py ============================================================================== --- python/branches/py3k-struni/Lib/distutils/command/build_scripts.py (original) +++ python/branches/py3k-struni/Lib/distutils/command/build_scripts.py Wed Jun 13 20:07:49 2007 @@ -119,8 +119,8 @@ if self.dry_run: log.info("changing mode of %s", file) else: - oldmode = os.stat(file)[ST_MODE] & 07777 - newmode = (oldmode | 0555) & 07777 + oldmode = os.stat(file)[ST_MODE] & 0o7777 + newmode = (oldmode | 0o555) & 0o7777 if newmode != oldmode: log.info("changing mode of %s from %o to %o", file, oldmode, newmode) Modified: python/branches/py3k-struni/Lib/distutils/command/install_scripts.py ============================================================================== --- python/branches/py3k-struni/Lib/distutils/command/install_scripts.py (original) +++ python/branches/py3k-struni/Lib/distutils/command/install_scripts.py Wed Jun 13 20:07:49 2007 @@ -53,7 +53,7 @@ if self.dry_run: log.info("changing mode of %s", file) else: - mode = ((os.stat(file)[ST_MODE]) | 0555) & 07777 + mode = ((os.stat(file)[ST_MODE]) | 0o555) & 0o7777 log.info("changing mode of %s to %o", file, mode) os.chmod(file, mode) Modified: python/branches/py3k-struni/Lib/distutils/command/register.py ============================================================================== --- python/branches/py3k-struni/Lib/distutils/command/register.py (original) +++ python/branches/py3k-struni/Lib/distutils/command/register.py Wed Jun 13 20:07:49 2007 @@ -183,7 +183,7 @@ username, password)) f.close() try: - os.chmod(rc, 0600) + os.chmod(rc, 0o600) except: pass elif choice == '2': Modified: python/branches/py3k-struni/Lib/distutils/dir_util.py ============================================================================== --- python/branches/py3k-struni/Lib/distutils/dir_util.py (original) +++ python/branches/py3k-struni/Lib/distutils/dir_util.py Wed Jun 13 20:07:49 2007 @@ -18,7 +18,7 @@ # I don't use os.makedirs because a) it's new to Python 1.5.2, and # b) it blows up if the directory already exists (I want to silently # succeed in that case). -def mkpath (name, mode=0777, verbose=0, dry_run=0): +def mkpath (name, mode=0o777, verbose=0, dry_run=0): """Create a directory and any missing ancestor directories. If the directory already exists (or if 'name' is the empty string, which means the current directory, which of course exists), then do @@ -85,7 +85,7 @@ # mkpath () -def create_tree (base_dir, files, mode=0777, verbose=0, dry_run=0): +def create_tree (base_dir, files, mode=0o777, verbose=0, dry_run=0): """Create all the empty directories under 'base_dir' needed to put 'files' there. 'base_dir' is just the a name of a directory Modified: python/branches/py3k-struni/Lib/distutils/mwerkscompiler.py ============================================================================== --- python/branches/py3k-struni/Lib/distutils/mwerkscompiler.py (original) +++ python/branches/py3k-struni/Lib/distutils/mwerkscompiler.py Wed Jun 13 20:07:49 2007 @@ -18,7 +18,6 @@ import distutils.util import distutils.dir_util from distutils import log -import mkcwproject class MWerksCompiler (CCompiler) : """Concrete class that implements an interface to MetroWerks CodeWarrior, @@ -188,6 +187,7 @@ # doesn't have a clue about our working directory. xmlfilename = os.path.join(os.getcwd(), os.path.join(build_temp, xmlname)) log.debug("\tCreate XML file %s", xmlfilename) + import mkcwproject xmlbuilder = mkcwproject.cwxmlgen.ProjectBuilder(settings) xmlbuilder.generate() xmldata = settings['tmp_projectxmldata'] Modified: python/branches/py3k-struni/Lib/distutils/tests/support.py ============================================================================== --- python/branches/py3k-struni/Lib/distutils/tests/support.py (original) +++ python/branches/py3k-struni/Lib/distutils/tests/support.py Wed Jun 13 20:07:49 2007 @@ -9,12 +9,12 @@ class LoggingSilencer(object): def setUp(self): - super(LoggingSilencer, self).setUp() + super().setUp() self.threshold = log.set_threshold(log.FATAL) def tearDown(self): log.set_threshold(self.threshold) - super(LoggingSilencer, self).tearDown() + super().tearDown() class TempdirManager(object): @@ -24,11 +24,11 @@ """ def setUp(self): - super(TempdirManager, self).setUp() + super().setUp() self.tempdirs = [] def tearDown(self): - super(TempdirManager, self).tearDown() + super().tearDown() while self.tempdirs: d = self.tempdirs.pop() shutil.rmtree(d) Modified: python/branches/py3k-struni/Lib/distutils/tests/test_build_py.py ============================================================================== --- python/branches/py3k-struni/Lib/distutils/tests/test_build_py.py (original) +++ python/branches/py3k-struni/Lib/distutils/tests/test_build_py.py Wed Jun 13 20:07:49 2007 @@ -1,10 +1,13 @@ """Tests for distutils.command.build_py.""" import os +import sys +import StringIO import unittest from distutils.command.build_py import build_py from distutils.core import Distribution +from distutils.errors import DistutilsFileError from distutils.tests import support @@ -53,6 +56,38 @@ self.assert_("__init__.pyc" in files) self.assert_("README.txt" in files) + def test_empty_package_dir (self): + # See SF 1668596/1720897. + cwd = os.getcwd() + + # create the distribution files. + sources = self.mkdtemp() + open(os.path.join(sources, "__init__.py"), "w").close() + + testdir = os.path.join(sources, "doc") + os.mkdir(testdir) + open(os.path.join(testdir, "testfile"), "w").close() + + os.chdir(sources) + sys.stdout = StringIO.StringIO() + + try: + dist = Distribution({"packages": ["pkg"], + "package_dir": {"pkg": ""}, + "package_data": {"pkg": ["doc/*"]}}) + # script_name need not exist, it just need to be initialized + dist.script_name = os.path.join(sources, "setup.py") + dist.script_args = ["build"] + dist.parse_command_line() + + try: + dist.run_commands() + except DistutilsFileError: + self.fail("failed package_data test when package_dir is ''") + finally: + # Restore state. + os.chdir(cwd) + sys.stdout = sys.__stdout__ def test_suite(): return unittest.makeSuite(BuildPyTestCase) Modified: python/branches/py3k-struni/Lib/dumbdbm.py ============================================================================== --- python/branches/py3k-struni/Lib/dumbdbm.py (original) +++ python/branches/py3k-struni/Lib/dumbdbm.py Wed Jun 13 20:07:49 2007 @@ -220,7 +220,7 @@ self._os.chmod(file, self._mode) -def open(file, flag=None, mode=0666): +def open(file, flag=None, mode=0o666): """Open the database file, filename, and return corresponding object. The flag argument, used to control how the database is opened in the @@ -229,7 +229,7 @@ not exist. The optional mode argument is the UNIX mode of the file, used only when - the database has to be created. It defaults to octal code 0666 (and + the database has to be created. It defaults to octal code 0o666 (and will be modified by the prevailing umask). """ Modified: python/branches/py3k-struni/Lib/ftplib.py ============================================================================== --- python/branches/py3k-struni/Lib/ftplib.py (original) +++ python/branches/py3k-struni/Lib/ftplib.py Wed Jun 13 20:07:49 2007 @@ -319,9 +319,7 @@ size = None if self.passiveserver: host, port = self.makepasv() - af, socktype, proto, canon, sa = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM)[0] - conn = socket.socket(af, socktype, proto) - conn.connect(sa) + conn = socket.create_connection((host, port), self.timeout) if rest is not None: self.sendcmd("REST %s" % rest) resp = self.sendcmd(cmd) Modified: python/branches/py3k-struni/Lib/imputil.py ============================================================================== --- python/branches/py3k-struni/Lib/imputil.py (original) +++ python/branches/py3k-struni/Lib/imputil.py Wed Jun 13 20:07:49 2007 @@ -476,7 +476,7 @@ s = _os_stat(pathname) except OSError: return None - return (s.st_mode & 0170000) == 0040000 + return (s.st_mode & 0o170000) == 0o040000 def _timestamp(pathname): "Return the file modification time as a Long." Modified: python/branches/py3k-struni/Lib/mailbox.py ============================================================================== --- python/branches/py3k-struni/Lib/mailbox.py (original) +++ python/branches/py3k-struni/Lib/mailbox.py Wed Jun 13 20:07:49 2007 @@ -227,10 +227,10 @@ Mailbox.__init__(self, dirname, factory, create) if not os.path.exists(self._path): if create: - os.mkdir(self._path, 0700) - os.mkdir(os.path.join(self._path, 'tmp'), 0700) - os.mkdir(os.path.join(self._path, 'new'), 0700) - os.mkdir(os.path.join(self._path, 'cur'), 0700) + os.mkdir(self._path, 0o700) + os.mkdir(os.path.join(self._path, 'tmp'), 0o700) + os.mkdir(os.path.join(self._path, 'new'), 0o700) + os.mkdir(os.path.join(self._path, 'cur'), 0o700) else: raise NoSuchMailboxError(self._path) self._toc = {} @@ -802,9 +802,9 @@ Mailbox.__init__(self, path, factory, create) if not os.path.exists(self._path): if create: - os.mkdir(self._path, 0700) + os.mkdir(self._path, 0o700) os.close(os.open(os.path.join(self._path, '.mh_sequences'), - os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0600)) + os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o600)) else: raise NoSuchMailboxError(self._path) self._locked = False Modified: python/branches/py3k-struni/Lib/mhlib.py ============================================================================== --- python/branches/py3k-struni/Lib/mhlib.py (original) +++ python/branches/py3k-struni/Lib/mhlib.py Wed Jun 13 20:07:49 2007 @@ -67,7 +67,7 @@ MH_PROFILE = '~/.mh_profile' PATH = '~/Mail' MH_SEQUENCES = '.mh_sequences' -FOLDER_PROTECT = 0700 +FOLDER_PROTECT = 0o700 # Imported modules Modified: python/branches/py3k-struni/Lib/os.py ============================================================================== --- python/branches/py3k-struni/Lib/os.py (original) +++ python/branches/py3k-struni/Lib/os.py Wed Jun 13 20:07:49 2007 @@ -147,8 +147,8 @@ # Super directory utilities. # (Inspired by Eric Raymond; the doc strings are mostly his) -def makedirs(name, mode=0777): - """makedirs(path [, mode=0777]) +def makedirs(name, mode=0o777): + """makedirs(path [, mode=0o777]) Super-mkdir; create a leaf directory and all intermediate ones. Works like mkdir, except that any intermediate path segment (not @@ -405,108 +405,63 @@ raise error, saved_exc, saved_tb raise error, last_exc, tb -# Change environ to automatically call putenv() if it exists -try: - # This will fail if there's no putenv - putenv -except NameError: - pass + +if name == "riscos": + # On RISC OS, all env access goes through getenv and putenv + from riscosenviron import _Environ else: - import UserDict + # Change environ to automatically call putenv(), unsetenv if they exist. + from _abcoll import MutableMapping # Can't use collections (bootstrap) - # Fake unsetenv() for Windows - # not sure about os2 here but - # I'm guessing they are the same. - - if name in ('os2', 'nt'): - def unsetenv(key): - putenv(key, "") - - if name == "riscos": - # On RISC OS, all env access goes through getenv and putenv - from riscosenviron import _Environ - elif name in ('os2', 'nt'): # Where Env Var Names Must Be UPPERCASE - # But we store them as upper case - class _Environ(UserDict.IterableUserDict): - def __init__(self, environ): - UserDict.UserDict.__init__(self) - data = self.data - for k, v in environ.items(): - data[k.upper()] = v - def __setitem__(self, key, item): - putenv(key, item) - self.data[key.upper()] = item - def __getitem__(self, key): - return self.data[key.upper()] - try: - unsetenv - except NameError: - def __delitem__(self, key): - del self.data[key.upper()] - else: - def __delitem__(self, key): - unsetenv(key) - del self.data[key.upper()] - def __contains__(self, key): - return key.upper() in self.data - def get(self, key, failobj=None): - return self.data.get(key.upper(), failobj) - def update(self, dict=None, **kwargs): - if dict: - try: - keys = dict.keys() - except AttributeError: - # List of (key, value) - for k, v in dict: - self[k] = v - else: - # got keys - # cannot use items(), since mappings - # may not have them. - for k in keys: - self[k] = dict[k] - if kwargs: - self.update(kwargs) - def copy(self): - return dict(self) + class _Environ(MutableMapping): + def __init__(self, environ, keymap, putenv, unsetenv): + self.keymap = keymap + self.putenv = putenv + self.unsetenv = unsetenv + self.data = data = {} + for key, value in environ.items(): + data[keymap(key)] = value + def __getitem__(self, key): + return self.data[self.keymap(key)] + def __setitem__(self, key, item): + self.putenv(key, item) + self.data[self.keymap(key)] = item + def __delitem__(self, key): + self.unsetenv(key) + del self.data[self.keymap(key)] + def __iter__(self): + for key in self.data: + yield key + def __len__(self): + return len(self.data) + def copy(self): + return dict(self) + def setdefault(self, key, value): + if key not in self: + self[key] = value + return self[key] + + try: + _putenv = putenv + except NameError: + _putenv = lambda key, value: None + else: + __all__.append("putenv") + try: + _unsetenv = unsetenv + except NameError: + _unsetenv = lambda key: _putenv(key, "") + else: + __all__.append("unsetenv") + + if name in ('os2', 'nt'): # Where Env Var Names Must Be UPPERCASE + _keymap = lambda key: key.upper() else: # Where Env Var Names Can Be Mixed Case - class _Environ(UserDict.IterableUserDict): - def __init__(self, environ): - UserDict.UserDict.__init__(self) - self.data = environ - def __setitem__(self, key, item): - putenv(key, item) - self.data[key] = item - def update(self, dict=None, **kwargs): - if dict: - try: - keys = dict.keys() - except AttributeError: - # List of (key, value) - for k, v in dict: - self[k] = v - else: - # got keys - # cannot use items(), since mappings - # may not have them. - for k in keys: - self[k] = dict[k] - if kwargs: - self.update(kwargs) - try: - unsetenv - except NameError: - pass - else: - def __delitem__(self, key): - unsetenv(key) - del self.data[key] - def copy(self): - return dict(self) + _keymap = lambda key: key + environ = _Environ(environ, _keymap, _putenv, _unsetenv) - environ = _Environ(environ) def getenv(key, default=None): """Get an environment variable, return None if it doesn't exist. Modified: python/branches/py3k-struni/Lib/plat-atheos/IN.py ============================================================================== --- python/branches/py3k-struni/Lib/plat-atheos/IN.py (original) +++ python/branches/py3k-struni/Lib/plat-atheos/IN.py Wed Jun 13 20:07:49 2007 @@ -557,7 +557,7 @@ # Included from bits/dirent.h def _D_ALLOC_NAMLEN(d): return (_D_EXACT_NAMLEN (d) + 1) -def IFTODT(mode): return (((mode) & 0170000) >> 12) +def IFTODT(mode): return (((mode) & 0o170000) >> 12) def DTTOIF(dirtype): return ((dirtype) << 12) @@ -567,17 +567,17 @@ MAXNAMLEN = 255 # Included from posix/stat.h -S_IFMT = 00170000 -S_IFSOCK = 0140000 -S_IFLNK = 0120000 -S_IFREG = 0100000 -S_IFBLK = 0060000 -S_IFDIR = 0040000 -S_IFCHR = 0020000 -S_IFIFO = 0010000 -S_ISUID = 0004000 -S_ISGID = 0002000 -S_ISVTX = 0001000 +S_IFMT = 0o0170000 +S_IFSOCK = 0o140000 +S_IFLNK = 0o120000 +S_IFREG = 0o100000 +S_IFBLK = 0o060000 +S_IFDIR = 0o040000 +S_IFCHR = 0o020000 +S_IFIFO = 0o010000 +S_ISUID = 0o004000 +S_ISGID = 0o002000 +S_ISVTX = 0o001000 def S_ISLNK(m): return (((m) & S_IFMT) == S_IFLNK) def S_ISREG(m): return (((m) & S_IFMT) == S_IFREG) @@ -592,18 +592,18 @@ def S_ISSOCK(m): return (((m) & S_IFMT) == S_IFSOCK) -S_IRWXU = 00700 -S_IRUSR = 00400 -S_IWUSR = 00200 -S_IXUSR = 00100 -S_IRWXG = 00070 -S_IRGRP = 00040 -S_IWGRP = 00020 -S_IXGRP = 00010 -S_IRWXO = 00007 -S_IROTH = 00004 -S_IWOTH = 00002 -S_IXOTH = 00001 +S_IRWXU = 0o0700 +S_IRUSR = 0o0400 +S_IWUSR = 0o0200 +S_IXUSR = 0o0100 +S_IRWXG = 0o0070 +S_IRGRP = 0o0040 +S_IWGRP = 0o0020 +S_IXGRP = 0o0010 +S_IRWXO = 0o0007 +S_IROTH = 0o0004 +S_IWOTH = 0o0002 +S_IXOTH = 0o0001 S_IRWXUGO = (S_IRWXU|S_IRWXG|S_IRWXO) S_IALLUGO = (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO) S_IRUGO = (S_IRUSR|S_IRGRP|S_IROTH) @@ -612,24 +612,24 @@ _STAT_VER_KERNEL = 0 # Included from posix/fcntl.h -O_ACCMODE = 0003 +O_ACCMODE = 0o003 O_RWMASK = O_ACCMODE O_RDONLY = 00 -O_WRONLY = 01 -O_RDWR = 02 -O_CREAT = 0100 -O_EXCL = 0200 -O_NOCTTY = 0400 -O_TRUNC = 01000 -O_APPEND = 02000 -O_NONBLOCK = 04000 +O_WRONLY = 0o1 +O_RDWR = 0o2 +O_CREAT = 0o100 +O_EXCL = 0o200 +O_NOCTTY = 0o400 +O_TRUNC = 0o1000 +O_APPEND = 0o2000 +O_NONBLOCK = 0o4000 O_NDELAY = O_NONBLOCK -O_SYNC = 010000 +O_SYNC = 0o10000 O_FSYNC = O_SYNC -O_ASYNC = 020000 +O_ASYNC = 0o20000 FASYNC = O_ASYNC -O_DIRECTORY = 040000 -O_NOTRAVERSE = 0100000 +O_DIRECTORY = 0o40000 +O_NOTRAVERSE = 0o100000 O_NOFOLLOW = O_NOTRAVERSE F_DUPFD = 0 F_GETFD = 1 Modified: python/branches/py3k-struni/Lib/plat-mac/aepack.py ============================================================================== --- python/branches/py3k-struni/Lib/plat-mac/aepack.py (original) +++ python/branches/py3k-struni/Lib/plat-mac/aepack.py Wed Jun 13 20:07:49 2007 @@ -100,10 +100,10 @@ data = data[2:] return AE.AECreateDesc('utxt', data) if isinstance(x, list): - list = AE.AECreateList('', 0) + lst = AE.AECreateList('', 0) for item in x: - list.AEPutDesc(0, pack(item)) - return list + lst.AEPutDesc(0, pack(item)) + return lst if isinstance(x, dict): record = AE.AECreateList('', 1) for key, value in x.items(): Modified: python/branches/py3k-struni/Lib/plat-mac/bundlebuilder.py ============================================================================== --- python/branches/py3k-struni/Lib/plat-mac/bundlebuilder.py (original) +++ python/branches/py3k-struni/Lib/plat-mac/bundlebuilder.py Wed Jun 13 20:07:49 2007 @@ -504,7 +504,7 @@ standalone = self.standalone semi_standalone = self.semi_standalone open(bootstrappath, "w").write(BOOTSTRAP_SCRIPT % locals()) - os.chmod(bootstrappath, 0775) + os.chmod(bootstrappath, 0o775) if self.iconfile is not None: iconbase = os.path.basename(self.iconfile) @@ -603,7 +603,7 @@ walk(path) else: mod = os.stat(path)[stat.ST_MODE] - if not (mod & 0100): + if not (mod & 0o100): continue relpath = path[len(self.bundlepath):] self.message("Stripping %s" % relpath, 2) Modified: python/branches/py3k-struni/Lib/plat-mac/macostools.py ============================================================================== --- python/branches/py3k-struni/Lib/plat-mac/macostools.py (original) +++ python/branches/py3k-struni/Lib/plat-mac/macostools.py Wed Jun 13 20:07:49 2007 @@ -61,7 +61,7 @@ if os.sep == ':' and not ':' in head: head = head + ':' mkdirs(head) - os.mkdir(dst, 0777) + os.mkdir(dst, 0o777) def touched(dst): """Tell the finder a file has changed. No-op on MacOSX.""" Modified: python/branches/py3k-struni/Lib/plat-mac/plistlib.py ============================================================================== --- python/branches/py3k-struni/Lib/plat-mac/plistlib.py (original) +++ python/branches/py3k-struni/Lib/plat-mac/plistlib.py Wed Jun 13 20:07:49 2007 @@ -320,7 +320,7 @@ from warnings import warn warn("The plistlib.Dict class is deprecated, use builtin dict instead", PendingDeprecationWarning) - super(Dict, self).__init__(**kwargs) + super().__init__(**kwargs) class Plist(_InternalDict): @@ -333,7 +333,7 @@ from warnings import warn warn("The Plist class is deprecated, use the readPlist() and " "writePlist() functions instead", PendingDeprecationWarning) - super(Plist, self).__init__(**kwargs) + super().__init__(**kwargs) def fromFile(cls, pathOrFile): """Deprecated. Use the readPlist() function instead.""" Modified: python/branches/py3k-struni/Lib/plat-sunos5/IN.py ============================================================================== --- python/branches/py3k-struni/Lib/plat-sunos5/IN.py (original) +++ python/branches/py3k-struni/Lib/plat-sunos5/IN.py Wed Jun 13 20:07:49 2007 @@ -97,7 +97,7 @@ NZERO = 20 NULL = 0 NULL = 0 -CMASK = 022 +CMASK = 0o22 CDLIMIT = (1<<11) NBPS = 0x20000 NBPSCTR = 512 @@ -733,13 +733,13 @@ _XRS_ID = 0x78727300 GETCONTEXT = 0 SETCONTEXT = 1 -UC_SIGMASK = 001 -UC_STACK = 002 -UC_CPU = 004 -UC_MAU = 010 +UC_SIGMASK = 0o01 +UC_STACK = 0o02 +UC_CPU = 0o04 +UC_MAU = 0o10 UC_FPU = UC_MAU -UC_INTR = 020 -UC_ASR = 040 +UC_INTR = 0o20 +UC_ASR = 0o40 UC_MCONTEXT = (UC_CPU|UC_FPU|UC_ASR) UC_ALL = (UC_SIGMASK|UC_STACK|UC_MCONTEXT) _SIGQUEUE_MAX = 32 @@ -1021,14 +1021,14 @@ AT_TIMES = (AT_ATIME|AT_MTIME|AT_CTIME) AT_NOSET = (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\ AT_BLKSIZE|AT_NBLOCKS|AT_VCODE) -VSUID = 04000 -VSGID = 02000 -VSVTX = 01000 -VREAD = 00400 -VWRITE = 00200 -VEXEC = 00100 -MODEMASK = 07777 -PERMMASK = 00777 +VSUID = 0o4000 +VSGID = 0o2000 +VSVTX = 0o1000 +VREAD = 0o0400 +VWRITE = 0o0200 +VEXEC = 0o0100 +MODEMASK = 0o7777 +PERMMASK = 0o0777 def MANDMODE(mode): return (((mode) & (VSGID|(VEXEC>>3))) == VSGID) VSA_ACL = 0x0001 Modified: python/branches/py3k-struni/Lib/plat-sunos5/STROPTS.py ============================================================================== --- python/branches/py3k-struni/Lib/plat-sunos5/STROPTS.py (original) +++ python/branches/py3k-struni/Lib/plat-sunos5/STROPTS.py Wed Jun 13 20:07:49 2007 @@ -94,7 +94,7 @@ NZERO = 20 NULL = 0 NULL = 0 -CMASK = 022 +CMASK = 0o22 CDLIMIT = (1<<11) NBPS = 0x20000 NBPSCTR = 512 @@ -730,13 +730,13 @@ _XRS_ID = 0x78727300 GETCONTEXT = 0 SETCONTEXT = 1 -UC_SIGMASK = 001 -UC_STACK = 002 -UC_CPU = 004 -UC_MAU = 010 +UC_SIGMASK = 0o01 +UC_STACK = 0o02 +UC_CPU = 0o04 +UC_MAU = 0o10 UC_FPU = UC_MAU -UC_INTR = 020 -UC_ASR = 040 +UC_INTR = 0o20 +UC_ASR = 0o40 UC_MCONTEXT = (UC_CPU|UC_FPU|UC_ASR) UC_ALL = (UC_SIGMASK|UC_STACK|UC_MCONTEXT) _SIGQUEUE_MAX = 32 @@ -1400,14 +1400,14 @@ AT_TIMES = (AT_ATIME|AT_MTIME|AT_CTIME) AT_NOSET = (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\ AT_BLKSIZE|AT_NBLOCKS|AT_VCODE) -VSUID = 04000 -VSGID = 02000 -VSVTX = 01000 -VREAD = 00400 -VWRITE = 00200 -VEXEC = 00100 -MODEMASK = 07777 -PERMMASK = 00777 +VSUID = 0o4000 +VSGID = 0o2000 +VSVTX = 0o1000 +VREAD = 0o0400 +VWRITE = 0o0200 +VEXEC = 0o0100 +MODEMASK = 0o7777 +PERMMASK = 0o0777 def MANDMODE(mode): return (((mode) & (VSGID|(VEXEC>>3))) == VSGID) VSA_ACL = 0x0001 Modified: python/branches/py3k-struni/Lib/plat-unixware7/IN.py ============================================================================== --- python/branches/py3k-struni/Lib/plat-unixware7/IN.py (original) +++ python/branches/py3k-struni/Lib/plat-unixware7/IN.py Wed Jun 13 20:07:49 2007 @@ -187,8 +187,8 @@ NC_TPI_COTS_ORD = 3 NC_TPI_RAW = 4 NC_NOFLAG = 00 -NC_VISIBLE = 01 -NC_BROADCAST = 02 +NC_VISIBLE = 0o1 +NC_BROADCAST = 0o2 NC_NOPROTOFMLY = "-" NC_LOOPBACK = "loopback" NC_INET = "inet" Modified: python/branches/py3k-struni/Lib/plat-unixware7/STROPTS.py ============================================================================== --- python/branches/py3k-struni/Lib/plat-unixware7/STROPTS.py (original) +++ python/branches/py3k-struni/Lib/plat-unixware7/STROPTS.py Wed Jun 13 20:07:49 2007 @@ -65,41 +65,41 @@ ES_MACADTLID = 7 ES_PRVID = 8 ES_TPGETMAJOR = 9 -SA_EXEC = 001 -SA_WRITE = 002 -SA_READ = 004 -SA_SUBSIZE = 010 +SA_EXEC = 0o01 +SA_WRITE = 0o02 +SA_READ = 0o04 +SA_SUBSIZE = 0o10 # Included from sys/stropts_f.h X_STR = (ord('S')<<8) -X_I_BASE = (X_STR|0200) -X_I_NREAD = (X_STR|0201) -X_I_PUSH = (X_STR|0202) -X_I_POP = (X_STR|0203) -X_I_LOOK = (X_STR|0204) -X_I_FLUSH = (X_STR|0205) -X_I_SRDOPT = (X_STR|0206) -X_I_GRDOPT = (X_STR|0207) -X_I_STR = (X_STR|0210) -X_I_SETSIG = (X_STR|0211) -X_I_GETSIG = (X_STR|0212) -X_I_FIND = (X_STR|0213) -X_I_LINK = (X_STR|0214) -X_I_UNLINK = (X_STR|0215) -X_I_PEEK = (X_STR|0217) -X_I_FDINSERT = (X_STR|0220) -X_I_SENDFD = (X_STR|0221) -X_I_RECVFD = (X_STR|0222) +X_I_BASE = (X_STR|0o200) +X_I_NREAD = (X_STR|0o201) +X_I_PUSH = (X_STR|0o202) +X_I_POP = (X_STR|0o203) +X_I_LOOK = (X_STR|0o204) +X_I_FLUSH = (X_STR|0o205) +X_I_SRDOPT = (X_STR|0o206) +X_I_GRDOPT = (X_STR|0o207) +X_I_STR = (X_STR|0o210) +X_I_SETSIG = (X_STR|0o211) +X_I_GETSIG = (X_STR|0o212) +X_I_FIND = (X_STR|0o213) +X_I_LINK = (X_STR|0o214) +X_I_UNLINK = (X_STR|0o215) +X_I_PEEK = (X_STR|0o217) +X_I_FDINSERT = (X_STR|0o220) +X_I_SENDFD = (X_STR|0o221) +X_I_RECVFD = (X_STR|0o222) # Included from unistd.h # Included from sys/unistd.h -R_OK = 004 -W_OK = 002 -X_OK = 001 +R_OK = 0o04 +W_OK = 0o02 +X_OK = 0o01 F_OK = 000 -EFF_ONLY_OK = 010 -EX_OK = 020 +EFF_ONLY_OK = 0o10 +EX_OK = 0o20 SEEK_SET = 0 SEEK_CUR = 1 SEEK_END = 2 @@ -289,40 +289,40 @@ ANYMARK = 0x01 LASTMARK = 0x02 STR = (ord('S')<<8) -I_NREAD = (STR|01) -I_PUSH = (STR|02) -I_POP = (STR|03) -I_LOOK = (STR|04) -I_FLUSH = (STR|05) -I_SRDOPT = (STR|06) -I_GRDOPT = (STR|07) -I_STR = (STR|010) -I_SETSIG = (STR|011) -I_GETSIG = (STR|012) -I_FIND = (STR|013) -I_LINK = (STR|014) -I_UNLINK = (STR|015) -I_PEEK = (STR|017) -I_FDINSERT = (STR|020) -I_SENDFD = (STR|021) -I_RECVFD = (STR|022) -I_E_RECVFD = (STR|016) -I_RECVFD = (STR|016) -I_RECVFD = (STR|022) -I_SWROPT = (STR|023) -I_GWROPT = (STR|024) -I_LIST = (STR|025) -I_PLINK = (STR|026) -I_PUNLINK = (STR|027) -I_FLUSHBAND = (STR|034) -I_CKBAND = (STR|035) -I_GETBAND = (STR|036) -I_ATMARK = (STR|037) -I_SETCLTIME = (STR|040) -I_GETCLTIME = (STR|041) -I_CANPUT = (STR|042) -I_S_RECVFD = (STR|043) -I_STATS = (STR|044) -I_BIGPIPE = (STR|045) -I_GETTP = (STR|046) +I_NREAD = (STR|0o1) +I_PUSH = (STR|0o2) +I_POP = (STR|0o3) +I_LOOK = (STR|0o4) +I_FLUSH = (STR|0o5) +I_SRDOPT = (STR|0o6) +I_GRDOPT = (STR|0o7) +I_STR = (STR|0o10) +I_SETSIG = (STR|0o11) +I_GETSIG = (STR|0o12) +I_FIND = (STR|0o13) +I_LINK = (STR|0o14) +I_UNLINK = (STR|0o15) +I_PEEK = (STR|0o17) +I_FDINSERT = (STR|0o20) +I_SENDFD = (STR|0o21) +I_RECVFD = (STR|0o22) +I_E_RECVFD = (STR|0o16) +I_RECVFD = (STR|0o16) +I_RECVFD = (STR|0o22) +I_SWROPT = (STR|0o23) +I_GWROPT = (STR|0o24) +I_LIST = (STR|0o25) +I_PLINK = (STR|0o26) +I_PUNLINK = (STR|0o27) +I_FLUSHBAND = (STR|0o34) +I_CKBAND = (STR|0o35) +I_GETBAND = (STR|0o36) +I_ATMARK = (STR|0o37) +I_SETCLTIME = (STR|0o40) +I_GETCLTIME = (STR|0o41) +I_CANPUT = (STR|0o42) +I_S_RECVFD = (STR|0o43) +I_STATS = (STR|0o44) +I_BIGPIPE = (STR|0o45) +I_GETTP = (STR|0o46) INFTIM = -1 Modified: python/branches/py3k-struni/Lib/platform.py ============================================================================== --- python/branches/py3k-struni/Lib/platform.py (original) +++ python/branches/py3k-struni/Lib/platform.py Wed Jun 13 20:07:49 2007 @@ -242,7 +242,7 @@ _supported_dists = ('SuSE', 'debian', 'fedora', 'redhat', 'centos', 'mandrake', 'rocks', 'slackware', 'yellowdog', - 'gentoo', 'UnitedLinux') + 'gentoo', 'UnitedLinux', 'turbolinux') def _parse_release_file(firstline): @@ -600,6 +600,16 @@ release = '2003Server' else: release = 'post2003' + elif maj == 6: + if min == 0: + # Per http://msdn2.microsoft.com/en-us/library/ms724429.aspx + productType = GetVersionEx(1)[8] + if productType == 1: # VER_NT_WORKSTATION + release = 'Vista' + else: + release = '2008Server' + else: + release = 'post2008Server' else: if not release: # E.g. Win3.1 with win32s @@ -1064,6 +1074,16 @@ # (_syscmd_ver() tends to return the vendor name as well) if system == 'Microsoft Windows': system = 'Windows' + elif system == 'Microsoft' and release == 'Windows': + # Under Windows Vista and Windows Server 2008, + # Microsoft changed the output of the ver command. The + # release is no longer printed. This causes the + # system and release to be misidentified. + system = 'Windows' + if '6.0' == version[:3]: + release = 'Vista' + else: + release = '' # In case we still don't know anything useful, we'll try to # help ourselves Modified: python/branches/py3k-struni/Lib/pty.py ============================================================================== --- python/branches/py3k-struni/Lib/pty.py (original) +++ python/branches/py3k-struni/Lib/pty.py Wed Jun 13 20:07:49 2007 @@ -55,7 +55,7 @@ pass else: try: - tty_name, master_fd = sgi._getpty(os.O_RDWR, 0666, 0) + tty_name, master_fd = sgi._getpty(os.O_RDWR, 0o666, 0) except IOError as msg: raise os.error, msg return master_fd, tty_name Modified: python/branches/py3k-struni/Lib/random.py ============================================================================== --- python/branches/py3k-struni/Lib/random.py (original) +++ python/branches/py3k-struni/Lib/random.py Wed Jun 13 20:07:49 2007 @@ -110,19 +110,19 @@ import time a = int(time.time() * 256) # use fractional seconds - super(Random, self).seed(a) + super().seed(a) self.gauss_next = None def getstate(self): """Return internal state; can be passed to setstate() later.""" - return self.VERSION, super(Random, self).getstate(), self.gauss_next + return self.VERSION, super().getstate(), self.gauss_next def setstate(self, state): """Restore internal state from object returned by getstate().""" version = state[0] if version == 2: version, internalstate, self.gauss_next = state - super(Random, self).setstate(internalstate) + super().setstate(internalstate) else: raise ValueError("state with version %s passed to " "Random.setstate() of version %s" % Modified: python/branches/py3k-struni/Lib/repr.py ============================================================================== --- python/branches/py3k-struni/Lib/repr.py (original) +++ python/branches/py3k-struni/Lib/repr.py Wed Jun 13 20:07:49 2007 @@ -47,7 +47,7 @@ return '%s%s%s' % (left, s, right) def repr_tuple(self, x, level): - return self._repr_iterable(x, level, '(', ')', self.maxlist, ',') + return self._repr_iterable(x, level, '(', ')', self.maxtuple, ',') def repr_list(self, x, level): return self._repr_iterable(x, level, '[', ']', self.maxlist) Modified: python/branches/py3k-struni/Lib/sqlite3/test/dbapi.py ============================================================================== --- python/branches/py3k-struni/Lib/sqlite3/test/dbapi.py (original) +++ python/branches/py3k-struni/Lib/sqlite3/test/dbapi.py Wed Jun 13 20:07:49 2007 @@ -40,12 +40,12 @@ sqlite.paramstyle) def CheckWarning(self): - self.assert_(issubclass(sqlite.Warning, StandardError), - "Warning is not a subclass of StandardError") + self.assert_(issubclass(sqlite.Warning, Exception), + "Warning is not a subclass of Exception") def CheckError(self): - self.failUnless(issubclass(sqlite.Error, StandardError), - "Error is not a subclass of StandardError") + self.failUnless(issubclass(sqlite.Error, Exception), + "Error is not a subclass of Exception") def CheckInterfaceError(self): self.failUnless(issubclass(sqlite.InterfaceError, sqlite.Error), Modified: python/branches/py3k-struni/Lib/stat.py ============================================================================== --- python/branches/py3k-struni/Lib/stat.py (original) +++ python/branches/py3k-struni/Lib/stat.py Wed Jun 13 20:07:49 2007 @@ -24,21 +24,21 @@ # Extract bits from the mode def S_IMODE(mode): - return mode & 07777 + return mode & 0o7777 def S_IFMT(mode): - return mode & 0170000 + return mode & 0o170000 # Constants used as S_IFMT() for various file types # (not all are implemented on all systems) -S_IFDIR = 0040000 -S_IFCHR = 0020000 -S_IFBLK = 0060000 -S_IFREG = 0100000 -S_IFIFO = 0010000 -S_IFLNK = 0120000 -S_IFSOCK = 0140000 +S_IFDIR = 0o040000 +S_IFCHR = 0o020000 +S_IFBLK = 0o060000 +S_IFREG = 0o100000 +S_IFIFO = 0o010000 +S_IFLNK = 0o120000 +S_IFSOCK = 0o140000 # Functions to test for each file type @@ -65,25 +65,25 @@ # Names for permission bits -S_ISUID = 04000 -S_ISGID = 02000 +S_ISUID = 0o4000 +S_ISGID = 0o2000 S_ENFMT = S_ISGID -S_ISVTX = 01000 -S_IREAD = 00400 -S_IWRITE = 00200 -S_IEXEC = 00100 -S_IRWXU = 00700 -S_IRUSR = 00400 -S_IWUSR = 00200 -S_IXUSR = 00100 -S_IRWXG = 00070 -S_IRGRP = 00040 -S_IWGRP = 00020 -S_IXGRP = 00010 -S_IRWXO = 00007 -S_IROTH = 00004 -S_IWOTH = 00002 -S_IXOTH = 00001 +S_ISVTX = 0o1000 +S_IREAD = 0o0400 +S_IWRITE = 0o0200 +S_IEXEC = 0o0100 +S_IRWXU = 0o0700 +S_IRUSR = 0o0400 +S_IWUSR = 0o0200 +S_IXUSR = 0o0100 +S_IRWXG = 0o0070 +S_IRGRP = 0o0040 +S_IWGRP = 0o0020 +S_IXGRP = 0o0010 +S_IRWXO = 0o0007 +S_IROTH = 0o0004 +S_IWOTH = 0o0002 +S_IXOTH = 0o0001 # Names for file flags Modified: python/branches/py3k-struni/Lib/tarfile.py ============================================================================== --- python/branches/py3k-struni/Lib/tarfile.py (original) +++ python/branches/py3k-struni/Lib/tarfile.py Wed Jun 13 20:07:49 2007 @@ -141,26 +141,26 @@ #--------------------------------------------------------- # Bits used in the mode field, values in octal. #--------------------------------------------------------- -S_IFLNK = 0120000 # symbolic link -S_IFREG = 0100000 # regular file -S_IFBLK = 0060000 # block device -S_IFDIR = 0040000 # directory -S_IFCHR = 0020000 # character device -S_IFIFO = 0010000 # fifo - -TSUID = 04000 # set UID on execution -TSGID = 02000 # set GID on execution -TSVTX = 01000 # reserved - -TUREAD = 0400 # read by owner -TUWRITE = 0200 # write by owner -TUEXEC = 0100 # execute/search by owner -TGREAD = 0040 # read by group -TGWRITE = 0020 # write by group -TGEXEC = 0010 # execute/search by group -TOREAD = 0004 # read by other -TOWRITE = 0002 # write by other -TOEXEC = 0001 # execute/search by other +S_IFLNK = 0o120000 # symbolic link +S_IFREG = 0o100000 # regular file +S_IFBLK = 0o060000 # block device +S_IFDIR = 0o040000 # directory +S_IFCHR = 0o020000 # character device +S_IFIFO = 0o010000 # fifo + +TSUID = 0o4000 # set UID on execution +TSGID = 0o2000 # set GID on execution +TSVTX = 0o1000 # reserved + +TUREAD = 0o400 # read by owner +TUWRITE = 0o200 # write by owner +TUEXEC = 0o100 # execute/search by owner +TGREAD = 0o040 # read by group +TGWRITE = 0o020 # write by group +TGEXEC = 0o010 # execute/search by group +TOREAD = 0o004 # read by other +TOWRITE = 0o002 # write by other +TOEXEC = 0o001 # execute/search by other #--------------------------------------------------------- # initialization @@ -192,7 +192,7 @@ """ # There are two possible encodings for a number field, see # itn() below. - if s[0] != chr(0200): + if s[0] != chr(0o200): try: n = int(nts(s) or "0", 8) except ValueError: @@ -210,7 +210,7 @@ # POSIX 1003.1-1988 requires numbers to be encoded as a string of # octal digits followed by a null-byte, this allows values up to # (8**(digits-1))-1. GNU tar allows storing numbers greater than - # that if necessary. A leading 0200 byte indicates this particular + # that if necessary. A leading 0o200 byte indicates this particular # encoding, the following digits-1 bytes are a big-endian # representation. This allows values up to (256**(digits-1))-1. if 0 <= n < 8 ** (digits - 1): @@ -226,9 +226,9 @@ s = "" for i in range(digits - 1): - s = chr(n & 0377) + s + s = chr(n & 0o377) + s n >>= 8 - s = chr(0200) + s + s = chr(0o200) + s return s def uts(s, encoding, errors): @@ -920,7 +920,7 @@ of the member. """ self.name = name # member name - self.mode = 0644 # file permissions + self.mode = 0o644 # file permissions self.uid = 0 # user id self.gid = 0 # group id self.size = 0 # file size @@ -960,7 +960,7 @@ """ info = { "name": normpath(self.name), - "mode": self.mode & 07777, + "mode": self.mode & 0o7777, "uid": self.uid, "gid": self.gid, "size": self.size, @@ -1103,7 +1103,7 @@ """ parts = [ stn(info.get("name", ""), 100), - itn(info.get("mode", 0) & 07777, 8, format), + itn(info.get("mode", 0) & 0o7777, 8, format), itn(info.get("uid", 0), 8, format), itn(info.get("gid", 0), 8, format), itn(info.get("size", 0), 12, format), @@ -2019,7 +2019,7 @@ # Extract directory with a safe mode, so that # all files below can be extracted as well. try: - os.makedirs(os.path.join(path, tarinfo.name), 0700) + os.makedirs(os.path.join(path, tarinfo.name), 0o700) except EnvironmentError: pass directories.append(tarinfo) Modified: python/branches/py3k-struni/Lib/tempfile.py ============================================================================== --- python/branches/py3k-struni/Lib/tempfile.py (original) +++ python/branches/py3k-struni/Lib/tempfile.py Wed Jun 13 20:07:49 2007 @@ -197,7 +197,7 @@ name = next(namer) filename = _os.path.join(dir, name) try: - fd = _os.open(filename, flags, 0600) + fd = _os.open(filename, flags, 0o600) fp = _os.fdopen(fd, 'w') fp.write('blat') fp.close() @@ -236,7 +236,7 @@ name = next(names) file = _os.path.join(dir, pre + name + suf) try: - fd = _os.open(file, flags, 0600) + fd = _os.open(file, flags, 0o600) _set_cloexec(fd) return (fd, _os.path.abspath(file)) except OSError as e: @@ -328,7 +328,7 @@ name = next(names) file = _os.path.join(dir, prefix + name + suffix) try: - _os.mkdir(file, 0700) + _os.mkdir(file, 0o700) return file except OSError as e: if e.errno == _errno.EEXIST: Modified: python/branches/py3k-struni/Lib/test/exception_hierarchy.txt ============================================================================== --- python/branches/py3k-struni/Lib/test/exception_hierarchy.txt (original) +++ python/branches/py3k-struni/Lib/test/exception_hierarchy.txt Wed Jun 13 20:07:49 2007 @@ -4,39 +4,38 @@ +-- Exception +-- GeneratorExit +-- StopIteration - +-- StandardError - | +-- ArithmeticError - | | +-- FloatingPointError - | | +-- OverflowError - | | +-- ZeroDivisionError - | +-- AssertionError - | +-- AttributeError - | +-- EnvironmentError - | | +-- IOError - | | +-- OSError - | | +-- WindowsError (Windows) - | | +-- VMSError (VMS) - | +-- EOFError - | +-- ImportError - | +-- LookupError - | | +-- IndexError - | | +-- KeyError - | +-- MemoryError - | +-- NameError - | | +-- UnboundLocalError - | +-- ReferenceError - | +-- RuntimeError - | | +-- NotImplementedError - | +-- SyntaxError - | | +-- IndentationError - | | +-- TabError - | +-- SystemError - | +-- TypeError - | +-- ValueError - | | +-- UnicodeError - | | +-- UnicodeDecodeError - | | +-- UnicodeEncodeError - | | +-- UnicodeTranslateError + +-- ArithmeticError + | +-- FloatingPointError + | +-- OverflowError + | +-- ZeroDivisionError + +-- AssertionError + +-- AttributeError + +-- EnvironmentError + | +-- IOError + | +-- OSError + | +-- WindowsError (Windows) + | +-- VMSError (VMS) + +-- EOFError + +-- ImportError + +-- LookupError + | +-- IndexError + | +-- KeyError + +-- MemoryError + +-- NameError + | +-- UnboundLocalError + +-- ReferenceError + +-- RuntimeError + | +-- NotImplementedError + +-- SyntaxError + | +-- IndentationError + | +-- TabError + +-- SystemError + +-- TypeError + +-- ValueError + | +-- UnicodeError + | +-- UnicodeDecodeError + | +-- UnicodeEncodeError + | +-- UnicodeTranslateError +-- Warning +-- DeprecationWarning +-- PendingDeprecationWarning Modified: python/branches/py3k-struni/Lib/test/list_tests.py ============================================================================== --- python/branches/py3k-struni/Lib/test/list_tests.py (original) +++ python/branches/py3k-struni/Lib/test/list_tests.py Wed Jun 13 20:07:49 2007 @@ -451,7 +451,7 @@ self.assertEqual(u, list("ham")) def test_iadd(self): - super(CommonTest, self).test_iadd() + super().test_iadd() u = self.type2test([0, 1]) u2 = u u += [2, 3] Modified: python/branches/py3k-struni/Lib/test/output/test_class ============================================================================== --- python/branches/py3k-struni/Lib/test/output/test_class (original) +++ python/branches/py3k-struni/Lib/test/output/test_class Wed Jun 13 20:07:49 2007 @@ -46,8 +46,7 @@ __int__: () __int__: () __float__: () -__oct__: () -__hex__: () +__index__: () __hash__: () __repr__: () __str__: () Modified: python/branches/py3k-struni/Lib/test/output/test_tokenize ============================================================================== --- python/branches/py3k-struni/Lib/test/output/test_tokenize (original) +++ python/branches/py3k-struni/Lib/test/output/test_tokenize Wed Jun 13 20:07:49 2007 @@ -124,66 +124,80 @@ 39,5-39,7: OP '!=' 39,8-39,11: NUMBER '255' 39,11-39,12: NEWLINE '\n' -40,0-40,4: NUMBER '0377' -40,5-40,7: OP '!=' -40,8-40,11: NUMBER '255' -40,11-40,12: NEWLINE '\n' +40,0-40,5: NUMBER '0o377' +40,6-40,8: OP '!=' +40,9-40,12: NUMBER '255' +40,12-40,13: NEWLINE '\n' 41,0-41,10: NUMBER '2147483647' 41,13-41,15: OP '!=' -41,16-41,28: NUMBER '017777777777' -41,28-41,29: NEWLINE '\n' +41,16-41,29: NUMBER '0o17777777777' +41,29-41,30: NEWLINE '\n' 42,0-42,1: OP '-' 42,1-42,11: NUMBER '2147483647' 42,11-42,12: OP '-' 42,12-42,13: NUMBER '1' 42,14-42,16: OP '!=' -42,17-42,29: NUMBER '020000000000' -42,29-42,30: NEWLINE '\n' -43,0-43,12: NUMBER '037777777777' -43,13-43,15: OP '!=' -43,16-43,17: OP '-' -43,17-43,18: NUMBER '1' -43,18-43,19: NEWLINE '\n' +42,17-42,30: NUMBER '0o20000000000' +42,30-42,31: NEWLINE '\n' +43,0-43,13: NUMBER '0o37777777777' +43,14-43,16: OP '!=' +43,17-43,18: OP '-' +43,18-43,19: NUMBER '1' +43,19-43,20: NEWLINE '\n' 44,0-44,10: NUMBER '0xffffffff' 44,11-44,13: OP '!=' 44,14-44,15: OP '-' 44,15-44,16: NUMBER '1' -44,16-44,17: NEWLINE '\n' +44,16-44,17: OP ';' +44,18-44,31: NUMBER '0o37777777777' +44,32-44,34: OP '!=' +44,35-44,36: OP '-' +44,36-44,37: NUMBER '1' +44,37-44,38: OP ';' +44,39-44,40: OP '-' +44,40-44,49: NUMBER '0o1234567' +44,50-44,52: OP '==' +44,53-44,64: NUMBER '0O001234567' +44,64-44,65: OP ';' +44,66-44,73: NUMBER '0b10101' +44,74-44,76: OP '==' +44,77-44,87: NUMBER '0B00010101' +44,87-44,88: NEWLINE '\n' 45,0-45,1: NL '\n' 46,0-46,15: COMMENT '# Long integers' 46,15-46,16: NL '\n' 47,0-47,1: NAME 'x' 47,2-47,3: OP '=' -47,4-47,6: NUMBER '0L' -47,6-47,7: NEWLINE '\n' +47,4-47,5: NUMBER '0' +47,5-47,6: NEWLINE '\n' 48,0-48,1: NAME 'x' 48,2-48,3: OP '=' -48,4-48,6: NUMBER '0l' -48,6-48,7: NEWLINE '\n' +48,4-48,5: NUMBER '0' +48,5-48,6: NEWLINE '\n' 49,0-49,1: NAME 'x' 49,2-49,3: OP '=' -49,4-49,23: NUMBER '0xffffffffffffffffL' -49,23-49,24: NEWLINE '\n' +49,4-49,22: NUMBER '0xffffffffffffffff' +49,22-49,23: NEWLINE '\n' 50,0-50,1: NAME 'x' 50,2-50,3: OP '=' -50,4-50,23: NUMBER '0xffffffffffffffffl' -50,23-50,24: NEWLINE '\n' +50,4-50,22: NUMBER '0xffffffffffffffff' +50,22-50,23: NEWLINE '\n' 51,0-51,1: NAME 'x' 51,2-51,3: OP '=' -51,4-51,23: NUMBER '077777777777777777L' +51,4-51,23: NUMBER '0o77777777777777777' 51,23-51,24: NEWLINE '\n' 52,0-52,1: NAME 'x' 52,2-52,3: OP '=' -52,4-52,23: NUMBER '077777777777777777l' +52,4-52,23: NUMBER '0B11101010111111111' 52,23-52,24: NEWLINE '\n' 53,0-53,1: NAME 'x' 53,2-53,3: OP '=' -53,4-53,35: NUMBER '123456789012345678901234567890L' -53,35-53,36: NEWLINE '\n' +53,4-53,34: NUMBER '123456789012345678901234567890' +53,34-53,35: NEWLINE '\n' 54,0-54,1: NAME 'x' 54,2-54,3: OP '=' -54,4-54,35: NUMBER '123456789012345678901234567890l' -54,35-54,36: NEWLINE '\n' +54,4-54,34: NUMBER '123456789012345678901234567890' +54,34-54,35: NEWLINE '\n' 55,0-55,1: NL '\n' 56,0-56,24: COMMENT '# Floating-point numbers' 56,24-56,25: NL '\n' Modified: python/branches/py3k-struni/Lib/test/regrtest.py ============================================================================== --- python/branches/py3k-struni/Lib/test/regrtest.py (original) +++ python/branches/py3k-struni/Lib/test/regrtest.py Wed Jun 13 20:07:49 2007 @@ -697,7 +697,7 @@ import gc, copy_reg import _strptime, linecache, dircache import urlparse, urllib, urllib2, mimetypes, doctest - import struct, filecmp + import struct, filecmp, collections from distutils.dir_util import _path_created # Restore some original values. @@ -707,6 +707,10 @@ sys.path_importer_cache.clear() sys.path_importer_cache.update(pic) + # Clear ABC registries. + for obj in [collections.Hashable, collections.Iterable]: + obj._ABCMeta__registry.clear() + # Clear assorted module caches. _path_created.clear() re.purge() Modified: python/branches/py3k-struni/Lib/test/string_tests.py ============================================================================== --- python/branches/py3k-struni/Lib/test/string_tests.py (original) +++ python/branches/py3k-struni/Lib/test/string_tests.py Wed Jun 13 20:07:49 2007 @@ -211,6 +211,32 @@ self.checkraises(TypeError, 'hello', 'rindex') self.checkraises(TypeError, 'hello', 'rindex', 42) + def test_lower(self): + self.checkequal('hello', 'HeLLo', 'lower') + self.checkequal('hello', 'hello', 'lower') + self.checkraises(TypeError, 'hello', 'lower', 42) + + def test_upper(self): + self.checkequal('HELLO', 'HeLLo', 'upper') + self.checkequal('HELLO', 'HELLO', 'upper') + self.checkraises(TypeError, 'hello', 'upper', 42) + + def test_expandtabs(self): + self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs') + self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs', 8) + self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs', 4) + self.checkequal('abc\r\nab def\ng hi', 'abc\r\nab\tdef\ng\thi', 'expandtabs', 4) + self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs') + self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs', 8) + self.checkequal('abc\r\nab\r\ndef\ng\r\nhi', 'abc\r\nab\r\ndef\ng\r\nhi', 'expandtabs', 4) + self.checkequal(' a\n b', ' \ta\n\tb', 'expandtabs', 1) + + 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: + self.checkraises(OverflowError, + '\ta\n\tb', 'expandtabs', sys.maxint) + def test_split(self): # by a char self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|') Modified: python/branches/py3k-struni/Lib/test/test_array.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_array.py (original) +++ python/branches/py3k-struni/Lib/test/test_array.py Wed Jun 13 20:07:49 2007 @@ -704,7 +704,7 @@ class StringTest(BaseTest): def test_setitem(self): - super(StringTest, self).test_setitem() + super().test_setitem() a = array.array(self.typecode, self.example) self.assertRaises(TypeError, a.__setitem__, 0, self.example[:2]) Modified: python/branches/py3k-struni/Lib/test/test_builtin.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_builtin.py (original) +++ python/branches/py3k-struni/Lib/test/test_builtin.py Wed Jun 13 20:07:49 2007 @@ -728,8 +728,27 @@ self.assertRaises(TypeError, int, 1, 12) - self.assertEqual(int('0123', 0), 83) + # tests with base 0 + self.assertRaises(ValueError, int, ' 0123 ', 0) # old octal syntax + self.assertEqual(int('000', 0), 0) + self.assertEqual(int('0o123', 0), 83) + self.assertEqual(int('0x123', 0), 291) + self.assertEqual(int('0b100', 0), 4) + self.assertEqual(int(' 0O123 ', 0), 83) + self.assertEqual(int(' 0X123 ', 0), 291) + self.assertEqual(int(' 0B100 ', 0), 4) + + # without base still base 10 + self.assertEqual(int('0123'), 123) + self.assertEqual(int('0123', 10), 123) + + # tests with prefix and base != 0 self.assertEqual(int('0x123', 16), 291) + self.assertEqual(int('0o123', 8), 83) + self.assertEqual(int('0b100', 2), 4) + self.assertEqual(int('0X123', 16), 291) + self.assertEqual(int('0O123', 8), 83) + self.assertEqual(int('0B100', 2), 4) # SF bug 1334662: int(string, base) wrong answers # Various representations of 2**32 evaluated to 0 @@ -1269,10 +1288,10 @@ self.assertEquals(next(it, 42), 42) def test_oct(self): - self.assertEqual(oct(100), '0144') - self.assertEqual(oct(100), '0144') - self.assertEqual(oct(-100), '-0144') - self.assertEqual(oct(-100), '-0144') + self.assertEqual(oct(100), '0o144') + self.assertEqual(oct(100), '0o144') + self.assertEqual(oct(-100), '-0o144') + self.assertEqual(oct(-100), '-0o144') self.assertRaises(TypeError, oct, ()) def write_testfile(self): Modified: python/branches/py3k-struni/Lib/test/test_bytes.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_bytes.py (original) +++ python/branches/py3k-struni/Lib/test/test_bytes.py Wed Jun 13 20:07:49 2007 @@ -716,6 +716,12 @@ pass def test_find(self): pass + def test_expandtabs(self): + pass + def test_upper(self): + pass + def test_lower(self): + pass def test_main(): Modified: python/branches/py3k-struni/Lib/test/test_cgi.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_cgi.py (original) +++ python/branches/py3k-struni/Lib/test/test_cgi.py Wed Jun 13 20:07:49 2007 @@ -50,7 +50,7 @@ raise ValueError, "unknown method: %s" % method try: return cgi.parse(fp, env, strict_parsing=1) - except StandardError as err: + except Exception as err: return ComparableException(err) # A list of test cases. Each test case is a a two-tuple that contains Modified: python/branches/py3k-struni/Lib/test/test_class.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_class.py (original) +++ python/branches/py3k-struni/Lib/test/test_class.py Wed Jun 13 20:07:49 2007 @@ -80,18 +80,14 @@ print("__int__:", args) return 1 + def __index__(self, *args): + print("__index__:", args) + return 1 + def __float__(self, *args): print("__float__:", args) return 1.0 - def __oct__(self, *args): - print("__oct__:", args) - return '01' - - def __hex__(self, *args): - print("__hex__:", args) - return '0x1' - def __cmp__(self, *args): print("__cmp__:", args) return 0 @@ -237,7 +233,6 @@ int(testme) float(testme) oct(testme) -hex(testme) # And the rest... @@ -287,8 +282,6 @@ __float__ = __int__ __str__ = __int__ __repr__ = __int__ - __oct__ = __int__ - __hex__ = __int__ def check_exc(stmt, exception): """Raise TestFailed if executing 'stmt' does not raise 'exception' Modified: python/branches/py3k-struni/Lib/test/test_collections.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_collections.py (original) +++ python/branches/py3k-struni/Lib/test/test_collections.py Wed Jun 13 20:07:49 2007 @@ -1,6 +1,14 @@ +"""Unit tests for collections.py.""" + import unittest from test import test_support from collections import NamedTuple +from collections import Hashable, Iterable, Iterator +from collections import Sized, Container, Callable +from collections import Set, MutableSet +from collections import Mapping, MutableMapping +from collections import Sequence, MutableSequence + class TestNamedTuple(unittest.TestCase): @@ -51,11 +59,187 @@ self.assertRaises(AttributeError, eval, 'p.z', locals()) +class TestOneTrickPonyABCs(unittest.TestCase): + + def test_Hashable(self): + # Check some non-hashables + non_samples = [bytes(), list(), set(), dict()] + for x in non_samples: + self.failIf(isinstance(x, Hashable), repr(x)) + self.failIf(issubclass(type(x), Hashable), repr(type(x))) + # Check some hashables + samples = [None, + int(), float(), complex(), + str(), unicode(), + tuple(), frozenset(), + int, list, object, type, + ] + for x in samples: + self.failUnless(isinstance(x, Hashable), repr(x)) + self.failUnless(issubclass(type(x), Hashable), repr(type(x))) + self.assertRaises(TypeError, Hashable) + # Check direct subclassing + class H(Hashable): + def __hash__(self): + return super().__hash__() + self.assertEqual(hash(H()), 0) + self.failIf(issubclass(int, H)) + + def test_Iterable(self): + # Check some non-iterables + non_samples = [None, 42, 3.14, 1j] + for x in non_samples: + self.failIf(isinstance(x, Iterable), repr(x)) + self.failIf(issubclass(type(x), Iterable), repr(type(x))) + # Check some iterables + samples = [bytes(), str(), unicode(), + tuple(), list(), set(), frozenset(), dict(), + dict().keys(), dict().items(), dict().values(), + (lambda: (yield))(), + (x for x in []), + ] + for x in samples: + self.failUnless(isinstance(x, Iterable), repr(x)) + self.failUnless(issubclass(type(x), Iterable), repr(type(x))) + # Check direct subclassing + class I(Iterable): + def __iter__(self): + return super().__iter__() + self.assertEqual(list(I()), []) + self.failIf(issubclass(str, I)) + + def test_Iterator(self): + non_samples = [None, 42, 3.14, 1j, b"", "", u"", (), [], {}, set()] + for x in non_samples: + self.failIf(isinstance(x, Iterator), repr(x)) + self.failIf(issubclass(type(x), Iterator), repr(type(x))) + samples = [iter(bytes()), iter(str()), iter(unicode()), + iter(tuple()), iter(list()), iter(dict()), + iter(set()), iter(frozenset()), + iter(dict().keys()), iter(dict().items()), + iter(dict().values()), + (lambda: (yield))(), + (x for x in []), + ] + for x in samples: + self.failUnless(isinstance(x, Iterator), repr(x)) + self.failUnless(issubclass(type(x), Iterator), repr(type(x))) + + def test_Sized(self): + non_samples = [None, 42, 3.14, 1j, + (lambda: (yield))(), + (x for x in []), + ] + for x in non_samples: + self.failIf(isinstance(x, Sized), repr(x)) + self.failIf(issubclass(type(x), Sized), repr(type(x))) + samples = [bytes(), str(), unicode(), + tuple(), list(), set(), frozenset(), dict(), + dict().keys(), dict().items(), dict().values(), + ] + for x in samples: + self.failUnless(isinstance(x, Sized), repr(x)) + self.failUnless(issubclass(type(x), Sized), repr(type(x))) + + def test_Container(self): + non_samples = [None, 42, 3.14, 1j, + (lambda: (yield))(), + (x for x in []), + ] + for x in non_samples: + self.failIf(isinstance(x, Container), repr(x)) + self.failIf(issubclass(type(x), Container), repr(type(x))) + samples = [bytes(), str(), unicode(), + tuple(), list(), set(), frozenset(), dict(), + dict().keys(), dict().items(), + ] + for x in samples: + self.failUnless(isinstance(x, Container), repr(x)) + self.failUnless(issubclass(type(x), Container), repr(type(x))) + + def test_Callable(self): + non_samples = [None, 42, 3.14, 1j, + "", b"", (), [], {}, set(), + (lambda: (yield))(), + (x for x in []), + ] + for x in non_samples: + self.failIf(isinstance(x, Callable), repr(x)) + self.failIf(issubclass(type(x), Callable), repr(type(x))) + samples = [lambda: None, + type, int, object, + len, + list.append, [].append, + ] + for x in samples: + self.failUnless(isinstance(x, Callable), repr(x)) + self.failUnless(issubclass(type(x), Callable), repr(type(x))) + + def test_direct_subclassing(self): + for B in Hashable, Iterable, Iterator, Sized, Container, Callable: + class C(B): + pass + self.failUnless(issubclass(C, B)) + self.failIf(issubclass(int, C)) + + def test_registration(self): + for B in Hashable, Iterable, Iterator, Sized, Container, Callable: + class C: + __hash__ = None # Make sure it isn't hashable by default + self.failIf(issubclass(C, B), B.__name__) + B.register(C) + self.failUnless(issubclass(C, B)) + + +class TestCollectionABCs(unittest.TestCase): + + # XXX For now, we only test some virtual inheritance properties. + # We should also test the proper behavior of the collection ABCs + # as real base classes or mix-in classes. + + def test_Set(self): + for sample in [set, frozenset]: + self.failUnless(isinstance(sample(), Set)) + self.failUnless(issubclass(sample, Set)) + + def test_MutableSet(self): + self.failUnless(isinstance(set(), MutableSet)) + self.failUnless(issubclass(set, MutableSet)) + self.failIf(isinstance(frozenset(), MutableSet)) + self.failIf(issubclass(frozenset, MutableSet)) + + def test_Mapping(self): + for sample in [dict]: + self.failUnless(isinstance(sample(), Mapping)) + self.failUnless(issubclass(sample, Mapping)) + + def test_MutableMapping(self): + for sample in [dict]: + self.failUnless(isinstance(sample(), MutableMapping)) + self.failUnless(issubclass(sample, MutableMapping)) + + def test_Sequence(self): + for sample in [tuple, list, bytes, str]: + self.failUnless(isinstance(sample(), Sequence)) + self.failUnless(issubclass(sample, Sequence)) + self.failUnless(issubclass(basestring, Sequence)) + + def test_MutableSequence(self): + for sample in [tuple, str]: + self.failIf(isinstance(sample(), MutableSequence)) + self.failIf(issubclass(sample, MutableSequence)) + for sample in [list, bytes]: + self.failUnless(isinstance(sample(), MutableSequence)) + self.failUnless(issubclass(sample, MutableSequence)) + self.failIf(issubclass(basestring, MutableSequence)) + + def test_main(verbose=None): import collections as CollectionsModule - test_classes = [TestNamedTuple] + test_classes = [TestNamedTuple, TestOneTrickPonyABCs, TestCollectionABCs] test_support.run_unittest(*test_classes) test_support.run_doctest(CollectionsModule, verbose) + if __name__ == "__main__": test_main(verbose=True) Modified: python/branches/py3k-struni/Lib/test/test_compile.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_compile.py (original) +++ python/branches/py3k-struni/Lib/test/test_compile.py Wed Jun 13 20:07:49 2007 @@ -36,6 +36,9 @@ def test_syntax_error(self): self.assertRaises(SyntaxError, compile, "1+*3", "filename", "exec") + def test_none_keyword_arg(self): + self.assertRaises(SyntaxError, compile, "f(None=1)", "", "exec") + def test_duplicate_global_local(self): try: exec('def f(a): global a; a = 1') @@ -158,21 +161,22 @@ def test_literals_with_leading_zeroes(self): for arg in ["077787", "0xj", "0x.", "0e", "090000000000000", - "080000000000000", "000000000000009", "000000000000008"]: + "080000000000000", "000000000000009", "000000000000008", + "0b42", "0BADCAFE", "0o123456789", "0b1.1", "0o4.2", + "0b101j2", "0o153j2", "0b100e1", "0o777e1", "0777", + "000777", "000000000000007"]: self.assertRaises(SyntaxError, eval, arg) - self.assertEqual(eval("0777"), 511) - self.assertEqual(eval("000777"), 511) self.assertEqual(eval("0xff"), 255) - self.assertEqual(eval("0XfF"), 255) self.assertEqual(eval("0777."), 777) self.assertEqual(eval("0777.0"), 777) self.assertEqual(eval("000000000000000000000000000000000000000000000000000777e0"), 777) self.assertEqual(eval("0777e1"), 7770) self.assertEqual(eval("0e0"), 0) - self.assertEqual(eval("0000E-012"), 0) + self.assertEqual(eval("0000e-012"), 0) self.assertEqual(eval("09.5"), 9.5) self.assertEqual(eval("0777j"), 777j) + self.assertEqual(eval("000"), 0) self.assertEqual(eval("00j"), 0j) self.assertEqual(eval("00.0"), 0) self.assertEqual(eval("0e3"), 0) @@ -181,9 +185,12 @@ self.assertEqual(eval("090000000000000e0"), 90000000000000.) self.assertEqual(eval("090000000000000e-0"), 90000000000000.) self.assertEqual(eval("090000000000000j"), 90000000000000j) - self.assertEqual(eval("000000000000007"), 7) self.assertEqual(eval("000000000000008."), 8.) self.assertEqual(eval("000000000000009."), 9.) + self.assertEqual(eval("0b101010"), 42) + self.assertEqual(eval("-0b000000000010"), -2) + self.assertEqual(eval("0o777"), 511) + self.assertEqual(eval("-0o0000010"), -8) def test_unary_minus(self): # Verify treatment of unary minus on negative numbers SF bug #660455 Modified: python/branches/py3k-struni/Lib/test/test_descr.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_descr.py (original) +++ python/branches/py3k-struni/Lib/test/test_descr.py Wed Jun 13 20:07:49 2007 @@ -2126,17 +2126,14 @@ class octlong(int): __slots__ = [] def __str__(self): - s = oct(self) - if s[-1] == 'L': - s = s[:-1] - return s + return oct(self) def __add__(self, other): return self.__class__(super(octlong, self).__add__(other)) __radd__ = __add__ - vereq(str(octlong(3) + 5), "010") + vereq(str(octlong(3) + 5), "0o10") # (Note that overriding __radd__ here only seems to work # because the example uses a short int left argument.) - vereq(str(5 + octlong(3000)), "05675") + vereq(str(5 + octlong(3000)), "0o5675") a = octlong(12345) vereq(a, 12345) vereq(int(a), 12345) Modified: python/branches/py3k-struni/Lib/test/test_dumbdbm.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_dumbdbm.py (original) +++ python/branches/py3k-struni/Lib/test/test_dumbdbm.py Wed Jun 13 20:07:49 2007 @@ -45,17 +45,17 @@ return try: - old_umask = os.umask(0002) - f = dumbdbm.open(_fname, 'c', 0637) + old_umask = os.umask(0o002) + f = dumbdbm.open(_fname, 'c', 0o637) f.close() finally: os.umask(old_umask) - expected_mode = 0635 + expected_mode = 0o635 if os.name != 'posix': # Windows only supports setting the read-only attribute. # This shouldn't fail, but doesn't work like Unix either. - expected_mode = 0666 + expected_mode = 0o666 import stat st = os.stat(_fname + '.dat') Modified: python/branches/py3k-struni/Lib/test/test_format.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_format.py (original) +++ python/branches/py3k-struni/Lib/test/test_format.py Wed Jun 13 20:07:49 2007 @@ -121,7 +121,7 @@ # same, except no 0 flag testboth("%#+27.23X", big, " +0X001234567890ABCDEF12345") -big = 012345670123456701234567012345670 # 32 octal digits +big = 0o12345670123456701234567012345670 # 32 octal digits testboth("%o", big, "12345670123456701234567012345670") testboth("%o", -big, "-12345670123456701234567012345670") testboth("%5o", -big, "-12345670123456701234567012345670") @@ -141,33 +141,36 @@ testboth("%34.33o", big, " 012345670123456701234567012345670") testboth("%-34.33o", big, "012345670123456701234567012345670 ") testboth("%o", big, "12345670123456701234567012345670") -testboth("%#o", big, "012345670123456701234567012345670") -testboth("%#o", -big, "-012345670123456701234567012345670") -testboth("%#.34o", -big, "-0012345670123456701234567012345670") -testboth("%#+.34o", big, "+0012345670123456701234567012345670") -testboth("%# .34o", big, " 0012345670123456701234567012345670") -testboth("%#+.34o", big, "+0012345670123456701234567012345670") -testboth("%#-+.34o", big, "+0012345670123456701234567012345670") -testboth("%#-+37.34o", big, "+0012345670123456701234567012345670 ") -testboth("%#+37.34o", big, " +0012345670123456701234567012345670") +testboth("%#o", big, "0o12345670123456701234567012345670") +testboth("%#o", -big, "-0o12345670123456701234567012345670") +testboth("%#.34o", -big, "-0o0012345670123456701234567012345670") +testboth("%#+.34o", big, "+0o0012345670123456701234567012345670") +testboth("%# .34o", big, " 0o0012345670123456701234567012345670") +testboth("%#-+.34o", big, "+0o0012345670123456701234567012345670") +testboth("%#-+39.34o", big, "+0o0012345670123456701234567012345670 ") +testboth("%#+39.34o", big, " +0o0012345670123456701234567012345670") # next one gets one leading zero from precision testboth("%.33o", big, "012345670123456701234567012345670") -# base marker shouldn't change that, since "0" is redundant -testboth("%#.33o", big, "012345670123456701234567012345670") -# but reduce precision, and base marker should add a zero -testboth("%#.32o", big, "012345670123456701234567012345670") -# one leading zero from precision, and another from "0" flag & width +# one leading zero from precision +testboth("%#.33o", big, "0o012345670123456701234567012345670") +# leading zero vanishes +testboth("%#.32o", big, "0o12345670123456701234567012345670") +# one leading zero from precision, and another from '0' flag & width testboth("%034.33o", big, "0012345670123456701234567012345670") -# base marker shouldn't change that -testboth("%0#34.33o", big, "0012345670123456701234567012345670") +# max width includes base marker; padding zeroes come after marker +testboth("%0#38.33o", big, "0o000012345670123456701234567012345670") +# padding spaces come before marker +testboth("%#36.33o", big, " 0o012345670123456701234567012345670") # Some small ints, in both Python int and long flavors). testboth("%d", 42, "42") testboth("%d", -42, "-42") testboth("%#x", 1, "0x1") testboth("%#X", 1, "0X1") -testboth("%#o", 1, "01") -testboth("%#o", 0, "0") +testboth("%#o", 1, "0o1") +testboth("%#o", 1, "0o1") +testboth("%#o", 0, "0o0") +testboth("%#o", 0, "0o0") testboth("%o", 0, "0") testboth("%d", 0, "0") testboth("%#x", 0, "0x0") @@ -176,8 +179,10 @@ testboth("%x", 0x42, "42") testboth("%x", -0x42, "-42") -testboth("%o", 042, "42") -testboth("%o", -042, "-42") +testboth("%o", 0o42, "42") +testboth("%o", -0o42, "-42") +testboth("%o", 0o42, "42") +testboth("%o", -0o42, "-42") # Test exception for unknown format characters if verbose: @@ -216,14 +221,6 @@ test_exc('no format', '1', TypeError, "not all arguments converted during string formatting") -class Foobar(int): - def __oct__(self): - # Returning a non-string should not blow up. - return self + 1 - -test_exc('%o', Foobar(), TypeError, - "expected string, int found") - if maxsize == 2**31-1: # crashes 2.2.1 and earlier: try: Modified: python/branches/py3k-struni/Lib/test/test_grammar.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_grammar.py (original) +++ python/branches/py3k-struni/Lib/test/test_grammar.py Wed Jun 13 20:07:49 2007 @@ -27,26 +27,32 @@ self.assertEquals(x, 0, 'backslash ending comment') def testPlainIntegers(self): + self.assertEquals(type(000), type(0)) self.assertEquals(0xff, 255) - self.assertEquals(0377, 255) - self.assertEquals(2147483647, 017777777777) + self.assertEquals(0o377, 255) + self.assertEquals(2147483647, 0o17777777777) + self.assertEquals(0b1001, 9) from sys import maxint if maxint == 2147483647: - self.assertEquals(-2147483647-1, -020000000000) + self.assertEquals(-2147483647-1, -0o20000000000) # XXX -2147483648 - self.assert_(037777777777 > 0) + self.assert_(0o37777777777 > 0) self.assert_(0xffffffff > 0) - for s in '2147483648', '040000000000', '0x100000000': + self.assert_(0b1111111111111111111111111111111 > 0) + for s in ('2147483648', '0o40000000000', '0x100000000', + '0b10000000000000000000000000000000'): try: x = eval(s) except OverflowError: self.fail("OverflowError on huge integer literal %r" % s) elif maxint == 9223372036854775807: - self.assertEquals(-9223372036854775807-1, -01000000000000000000000) - self.assert_(01777777777777777777777 > 0) + self.assertEquals(-9223372036854775807-1, -0o1000000000000000000000) + self.assert_(0o1777777777777777777777 > 0) self.assert_(0xffffffffffffffff > 0) - for s in '9223372036854775808', '02000000000000000000000', \ - '0x10000000000000000': + self.assert_(0b11111111111111111111111111111111111111111111111111111111111111 > 0) + for s in '9223372036854775808', '0o2000000000000000000000', \ + '0x10000000000000000', \ + '0b100000000000000000000000000000000000000000000000000000000000000': try: x = eval(s) except OverflowError: @@ -56,13 +62,13 @@ def testLongIntegers(self): x = 0 - x = 0 - x = 0xffffffffffffffff x = 0xffffffffffffffff - x = 077777777777777777 - x = 077777777777777777 - x = 123456789012345678901234567890 + x = 0Xffffffffffffffff + x = 0o77777777777777777 + x = 0O77777777777777777 x = 123456789012345678901234567890 + x = 0b100000000000000000000000000000000000000000000000000000000000000000000 + x = 0B111111111111111111111111111111111111111111111111111111111111111111111 def testFloats(self): x = 3.14 Modified: python/branches/py3k-struni/Lib/test/test_hexoct.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_hexoct.py (original) +++ python/branches/py3k-struni/Lib/test/test_hexoct.py Wed Jun 13 20:07:49 2007 @@ -65,49 +65,49 @@ def test_oct_baseline(self): # Baseline tests self.assertEqual(00, 0) - self.assertEqual(020, 16) + self.assertEqual(0o20, 16) if platform_long_is_32_bits: - self.assertEqual(017777777777, 2147483647) + self.assertEqual(0o17777777777, 2147483647) else: - self.assertEqual(0777777777777777777777, 9223372036854775807) + self.assertEqual(0o777777777777777777777, 9223372036854775807) # Ditto with a minus sign and parentheses self.assertEqual(-(00), 0) - self.assertEqual(-(020), -16) + self.assertEqual(-(0o20), -16) if platform_long_is_32_bits: - self.assertEqual(-(017777777777), -2147483647) + self.assertEqual(-(0o17777777777), -2147483647) else: - self.assertEqual(-(0777777777777777777777), -9223372036854775807) + self.assertEqual(-(0o777777777777777777777), -9223372036854775807) # Ditto with a minus sign and NO parentheses self.assertEqual(-00, 0) - self.assertEqual(-020, -16) + self.assertEqual(-0o20, -16) if platform_long_is_32_bits: - self.assertEqual(-017777777777, -2147483647) + self.assertEqual(-0o17777777777, -2147483647) else: - self.assertEqual(-0777777777777777777777, -9223372036854775807) + self.assertEqual(-0o777777777777777777777, -9223372036854775807) def test_oct_unsigned(self): if platform_long_is_32_bits: # Positive constants - self.assertEqual(020000000000, 2147483648) - self.assertEqual(037777777777, 4294967295) + self.assertEqual(0o20000000000, 2147483648) + self.assertEqual(0o37777777777, 4294967295) # Ditto with a minus sign and parentheses - self.assertEqual(-(020000000000), -2147483648) - self.assertEqual(-(037777777777), -4294967295) + self.assertEqual(-(0o20000000000), -2147483648) + self.assertEqual(-(0o37777777777), -4294967295) # Ditto with a minus sign and NO parentheses # This failed in Python 2.2 through 2.2.2 and in 2.3a1 - self.assertEqual(-020000000000, -2147483648) - self.assertEqual(-037777777777, -4294967295) + self.assertEqual(-0o20000000000, -2147483648) + self.assertEqual(-0o37777777777, -4294967295) else: # Positive constants - self.assertEqual(01000000000000000000000, 9223372036854775808) - self.assertEqual(01777777777777777777777, 18446744073709551615) + self.assertEqual(0o1000000000000000000000, 9223372036854775808) + self.assertEqual(0o1777777777777777777777, 18446744073709551615) # Ditto with a minus sign and parentheses - self.assertEqual(-(01000000000000000000000), -9223372036854775808) - self.assertEqual(-(01777777777777777777777), -18446744073709551615) + self.assertEqual(-(0o1000000000000000000000), -9223372036854775808) + self.assertEqual(-(0o1777777777777777777777), -18446744073709551615) # Ditto with a minus sign and NO parentheses # This failed in Python 2.2 through 2.2.2 and in 2.3a1 - self.assertEqual(-01000000000000000000000, -9223372036854775808) - self.assertEqual(-01777777777777777777777, -18446744073709551615) + self.assertEqual(-0o1000000000000000000000, -9223372036854775808) + self.assertEqual(-0o1777777777777777777777, -18446744073709551615) def test_main(): test_support.run_unittest(TextHexOct) Modified: python/branches/py3k-struni/Lib/test/test_list.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_list.py (original) +++ python/branches/py3k-struni/Lib/test/test_list.py Wed Jun 13 20:07:49 2007 @@ -5,7 +5,7 @@ type2test = list def test_truth(self): - super(ListTest, self).test_truth() + super().test_truth() self.assert_(not []) self.assert_([42]) @@ -13,7 +13,7 @@ self.assert_([] is not []) def test_len(self): - super(ListTest, self).test_len() + super().test_len() self.assertEqual(len([]), 0) self.assertEqual(len([0]), 1) self.assertEqual(len([0, 1, 2]), 3) Modified: python/branches/py3k-struni/Lib/test/test_long.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_long.py (original) +++ python/branches/py3k-struni/Lib/test/test_long.py Wed Jun 13 20:07:49 2007 @@ -195,9 +195,6 @@ self.check_bitop_identities_3(x, y, self.getran((lenx + leny)//2)) def slow_format(self, x, base): - if (x, base) == (0, 8): - # this is an oddball! - return "0" digits = [] sign = 0 if x < 0: @@ -208,7 +205,7 @@ digits.reverse() digits = digits or [0] return '-'[:sign] + \ - {8: '0', 10: '', 16: '0x'}[base] + \ + {2: '0b', 8: '0o', 10: '', 16: '0x'}[base] + \ "".join(map(lambda i: "0123456789abcdef"[i], digits)) def check_format_1(self, x): Modified: python/branches/py3k-struni/Lib/test/test_multibytecodec.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_multibytecodec.py (original) +++ python/branches/py3k-struni/Lib/test/test_multibytecodec.py Wed Jun 13 20:07:49 2007 @@ -136,6 +136,16 @@ self.assertRaises(UnicodeDecodeError, decoder.decode, '', True) self.assertEqual(decoder.decode('B@$'), '\u4e16') +class Test_StreamReader(unittest.TestCase): + def test_bug1728403(self): + try: + open(TESTFN, 'w').write('\xa1') + f = codecs.open(TESTFN, encoding='cp949') + self.assertRaises(UnicodeDecodeError, f.read, 2) + finally: + try: f.close() + except: pass + os.unlink(TESTFN) class Test_StreamWriter(unittest.TestCase): if len('\U00012345') == 2: # UCS2 Modified: python/branches/py3k-struni/Lib/test/test_peepholer.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_peepholer.py (original) +++ python/branches/py3k-struni/Lib/test/test_peepholer.py Wed Jun 13 20:07:49 2007 @@ -39,16 +39,24 @@ asm = dis_single(line) self.assert_(elem in asm) - def test_none_as_constant(self): - # LOAD_GLOBAL None --> LOAD_CONST None + def test_global_as_constant(self): + # LOAD_GLOBAL None/True/False --> LOAD_CONST None/True/False def f(x): None + None return x - asm = disassemble(f) - for elem in ('LOAD_GLOBAL',): - self.assert_(elem not in asm) - for elem in ('LOAD_CONST', '(None)'): - self.assert_(elem in asm) + def g(x): + True + return x + def h(x): + False + return x + for func, name in ((f, 'None'), (g, 'True'), (h, 'False')): + asm = disassemble(func) + for elem in ('LOAD_GLOBAL',): + self.assert_(elem not in asm) + for elem in ('LOAD_CONST', '('+name+')'): + self.assert_(elem in asm) def f(): 'Adding a docstring made this test fail in Py2.5.0' return None Modified: python/branches/py3k-struni/Lib/test/test_pep352.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_pep352.py (original) +++ python/branches/py3k-struni/Lib/test/test_pep352.py Wed Jun 13 20:07:49 2007 @@ -131,22 +131,22 @@ """Catching 'object_' should raise a TypeError.""" try: try: - raise StandardError + raise Exception except object_: pass except TypeError: pass - except StandardError: + except Exception: self.fail("TypeError expected when catching %s" % type(object_)) try: try: - raise StandardError + raise Exception except (object_,): pass except TypeError: return - except StandardError: + except Exception: self.fail("TypeError expected when catching %s as specified in a " "tuple" % type(object_)) Modified: python/branches/py3k-struni/Lib/test/test_repr.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_repr.py (original) +++ python/branches/py3k-struni/Lib/test/test_repr.py Wed Jun 13 20:07:49 2007 @@ -10,6 +10,7 @@ from test.test_support import run_unittest from repr import repr as r # Don't shadow builtin repr +from repr import Repr def nestedTuple(nesting): @@ -34,6 +35,18 @@ expected = repr(s)[:13] + "..." + repr(s)[-14:] eq(r(s), expected) + def test_tuple(self): + eq = self.assertEquals + eq(r((1,)), "(1,)") + + t3 = (1, 2, 3) + eq(r(t3), "(1, 2, 3)") + + r2 = Repr() + r2.maxtuple = 2 + expected = repr(t3)[:-2] + "...)" + eq(r2.repr(t3), expected) + def test_container(self): from array import array from collections import deque Modified: python/branches/py3k-struni/Lib/test/test_str.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_str.py (original) +++ python/branches/py3k-struni/Lib/test/test_str.py Wed Jun 13 20:07:49 2007 @@ -1,4 +1,7 @@ + import unittest +import struct +import sys from test import test_support, string_tests @@ -88,6 +91,15 @@ self.assertEqual(str8(Foo9("foo")), "string") self.assertEqual(str(Foo9("foo")), "not unicode") + def test_expandtabs_overflows_gracefully(self): + # 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: + return + self.assertRaises(OverflowError, 't\tt\t'.expandtabs, sys.maxint) + + def test_main(): test_support.run_unittest(StrTest) Modified: python/branches/py3k-struni/Lib/test/test_strptime.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_strptime.py (original) +++ python/branches/py3k-struni/Lib/test/test_strptime.py Wed Jun 13 20:07:49 2007 @@ -190,6 +190,15 @@ "locale data that contains regex metacharacters is not" " properly escaped") + def test_whitespace_substitution(self): + # When pattern contains whitespace, make sure it is taken into account + # so as to not allow to subpatterns to end up next to each other and + # "steal" characters from each other. + pattern = self.time_re.pattern('%j %H') + self.failUnless(not re.match(pattern, "180")) + self.failUnless(re.match(pattern, "18 0")) + + class StrptimeTests(unittest.TestCase): """Tests for _strptime.strptime.""" @@ -463,8 +472,8 @@ "of the year") test_helper((1917, 12, 31), "Dec 31 on Monday with year starting and " "ending on Monday") - test_helper((2007, 01, 07), "First Sunday of 2007") - test_helper((2007, 01, 14), "Second Sunday of 2007") + test_helper((2007, 1, 7), "First Sunday of 2007") + test_helper((2007, 1, 14), "Second Sunday of 2007") test_helper((2006, 12, 31), "Last Sunday of 2006") test_helper((2006, 12, 24), "Second to last Sunday of 2006") Modified: python/branches/py3k-struni/Lib/test/test_structmembers.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_structmembers.py (original) +++ python/branches/py3k-struni/Lib/test/test_structmembers.py Wed Jun 13 20:07:49 2007 @@ -2,7 +2,8 @@ CHAR_MAX, CHAR_MIN, UCHAR_MAX, \ SHRT_MAX, SHRT_MIN, USHRT_MAX, \ INT_MAX, INT_MIN, UINT_MAX, \ - LONG_MAX, LONG_MIN, ULONG_MAX + LONG_MAX, LONG_MIN, ULONG_MAX, \ + LLONG_MAX, LLONG_MIN, ULLONG_MAX import warnings, unittest from test import test_support @@ -39,6 +40,23 @@ ts.T_ULONG=ULONG_MAX self.assertEquals(ts.T_ULONG, ULONG_MAX) + ## T_LONGLONG and T_ULONGLONG may not be present on some platforms + if hasattr(ts, 'T_LONGLONG'): + ts.T_LONGLONG=LLONG_MAX + self.assertEquals(ts.T_LONGLONG, LLONG_MAX) + ts.T_LONGLONG=LLONG_MIN + self.assertEquals(ts.T_LONGLONG, LLONG_MIN) + + ts.T_ULONGLONG=ULLONG_MAX + self.assertEquals(ts.T_ULONGLONG, ULLONG_MAX) + + ## make sure these will accept a plain int as well as a long + ts.T_LONGLONG=3 + self.assertEquals(ts.T_LONGLONG, 3) + ts.T_ULONGLONG=4 + self.assertEquals(ts.T_ULONGLONG, 4) + + class TestWarnings(unittest.TestCase): def has_warned(self, w): self.assert_(w.category is RuntimeWarning) Modified: python/branches/py3k-struni/Lib/test/test_subprocess.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_subprocess.py (original) +++ python/branches/py3k-struni/Lib/test/test_subprocess.py Wed Jun 13 20:07:49 2007 @@ -528,7 +528,7 @@ os.write(f, "exec %s -c 'import sys; sys.exit(47)'\n" % sys.executable) os.close(f) - os.chmod(fname, 0700) + os.chmod(fname, 0o700) p = subprocess.Popen(fname) p.wait() os.remove(fname) @@ -570,7 +570,7 @@ os.write(f, "exec %s -c 'import sys; sys.exit(47)'\n" % sys.executable) os.close(f) - os.chmod(fname, 0700) + os.chmod(fname, 0o700) rc = subprocess.call(fname) os.remove(fname) self.assertEqual(rc, 47) Modified: python/branches/py3k-struni/Lib/test/test_sundry.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_sundry.py (original) +++ python/branches/py3k-struni/Lib/test/test_sundry.py Wed Jun 13 20:07:49 2007 @@ -1,6 +1,7 @@ """Do a minimal test of all the modules that aren't otherwise tested.""" from test.test_support import guard_warnings_filter +import sys import warnings with guard_warnings_filter(): @@ -18,6 +19,53 @@ import cmd import code import compileall + + import distutils.archive_util + import distutils.bcppcompiler + import distutils.ccompiler + import distutils.cmd + import distutils.core + import distutils.cygwinccompiler + import distutils.dep_util + import distutils.dir_util + import distutils.emxccompiler + import distutils.errors + import distutils.extension + import distutils.file_util + import distutils.filelist + import distutils.log + if sys.platform.startswith('win'): + import distutils.msvccompiler + import distutils.mwerkscompiler + import distutils.sysconfig + import distutils.text_file + import distutils.unixccompiler + import distutils.util + import distutils.version + + import distutils.command.bdist_dumb + if sys.platform.startswith('win'): + import distutils.command.bdist_msi + import distutils.command.bdist + import distutils.command.bdist_rpm + import distutils.command.bdist_wininst + import distutils.command.build_clib + import distutils.command.build_ext + import distutils.command.build + import distutils.command.build_py + import distutils.command.build_scripts + import distutils.command.clean + import distutils.command.config + import distutils.command.install_data + import distutils.command.install_egg_info + import distutils.command.install_headers + import distutils.command.install_lib + import distutils.command.install + import distutils.command.install_scripts + import distutils.command.register + import distutils.command.sdist + import distutils.command.upload + import encodings import formatter import ftplib @@ -37,7 +85,6 @@ import os2emxpath import pdb import pipes - #import poplib import pstats import py_compile import pydoc Modified: python/branches/py3k-struni/Lib/test/test_tarfile.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_tarfile.py (original) +++ python/branches/py3k-struni/Lib/test/test_tarfile.py Wed Jun 13 20:07:49 2007 @@ -164,7 +164,7 @@ def test_check_members(self): for tarinfo in self.tar: - self.assert_(int(tarinfo.mtime) == 07606136617, + self.assert_(int(tarinfo.mtime) == 0o7606136617, "wrong mtime for %s" % tarinfo.name) if not tarinfo.name.startswith("ustar/"): continue @@ -299,7 +299,7 @@ self.assert_(md5sum(self.tar.extractfile(tarinfo).read()) == chksum, "wrong md5sum for %s" % tarinfo.name) - kwargs["mtime"] = 07606136617 + kwargs["mtime"] = 0o7606136617 kwargs["uid"] = 1000 kwargs["gid"] = 100 if "old-v7" not in tarinfo.name: @@ -978,7 +978,7 @@ # uid > 8 digits tarinfo = tarfile.TarInfo("name") - tarinfo.uid = 010000000 + tarinfo.uid = 0o10000000 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT) def test_gnu_limits(self): @@ -991,7 +991,7 @@ # uid >= 256 ** 7 tarinfo = tarfile.TarInfo("name") - tarinfo.uid = 04000000000000000000 + tarinfo.uid = 0o4000000000000000000 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.GNU_FORMAT) def test_pax_limits(self): @@ -1003,7 +1003,7 @@ tarinfo.tobuf(tarfile.PAX_FORMAT) tarinfo = tarfile.TarInfo("name") - tarinfo.uid = 04000000000000000000 + tarinfo.uid = 0o4000000000000000000 tarinfo.tobuf(tarfile.PAX_FORMAT) Modified: python/branches/py3k-struni/Lib/test/test_tempfile.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_tempfile.py (original) +++ python/branches/py3k-struni/Lib/test/test_tempfile.py Wed Jun 13 20:07:49 2007 @@ -264,7 +264,7 @@ file = self.do_create() mode = stat.S_IMODE(os.stat(file.name).st_mode) - expected = 0600 + expected = 0o600 if sys.platform in ('win32', 'os2emx', 'mac'): # There's no distinction among 'user', 'group' and 'world'; # replicate the 'user' bits. @@ -482,8 +482,8 @@ dir = self.do_create() try: mode = stat.S_IMODE(os.stat(dir).st_mode) - mode &= 0777 # Mask off sticky bits inherited from /tmp - expected = 0700 + mode &= 0o777 # Mask off sticky bits inherited from /tmp + expected = 0o700 if sys.platform in ('win32', 'os2emx', 'mac'): # There's no distinction among 'user', 'group' and 'world'; # replicate the 'user' bits. @@ -517,7 +517,7 @@ self.name = tempfile.mktemp(dir=dir, prefix=pre, suffix=suf) # Create the file. This will raise an exception if it's # mysteriously appeared in the meanwhile. - os.close(os.open(self.name, self._bflags, 0600)) + os.close(os.open(self.name, self._bflags, 0o600)) def __del__(self): self._unlink(self.name) Modified: python/branches/py3k-struni/Lib/test/test_threading.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_threading.py (original) +++ python/branches/py3k-struni/Lib/test/test_threading.py Wed Jun 13 20:07:49 2007 @@ -3,6 +3,7 @@ import test.test_support from test.test_support import verbose import random +import sys import threading import thread import time @@ -201,8 +202,47 @@ t.join() # else the thread is still running, and we have no way to kill it +class ThreadingExceptionTests(unittest.TestCase): + # A RuntimeError should be raised if Thread.start() is called + # multiple times. + def test_start_thread_again(self): + thread = threading.Thread() + thread.start() + self.assertRaises(RuntimeError, thread.start) + + def test_releasing_unacquired_rlock(self): + rlock = threading.RLock() + self.assertRaises(RuntimeError, rlock.release) + + def test_waiting_on_unacquired_condition(self): + cond = threading.Condition() + self.assertRaises(RuntimeError, cond.wait) + + def test_notify_on_unacquired_condition(self): + cond = threading.Condition() + self.assertRaises(RuntimeError, cond.notify) + + def test_semaphore_with_negative_value(self): + self.assertRaises(ValueError, threading.Semaphore, value = -1) + self.assertRaises(ValueError, threading.Semaphore, value = -sys.maxint) + + def test_joining_current_thread(self): + currentThread = threading.currentThread() + self.assertRaises(RuntimeError, currentThread.join); + + def test_joining_inactive_thread(self): + thread = threading.Thread() + self.assertRaises(RuntimeError, thread.join) + + def test_daemonize_active_thread(self): + thread = threading.Thread() + thread.start() + self.assertRaises(RuntimeError, thread.setDaemon, True) + + def test_main(): - test.test_support.run_unittest(ThreadTests) + test.test_support.run_unittest(ThreadTests, + ThreadingExceptionTests) if __name__ == "__main__": test_main() Modified: python/branches/py3k-struni/Lib/test/test_tuple.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_tuple.py (original) +++ python/branches/py3k-struni/Lib/test/test_tuple.py Wed Jun 13 20:07:49 2007 @@ -5,30 +5,30 @@ type2test = tuple def test_constructors(self): - super(TupleTest, self).test_len() + super().test_len() # calling built-in types without argument must return empty self.assertEqual(tuple(), ()) def test_truth(self): - super(TupleTest, self).test_truth() + super().test_truth() self.assert_(not ()) self.assert_((42, )) def test_len(self): - super(TupleTest, self).test_len() + super().test_len() self.assertEqual(len(()), 0) self.assertEqual(len((0,)), 1) self.assertEqual(len((0, 1, 2)), 3) def test_iadd(self): - super(TupleTest, self).test_iadd() + super().test_iadd() u = (0, 1) u2 = u u += (2, 3) self.assert_(u is not u2) def test_imul(self): - super(TupleTest, self).test_imul() + super().test_imul() u = (0, 1) u2 = u u *= 3 Modified: python/branches/py3k-struni/Lib/test/test_unicode.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_unicode.py (original) +++ python/branches/py3k-struni/Lib/test/test_unicode.py Wed Jun 13 20:07:49 2007 @@ -6,7 +6,7 @@ (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. """#" -import unittest, sys, codecs, new +import unittest, sys, struct, codecs, new from test import test_support, string_tests # Error handling (bad decoder return) @@ -785,8 +785,13 @@ self.assertEqual(repr(s1()), '\\n') self.assertEqual(repr(s2()), '\\n') - - + def test_expandtabs_overflows_gracefully(self): + # 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: + return + self.assertRaises(OverflowError, u't\tt\t'.expandtabs, sys.maxint) def test_main(): Modified: python/branches/py3k-struni/Lib/test/test_unicode_file.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_unicode_file.py (original) +++ python/branches/py3k-struni/Lib/test/test_unicode_file.py Wed Jun 13 20:07:49 2007 @@ -48,7 +48,7 @@ self.failUnless(os.path.exists(os.path.abspath(filename))) self.failUnless(os.path.isfile(os.path.abspath(filename))) self.failUnless(os.access(os.path.abspath(filename), os.R_OK)) - os.chmod(filename, 0777) + os.chmod(filename, 0o777) os.utime(filename, None) os.utime(filename, (time.time(), time.time())) # Copy/rename etc tests using the same filename Modified: python/branches/py3k-struni/Lib/test/test_unittest.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_unittest.py (original) +++ python/branches/py3k-struni/Lib/test/test_unittest.py Wed Jun 13 20:07:49 2007 @@ -16,23 +16,23 @@ class LoggingResult(unittest.TestResult): def __init__(self, log): self._events = log - super(LoggingResult, self).__init__() + super().__init__() def startTest(self, test): self._events.append('startTest') - super(LoggingResult, self).startTest(test) + super().startTest(test) def stopTest(self, test): self._events.append('stopTest') - super(LoggingResult, self).stopTest(test) + super().stopTest(test) def addFailure(self, *args): self._events.append('addFailure') - super(LoggingResult, self).addFailure(*args) + super().addFailure(*args) def addError(self, *args): self._events.append('addError') - super(LoggingResult, self).addError(*args) + super().addError(*args) class TestEquality(object): # Check for a valid __eq__ implementation Modified: python/branches/py3k-struni/Lib/test/test_urllib2.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_urllib2.py (original) +++ python/branches/py3k-struni/Lib/test/test_urllib2.py Wed Jun 13 20:07:49 2007 @@ -544,7 +544,7 @@ class NullFTPHandler(urllib2.FTPHandler): def __init__(self, data): self.data = data - def connect_ftp(self, user, passwd, host, port, dirs): + def connect_ftp(self, user, passwd, host, port, dirs, timeout=None): self.user, self.passwd = user, passwd self.host, self.port = host, port self.dirs = dirs @@ -567,7 +567,9 @@ "localhost", ftplib.FTP_PORT, "A", [], "baz.gif", None), # XXX really this should guess image/gif ]: - r = h.ftp_open(Request(url)) + req = Request(url) + req.timeout = None + r = h.ftp_open(req) # ftp authentication not yet implemented by FTPHandler self.assert_(h.user == h.passwd == "") self.assertEqual(h.host, socket.gethostbyname(host)) @@ -682,8 +684,9 @@ self.req_headers = [] self.data = None self.raise_on_endheaders = False - def __call__(self, host): + def __call__(self, host, timeout=None): self.host = host + self.timeout = timeout return self def set_debuglevel(self, level): self.level = level @@ -706,6 +709,7 @@ url = "http://example.com/" for method, data in [("GET", None), ("POST", "blah")]: req = Request(url, data, {"Foo": "bar"}) + req.timeout = None req.add_unredirected_header("Spam", "eggs") http = MockHTTPClass() r = h.do_open(http, req) Modified: python/branches/py3k-struni/Lib/test/test_urllib2net.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_urllib2net.py (original) +++ python/branches/py3k-struni/Lib/test/test_urllib2net.py Wed Jun 13 20:07:49 2007 @@ -267,6 +267,49 @@ return handlers +class TimeoutTest(unittest.TestCase): + def test_http_basic(self): + u = urllib2.urlopen("http://www.python.org") + self.assertTrue(u.fp._sock.fp._sock.gettimeout() is None) + + def test_http_NoneWithdefault(self): + prev = socket.getdefaulttimeout() + socket.setdefaulttimeout(60) + try: + u = urllib2.urlopen("http://www.python.org", timeout=None) + self.assertEqual(u.fp._sock.fp._sock.gettimeout(), 60) + finally: + socket.setdefaulttimeout(prev) + + def test_http_Value(self): + u = urllib2.urlopen("http://www.python.org", timeout=120) + self.assertEqual(u.fp._sock.fp._sock.gettimeout(), 120) + + def test_http_NoneNodefault(self): + u = urllib2.urlopen("http://www.python.org", timeout=None) + self.assertTrue(u.fp._sock.fp._sock.gettimeout() is None) + + def test_ftp_basic(self): + u = urllib2.urlopen("ftp://ftp.mirror.nl/pub/mirror/gnu/") + self.assertTrue(u.fp.fp._sock.gettimeout() is None) + + def test_ftp_NoneWithdefault(self): + prev = socket.getdefaulttimeout() + socket.setdefaulttimeout(60) + try: + u = urllib2.urlopen("ftp://ftp.mirror.nl/pub/mirror/gnu/", timeout=None) + self.assertEqual(u.fp.fp._sock.gettimeout(), 60) + finally: + socket.setdefaulttimeout(prev) + + def test_ftp_NoneNodefault(self): + u = urllib2.urlopen("ftp://ftp.mirror.nl/pub/mirror/gnu/", timeout=None) + self.assertTrue(u.fp.fp._sock.gettimeout() is None) + + def test_ftp_Value(self): + u = urllib2.urlopen("ftp://ftp.mirror.nl/pub/mirror/gnu/", timeout=60) + self.assertEqual(u.fp.fp._sock.gettimeout(), 60) + def test_main(): test_support.requires("network") @@ -275,6 +318,7 @@ AuthTests, OtherNetworkTests, CloseSocketTest, + TimeoutTest, ) if __name__ == "__main__": Modified: python/branches/py3k-struni/Lib/test/test_userlist.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_userlist.py (original) +++ python/branches/py3k-struni/Lib/test/test_userlist.py Wed Jun 13 20:07:49 2007 @@ -8,7 +8,7 @@ type2test = UserList def test_getslice(self): - super(UserListTest, self).test_getslice() + super().test_getslice() l = [0, 1, 2, 3, 4] u = self.type2test(l) for i in range(-3, 6): @@ -30,7 +30,7 @@ self.assertEqual(u2, list("spameggs")) def test_iadd(self): - super(UserListTest, self).test_iadd() + super().test_iadd() u = [0, 1] u += UserList([0, 1]) self.assertEqual(u, [0, 1, 0, 1]) Modified: python/branches/py3k-struni/Lib/test/test_uu.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_uu.py (original) +++ python/branches/py3k-struni/Lib/test/test_uu.py Wed Jun 13 20:07:49 2007 @@ -24,21 +24,21 @@ inp = cStringIO.StringIO(plaintext) out = cStringIO.StringIO() uu.encode(inp, out, "t1") - self.assertEqual(out.getvalue(), encodedtextwrapped % (0666, "t1")) + self.assertEqual(out.getvalue(), encodedtextwrapped % (0o666, "t1")) inp = cStringIO.StringIO(plaintext) out = cStringIO.StringIO() - uu.encode(inp, out, "t1", 0644) - self.assertEqual(out.getvalue(), encodedtextwrapped % (0644, "t1")) + uu.encode(inp, out, "t1", 0o644) + self.assertEqual(out.getvalue(), encodedtextwrapped % (0o644, "t1")) def test_decode(self): - inp = cStringIO.StringIO(encodedtextwrapped % (0666, "t1")) + inp = cStringIO.StringIO(encodedtextwrapped % (0o666, "t1")) out = cStringIO.StringIO() uu.decode(inp, out) self.assertEqual(out.getvalue(), plaintext) inp = cStringIO.StringIO( "UUencoded files may contain many lines,\n" + "even some that have 'begin' in them.\n" + - encodedtextwrapped % (0666, "t1") + encodedtextwrapped % (0o666, "t1") ) out = cStringIO.StringIO() uu.decode(inp, out) @@ -75,14 +75,14 @@ def test_encode(self): sys.stdin = cStringIO.StringIO(plaintext) sys.stdout = cStringIO.StringIO() - uu.encode("-", "-", "t1", 0666) + uu.encode("-", "-", "t1", 0o666) self.assertEqual( sys.stdout.getvalue(), - encodedtextwrapped % (0666, "t1") + encodedtextwrapped % (0o666, "t1") ) def test_decode(self): - sys.stdin = cStringIO.StringIO(encodedtextwrapped % (0666, "t1")) + sys.stdin = cStringIO.StringIO(encodedtextwrapped % (0o666, "t1")) sys.stdout = cStringIO.StringIO() uu.decode("-", "-") self.assertEqual(sys.stdout.getvalue(), plaintext) @@ -120,21 +120,21 @@ fin = open(self.tmpin, 'rb') fout = open(self.tmpout, 'w') - uu.encode(fin, fout, self.tmpin, mode=0644) + uu.encode(fin, fout, self.tmpin, mode=0o644) fin.close() fout.close() fout = open(self.tmpout, 'r') s = fout.read() fout.close() - self.assertEqual(s, encodedtextwrapped % (0644, self.tmpin)) + self.assertEqual(s, encodedtextwrapped % (0o644, self.tmpin)) # in_file and out_file as filenames - uu.encode(self.tmpin, self.tmpout, self.tmpin, mode=0644) + uu.encode(self.tmpin, self.tmpout, self.tmpin, mode=0o644) fout = open(self.tmpout, 'r') s = fout.read() fout.close() - self.assertEqual(s, encodedtextwrapped % (0644, self.tmpin)) + self.assertEqual(s, encodedtextwrapped % (0o644, self.tmpin)) finally: self._kill(fin) @@ -143,7 +143,7 @@ def test_decode(self): try: f = open(self.tmpin, 'w') - f.write(encodedtextwrapped % (0644, self.tmpout)) + f.write(encodedtextwrapped % (0o644, self.tmpout)) f.close() f = open(self.tmpin, 'r') @@ -161,7 +161,7 @@ def test_decodetwice(self): # Verify that decode() will refuse to overwrite an existing file try: - f = cStringIO.StringIO(encodedtextwrapped % (0644, self.tmpout)) + f = cStringIO.StringIO(encodedtextwrapped % (0o644, self.tmpout)) f = open(self.tmpin, 'r') uu.decode(f) Modified: python/branches/py3k-struni/Lib/test/test_weakref.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_weakref.py (original) +++ python/branches/py3k-struni/Lib/test/test_weakref.py Wed Jun 13 20:07:49 2007 @@ -651,10 +651,10 @@ class MyRef(weakref.ref): def __init__(self, ob, callback=None, value=42): self.value = value - super(MyRef, self).__init__(ob, callback) + super().__init__(ob, callback) def __call__(self): self.called = True - return super(MyRef, self).__call__() + return super().__call__() o = Object("foo") mr = MyRef(o, value=24) self.assert_(mr() is o) @@ -1091,7 +1091,7 @@ >>> import weakref >>> class ExtendedRef(weakref.ref): ... def __init__(self, ob, callback=None, **annotations): -... super(ExtendedRef, self).__init__(ob, callback) +... super().__init__(ob, callback) ... self.__counter = 0 ... for k, v in annotations.items(): ... setattr(self, k, v) @@ -1099,7 +1099,7 @@ ... '''Return a pair containing the referent and the number of ... times the reference has been called. ... ''' -... ob = super(ExtendedRef, self).__call__() +... ob = super().__call__() ... if ob is not None: ... self.__counter += 1 ... ob = (ob, self.__counter) Modified: python/branches/py3k-struni/Lib/test/test_xmlrpc.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_xmlrpc.py (original) +++ python/branches/py3k-struni/Lib/test/test_xmlrpc.py Wed Jun 13 20:07:49 2007 @@ -15,9 +15,9 @@ 'ukey\u4000': 'regular value', 'datetime1': xmlrpclib.DateTime('20050210T11:41:23'), 'datetime2': xmlrpclib.DateTime( - (2005, 02, 10, 11, 41, 23, 0, 1, -1)), + (2005, 2, 10, 11, 41, 23, 0, 1, -1)), 'datetime3': xmlrpclib.DateTime( - datetime.datetime(2005, 02, 10, 11, 41, 23)), + datetime.datetime(2005, 2, 10, 11, 41, 23)), }] class XMLRPCTestCase(unittest.TestCase): @@ -31,7 +31,7 @@ # by the marshalling code. This can't be done via test_dump_load() # since with use_datetime set to 1 the unmarshaller would create # datetime objects for the 'datetime[123]' keys as well - dt = datetime.datetime(2005, 02, 10, 11, 41, 23) + dt = datetime.datetime(2005, 2, 10, 11, 41, 23) s = xmlrpclib.dumps((dt,)) (newdt,), m = xmlrpclib.loads(s, use_datetime=1) self.assertEquals(newdt, dt) @@ -44,7 +44,7 @@ # This checks that an unwrapped datetime.date object can be handled # by the marshalling code. This can't be done via test_dump_load() # since the unmarshaller produces a datetime object - d = datetime.datetime(2005, 02, 10, 11, 41, 23).date() + d = datetime.datetime(2005, 2, 10, 11, 41, 23).date() s = xmlrpclib.dumps((d,)) (newd,), m = xmlrpclib.loads(s, use_datetime=1) self.assertEquals(newd.date(), d) @@ -58,7 +58,7 @@ # This checks that an unwrapped datetime.time object can be handled # by the marshalling code. This can't be done via test_dump_load() # since the unmarshaller produces a datetime object - t = datetime.datetime(2005, 02, 10, 11, 41, 23).time() + t = datetime.datetime(2005, 2, 10, 11, 41, 23).time() s = xmlrpclib.dumps((t,)) (newt,), m = xmlrpclib.loads(s, use_datetime=1) today = datetime.datetime.now().date().strftime("%Y%m%d") Modified: python/branches/py3k-struni/Lib/test/test_zipimport.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_zipimport.py (original) +++ python/branches/py3k-struni/Lib/test/test_zipimport.py Wed Jun 13 20:07:49 2007 @@ -364,7 +364,7 @@ finally: # If we leave "the read-only bit" set on Windows, nothing can # delete TESTMOD, and later tests suffer bogus failures. - os.chmod(TESTMOD, 0666) + os.chmod(TESTMOD, 0o666) test_support.unlink(TESTMOD) def testNotZipFile(self): Modified: python/branches/py3k-struni/Lib/test/tf_inherit_check.py ============================================================================== --- python/branches/py3k-struni/Lib/test/tf_inherit_check.py (original) +++ python/branches/py3k-struni/Lib/test/tf_inherit_check.py Wed Jun 13 20:07:49 2007 @@ -19,7 +19,7 @@ sys.stderr.write("fd %d is open in child" % fd) sys.exit(1) -except StandardError: +except Exception: if verbose: raise sys.exit(1) Modified: python/branches/py3k-struni/Lib/test/tokenize_tests.txt ============================================================================== --- python/branches/py3k-struni/Lib/test/tokenize_tests.txt (original) +++ python/branches/py3k-struni/Lib/test/tokenize_tests.txt Wed Jun 13 20:07:49 2007 @@ -37,21 +37,21 @@ # Ordinary integers 0xff != 255 -0377 != 255 -2147483647 != 017777777777 --2147483647-1 != 020000000000 -037777777777 != -1 -0xffffffff != -1 +0o377 != 255 +2147483647 != 0o17777777777 +-2147483647-1 != 0o20000000000 +0o37777777777 != -1 +0xffffffff != -1; 0o37777777777 != -1; -0o1234567 == 0O001234567; 0b10101 == 0B00010101 # Long integers -x = 0L -x = 0l -x = 0xffffffffffffffffL -x = 0xffffffffffffffffl -x = 077777777777777777L -x = 077777777777777777l -x = 123456789012345678901234567890L -x = 123456789012345678901234567890l +x = 0 +x = 0 +x = 0xffffffffffffffff +x = 0xffffffffffffffff +x = 0o77777777777777777 +x = 0B11101010111111111 +x = 123456789012345678901234567890 +x = 123456789012345678901234567890 # Floating-point numbers x = 3.14 Modified: python/branches/py3k-struni/Lib/threading.py ============================================================================== --- python/branches/py3k-struni/Lib/threading.py (original) +++ python/branches/py3k-struni/Lib/threading.py Wed Jun 13 20:07:49 2007 @@ -111,8 +111,8 @@ __enter__ = acquire def release(self): - me = currentThread() - assert self.__owner is me, "release() of un-acquire()d lock" + if self.__owner is not currentThread(): + raise RuntimeError("cannot release un-aquired lock") self.__count = count = self.__count - 1 if not count: self.__owner = None @@ -203,7 +203,8 @@ return True def wait(self, timeout=None): - assert self._is_owned(), "wait() of un-acquire()d lock" + if not self._is_owned(): + raise RuntimeError("cannot wait on un-aquired lock") waiter = _allocate_lock() waiter.acquire() self.__waiters.append(waiter) @@ -244,7 +245,8 @@ self._acquire_restore(saved_state) def notify(self, n=1): - assert self._is_owned(), "notify() of un-acquire()d lock" + if not self._is_owned(): + raise RuntimeError("cannot notify on un-aquired lock") __waiters = self.__waiters waiters = __waiters[:n] if not waiters: @@ -272,7 +274,8 @@ # After Tim Peters' semaphore class, but not quite the same (no maximum) def __init__(self, value=1, verbose=None): - assert value >= 0, "Semaphore initial value must be >= 0" + if value < 0: + raise ValueError("semaphore initial value must be >= 0") _Verbose.__init__(self, verbose) self.__cond = Condition(Lock()) self.__value = value @@ -423,8 +426,10 @@ return "<%s(%s, %s)>" % (self.__class__.__name__, self.__name, status) def start(self): - assert self.__initialized, "Thread.__init__() not called" - assert not self.__started, "thread already started" + if not self.__initialized: + raise RuntimeError("thread.__init__() not called") + if self.__started: + raise RuntimeError("thread already started") if __debug__: self._note("%s.start(): starting thread", self) _active_limbo_lock.acquire() @@ -544,9 +549,13 @@ _active_limbo_lock.release() def join(self, timeout=None): - assert self.__initialized, "Thread.__init__() not called" - assert self.__started, "cannot join thread before it is started" - assert self is not currentThread(), "cannot join current thread" + if not self.__initialized: + raise RuntimeError("Thread.__init__() not called") + if not self.__started: + raise RuntimeError("cannot join thread before it is started") + if self is currentThread(): + raise RuntimeError("cannot join current thread") + if __debug__: if not self.__stopped: self._note("%s.join(): waiting until thread stops", self) @@ -589,8 +598,10 @@ return self.__daemonic def setDaemon(self, daemonic): - assert self.__initialized, "Thread.__init__() not called" - assert not self.__started, "cannot set daemon status of active thread" + if not self.__initialized: + raise RuntimeError("Thread.__init__() not called") + if self.__started: + raise RuntimeError("cannot set daemon status of active thread"); self.__daemonic = daemonic # The timer class was contributed by Itamar Shtull-Trauring Modified: python/branches/py3k-struni/Lib/tokenize.py ============================================================================== --- python/branches/py3k-struni/Lib/tokenize.py (original) +++ python/branches/py3k-struni/Lib/tokenize.py Wed Jun 13 20:07:49 2007 @@ -49,10 +49,11 @@ Ignore = Whitespace + any(r'\\\r?\n' + Whitespace) + maybe(Comment) Name = r'[a-zA-Z_]\w*' -Hexnumber = r'0[xX][\da-fA-F]*[lL]?' -Octnumber = r'0[0-7]*[lL]?' -Decnumber = r'[1-9]\d*[lL]?' -Intnumber = group(Hexnumber, Octnumber, Decnumber) +Hexnumber = r'0[xX][\da-fA-F]*' +Binnumber = r'0[bB][01]*' +Octnumber = r'0[oO][0-7]*' +Decnumber = r'(?:0+|[1-9]\d*)' +Intnumber = group(Hexnumber, Binnumber, Octnumber, Decnumber) Exponent = r'[eE][-+]?\d+' Pointfloat = group(r'\d+\.\d*', r'\.\d+') + maybe(Exponent) Expfloat = r'\d+' + Exponent Modified: python/branches/py3k-struni/Lib/urllib2.py ============================================================================== --- python/branches/py3k-struni/Lib/urllib2.py (original) +++ python/branches/py3k-struni/Lib/urllib2.py Wed Jun 13 20:07:49 2007 @@ -114,11 +114,11 @@ __version__ = sys.version[:3] _opener = None -def urlopen(url, data=None): +def urlopen(url, data=None, timeout=None): global _opener if _opener is None: _opener = build_opener() - return _opener.open(url, data) + return _opener.open(url, data, timeout) def install_opener(opener): global _opener @@ -352,7 +352,7 @@ if result is not None: return result - def open(self, fullurl, data=None): + def open(self, fullurl, data=None, timeout=None): # accept a URL or a Request object if isinstance(fullurl, basestring): req = Request(fullurl, data) @@ -361,6 +361,7 @@ if data is not None: req.add_data(data) + req.timeout = timeout protocol = req.get_type() # pre-process request @@ -944,7 +945,7 @@ respdig = KD(H(A1), "%s:%s" % (nonce, H(A2))) else: # XXX handle auth-int. - pass + raise URLError("qop '%s' is not supported." % qop) # XXX should the partial digests be encoded too? @@ -1053,7 +1054,7 @@ if not host: raise URLError('no host given') - h = http_class(host) # will parse host:port + h = http_class(host, timeout=req.timeout) # will parse host:port h.set_debuglevel(self._debuglevel) headers = dict(req.headers) @@ -1263,7 +1264,7 @@ if dirs and not dirs[0]: dirs = dirs[1:] try: - fw = self.connect_ftp(user, passwd, host, port, dirs) + fw = self.connect_ftp(user, passwd, host, port, dirs, req.timeout) type = file and 'I' or 'D' for attr in attrs: attr, value = splitvalue(attr) @@ -1283,8 +1284,8 @@ except ftplib.all_errors as msg: raise IOError, ('ftp error', msg), sys.exc_info()[2] - def connect_ftp(self, user, passwd, host, port, dirs): - fw = ftpwrapper(user, passwd, host, port, dirs) + def connect_ftp(self, user, passwd, host, port, dirs, timeout): + fw = ftpwrapper(user, passwd, host, port, dirs, timeout) ## fw.ftp.set_debuglevel(1) return fw @@ -1304,12 +1305,12 @@ def setMaxConns(self, m): self.max_conns = m - def connect_ftp(self, user, passwd, host, port, dirs): - key = user, host, port, '/'.join(dirs) + def connect_ftp(self, user, passwd, host, port, dirs, timeout): + key = user, host, port, '/'.join(dirs), timeout if key in self.cache: self.timeout[key] = time.time() + self.delay else: - self.cache[key] = ftpwrapper(user, passwd, host, port, dirs) + self.cache[key] = ftpwrapper(user, passwd, host, port, dirs, timeout) self.timeout[key] = time.time() + self.delay self.check_cache() return self.cache[key] Modified: python/branches/py3k-struni/Lib/uu.py ============================================================================== --- python/branches/py3k-struni/Lib/uu.py (original) +++ python/branches/py3k-struni/Lib/uu.py Wed Jun 13 20:07:49 2007 @@ -68,11 +68,11 @@ if name is None: name = '-' if mode is None: - mode = 0666 + mode = 0o666 # # Write the data # - out_file.write('begin %o %s\n' % ((mode&0777),name)) + out_file.write('begin %o %s\n' % ((mode & 0o777),name)) data = in_file.read(45) while len(data) > 0: out_file.write(binascii.b2a_uu(data)) Modified: python/branches/py3k-struni/Lib/weakref.py ============================================================================== --- python/branches/py3k-struni/Lib/weakref.py (original) +++ python/branches/py3k-struni/Lib/weakref.py Wed Jun 13 20:07:49 2007 @@ -204,7 +204,7 @@ return self def __init__(self, ob, callback, key): - super(KeyedRef, self).__init__(ob, callback) + super().__init__(ob, callback) class WeakKeyDictionary(UserDict.UserDict): Modified: python/branches/py3k-struni/Lib/xml/dom/domreg.py ============================================================================== --- python/branches/py3k-struni/Lib/xml/dom/domreg.py (original) +++ python/branches/py3k-struni/Lib/xml/dom/domreg.py Wed Jun 13 20:07:49 2007 @@ -72,7 +72,7 @@ for creator in well_known_implementations.keys(): try: dom = getDOMImplementation(name = creator) - except StandardError: # typically ImportError, or AttributeError + except Exception: # typically ImportError, or AttributeError continue if _good_enough(dom, features): return dom Modified: python/branches/py3k-struni/Misc/ACKS ============================================================================== --- python/branches/py3k-struni/Misc/ACKS (original) +++ python/branches/py3k-struni/Misc/ACKS Wed Jun 13 20:07:49 2007 @@ -159,6 +159,7 @@ Vincent Delft Erik Demaine Roger Dev +Raghuram Devarakonda Toby Dickenson Mark Dickinson Yves Dionne @@ -660,6 +661,7 @@ Roger Upole Michael Urman Hector Urtubia +Atul Varma Dmitry Vasiliev Frank Vercruesse Mike Verdone Modified: python/branches/py3k-struni/Misc/NEWS ============================================================================== --- python/branches/py3k-struni/Misc/NEWS (original) +++ python/branches/py3k-struni/Misc/NEWS Wed Jun 13 20:07:49 2007 @@ -26,6 +26,13 @@ Core and Builtins ----------------- +- Removed the __oct__ and __hex__ special methods and added a bin() + builtin function. + +- PEP 3127: octal literals now start with "0o". Old-style octal literals + are invalid. There are binary literals with a prefix of "0b". + This also affects int(x, 0). + - None, True, False are now keywords. - PEP 3119: isinstance() and issubclass() can be overridden. Modified: python/branches/py3k-struni/Misc/Vim/python.vim ============================================================================== --- python/branches/py3k-struni/Misc/Vim/python.vim (original) +++ python/branches/py3k-struni/Misc/Vim/python.vim Wed Jun 13 20:07:49 2007 @@ -88,7 +88,7 @@ syn keyword pythonException MemoryError NameError NotImplementedError syn keyword pythonException OSError OverflowError PendingDeprecationWarning syn keyword pythonException ReferenceError RuntimeError RuntimeWarning - syn keyword pythonException StandardError StopIteration SyntaxError + syn keyword pythonException StopIteration SyntaxError syn keyword pythonException SyntaxWarning SystemError SystemExit TabError syn keyword pythonException TypeError UnboundLocalError UnicodeDecodeError syn keyword pythonException UnicodeEncodeError UnicodeError Modified: python/branches/py3k-struni/Misc/build.sh ============================================================================== --- python/branches/py3k-struni/Misc/build.sh (original) +++ python/branches/py3k-struni/Misc/build.sh Wed Jun 13 20:07:49 2007 @@ -70,7 +70,7 @@ LEAKY_TESTS="test_(cmd_line|socket)" # These tests always fail, so skip them so we don't get false positives. -_ALWAYS_SKIP="test_compiler test_transformer" +_ALWAYS_SKIP="" ALWAYS_SKIP="-x $_ALWAYS_SKIP" # Skip these tests altogether when looking for leaks. These tests Modified: python/branches/py3k-struni/Misc/cheatsheet ============================================================================== --- python/branches/py3k-struni/Misc/cheatsheet (original) +++ python/branches/py3k-struni/Misc/cheatsheet Wed Jun 13 20:07:49 2007 @@ -779,8 +779,8 @@ class, the class name is printed, then a colon and a space, and finally the instance converted to a string using the built-in function str(). -All built-in exception classes derives from StandardError, itself -derived from Exception. +All built-in exception classes derives from Exception, itself +derived from BaseException. Name Space Statements @@ -1051,9 +1051,6 @@ On 'sys.exit()' StopIteration Signal the end from iterator.__next__() - StandardError - Base class for all built-in exceptions; derived from Exception - root class. ArithmeticError Base class for OverflowError, ZeroDivisionError, FloatingPointError Modified: python/branches/py3k-struni/Misc/python-mode.el ============================================================================== --- python/branches/py3k-struni/Misc/python-mode.el (original) +++ python/branches/py3k-struni/Misc/python-mode.el Wed Jun 13 20:07:49 2007 @@ -369,7 +369,7 @@ "NotImplementedError" "OSError" "OverflowError" "OverflowWarning" "PendingDeprecationWarning" "ReferenceError" "RuntimeError" "RuntimeWarning" - "StandardError" "StopIteration" "SyntaxError" + "StopIteration" "SyntaxError" "SyntaxWarning" "SystemError" "SystemExit" "TabError" "True" "TypeError" "UnboundLocalError" "UnicodeDecodeError" "UnicodeEncodeError" Modified: python/branches/py3k-struni/Misc/valgrind-python.supp ============================================================================== --- python/branches/py3k-struni/Misc/valgrind-python.supp (original) +++ python/branches/py3k-struni/Misc/valgrind-python.supp Wed Jun 13 20:07:49 2007 @@ -134,6 +134,15 @@ ### { + Generic ubuntu ld problems + Memcheck:Addr8 + obj:/lib/ld-2.4.so + obj:/lib/ld-2.4.so + obj:/lib/ld-2.4.so + obj:/lib/ld-2.4.so +} + +{ Generic gentoo ld problems Memcheck:Cond obj:/lib/ld-2.3.4.so Modified: python/branches/py3k-struni/Modules/_bsddb.c ============================================================================== --- python/branches/py3k-struni/Modules/_bsddb.c (original) +++ python/branches/py3k-struni/Modules/_bsddb.c Wed Jun 13 20:07:49 2007 @@ -1713,6 +1713,7 @@ PyObject* dataobj; PyObject* retval = NULL; DBT key, data; + void *orig_data; DB_TXN *txn = NULL; static char* kwnames[] = { "key", "data", "txn", "flags", NULL }; @@ -1724,7 +1725,6 @@ CHECK_DB_NOT_CLOSED(self); if (!make_key_dbt(self, keyobj, &key, NULL)) return NULL; - CLEAR_DBT(data); if ( !make_dbt(dataobj, &data) || !checkTxnObj(txnobj, &txn) ) { @@ -1733,13 +1733,12 @@ } flags |= DB_GET_BOTH; + orig_data = data.data; if (CHECK_DBFLAG(self, DB_THREAD)) { /* Tell BerkeleyDB to malloc the return value (thread safe) */ + /* XXX(nnorwitz): At least 4.4.20 and 4.5.20 require this flag. */ data.flags = DB_DBT_MALLOC; - /* TODO: Is this flag needed? We're passing a data object that should - match what's in the DB, so there should be no need to malloc. - We run the risk of freeing something twice! Check this. */ } MYDB_BEGIN_ALLOW_THREADS; @@ -1753,8 +1752,13 @@ retval = Py_None; } else if (!err) { + /* XXX(nnorwitz): can we do: retval = dataobj; Py_INCREF(retval); */ retval = PyString_FromStringAndSize((char*)data.data, data.size); - FREE_DBT(data); /* Only if retrieval was successful */ + + /* Even though the flags require DB_DBT_MALLOC, data is not always + allocated. 4.4: allocated, 4.5: *not* allocated. :-( */ + if (data.data != orig_data) + FREE_DBT(data); } FREE_DBT(key); Modified: python/branches/py3k-struni/Modules/_ctypes/_ctypes.c ============================================================================== --- python/branches/py3k-struni/Modules/_ctypes/_ctypes.c (original) +++ python/branches/py3k-struni/Modules/_ctypes/_ctypes.c Wed Jun 13 20:07:49 2007 @@ -789,7 +789,7 @@ CharArray_set_value(CDataObject *self, PyObject *value) { char *ptr; - int size; + Py_ssize_t size; if (PyUnicode_Check(value)) { value = PyUnicode_AsEncodedString(value, @@ -844,7 +844,7 @@ static int WCharArray_set_value(CDataObject *self, PyObject *value) { - int result = 0; + Py_ssize_t result = 0; if (PyString_Check(value)) { value = PyUnicode_FromEncodedObject(value, @@ -868,14 +868,12 @@ result = PyUnicode_AsWideChar((PyUnicodeObject *)value, (wchar_t *)self->b_ptr, self->b_size/sizeof(wchar_t)); - if (result >= 0 && (unsigned)result < self->b_size/sizeof(wchar_t)) + if (result >= 0 && (size_t)result < self->b_size/sizeof(wchar_t)) ((wchar_t *)self->b_ptr)[result] = (wchar_t)0; - if (result > 0) - result = 0; done: Py_DECREF(value); - return result; + return result >= 0 ? 0 : -1; } static PyGetSetDef WCharArray_getsets[] = { @@ -966,7 +964,7 @@ PyObject *typedict; int length; - int itemsize, itemalign; + Py_ssize_t itemsize, itemalign; typedict = PyTuple_GetItem(args, 2); if (!typedict) @@ -1737,8 +1735,8 @@ converters_from_argtypes(PyObject *ob) { PyObject *converters; - int i; - int nArgs; + Py_ssize_t i; + Py_ssize_t nArgs; ob = PySequence_Tuple(ob); /* new reference */ if (!ob) { @@ -1771,7 +1769,12 @@ Py_XDECREF(converters); Py_DECREF(ob); PyErr_Format(PyExc_TypeError, - "item %d in _argtypes_ has no from_param method", i+1); +#if (PY_VERSION_HEX < 0x02050000) + "item %d in _argtypes_ has no from_param method", +#else + "item %zd in _argtypes_ has no from_param method", +#endif + i+1); return NULL; } @@ -2591,18 +2594,18 @@ #ifdef MS_WIN32 static PPROC FindAddress(void *handle, char *name, PyObject *type) { +#ifdef MS_WIN64 + /* win64 has no stdcall calling conv, so it should + also not have the name mangling of it. + */ + return (PPROC)GetProcAddress(handle, name); +#else PPROC address; char *mangled_name; int i; StgDictObject *dict; address = (PPROC)GetProcAddress(handle, name); -#ifdef _WIN64 - /* win64 has no stdcall calling conv, so it should - also not have the name mangling of it. - */ - return address; -#else if (address) return address; if (((size_t)name & ~0xFFFF) == 0) { @@ -2634,7 +2637,7 @@ /* Return 1 if usable, 0 else and exception set. */ static int -_check_outarg_type(PyObject *arg, int index) +_check_outarg_type(PyObject *arg, Py_ssize_t index) { StgDictObject *dict; @@ -2655,7 +2658,7 @@ PyErr_Format(PyExc_TypeError, "'out' parameter %d must be a pointer type, not %s", - index, + Py_SAFE_DOWNCAST(index, Py_ssize_t, int), PyType_Check(arg) ? ((PyTypeObject *)arg)->tp_name : arg->ob_type->tp_name); @@ -2666,7 +2669,7 @@ static int _validate_paramflags(PyTypeObject *type, PyObject *paramflags) { - int i, len; + Py_ssize_t i, len; StgDictObject *dict; PyObject *argtypes; @@ -3051,12 +3054,12 @@ PyObject *paramflags = self->paramflags; PyObject *callargs; StgDictObject *dict; - int i, len; + Py_ssize_t i, len; int inargs_index = 0; /* It's a little bit difficult to determine how many arguments the function call requires/accepts. For simplicity, we count the consumed args and compare this to the number of supplied args. */ - int actual_args; + Py_ssize_t actual_args; *poutmask = 0; *pinoutmask = 0; @@ -3093,7 +3096,7 @@ /* This way seems to be ~2 us faster than the PyArg_ParseTuple calls below. */ /* We HAVE already checked that the tuple can be parsed with "i|zO", so... */ - int tsize = PyTuple_GET_SIZE(item); + Py_ssize_t tsize = PyTuple_GET_SIZE(item); flag = PyInt_AS_LONG(PyTuple_GET_ITEM(item, 0)); name = tsize > 1 ? PyString_AS_STRING(PyTuple_GET_ITEM(item, 1)) : NULL; defval = tsize > 2 ? PyTuple_GET_ITEM(item, 2) : NULL; @@ -3193,7 +3196,11 @@ message is misleading. See unittests/test_paramflags.py */ PyErr_Format(PyExc_TypeError, +#if (PY_VERSION_HEX < 0x02050000) "call takes exactly %d arguments (%d given)", +#else + "call takes exactly %d arguments (%zd given)", +#endif inargs_index, actual_args); goto error; } @@ -3339,8 +3346,10 @@ return NULL; if (converters) { - int required = PyTuple_GET_SIZE(converters); - int actual = PyTuple_GET_SIZE(callargs); + int required = Py_SAFE_DOWNCAST(PyTuple_GET_SIZE(converters), + Py_ssize_t, int); + int actual = Py_SAFE_DOWNCAST(PyTuple_GET_SIZE(callargs), + Py_ssize_t, int); if ((dict->flags & FUNCFLAG_CDECL) == FUNCFLAG_CDECL) { /* For cdecl functions, we allow more actual arguments @@ -3679,8 +3688,8 @@ static int Array_init(CDataObject *self, PyObject *args, PyObject *kw) { - int i; - int n; + Py_ssize_t i; + Py_ssize_t n; if (!PyTuple_Check(args)) { PyErr_SetString(PyExc_TypeError, @@ -3701,7 +3710,7 @@ Array_item(PyObject *_self, Py_ssize_t index) { CDataObject *self = (CDataObject *)_self; - int offset, size; + Py_ssize_t offset, size; StgDictObject *stgdict; @@ -3773,7 +3782,7 @@ Array_ass_item(PyObject *_self, Py_ssize_t index, PyObject *value) { CDataObject *self = (CDataObject *)_self; - int size, offset; + Py_ssize_t size, offset; StgDictObject *stgdict; char *ptr; @@ -3802,7 +3811,7 @@ Array_ass_slice(PyObject *_self, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *value) { CDataObject *self = (CDataObject *)_self; - int i, len; + Py_ssize_t i, len; if (value == NULL) { PyErr_SetString(PyExc_TypeError, @@ -4163,7 +4172,7 @@ Pointer_item(PyObject *_self, Py_ssize_t index) { CDataObject *self = (CDataObject *)_self; - int size; + Py_ssize_t size; Py_ssize_t offset; StgDictObject *stgdict, *itemdict; PyObject *proto; @@ -4194,7 +4203,7 @@ Pointer_ass_item(PyObject *_self, Py_ssize_t index, PyObject *value) { CDataObject *self = (CDataObject *)_self; - int size; + Py_ssize_t size; Py_ssize_t offset; StgDictObject *stgdict, *itemdict; PyObject *proto; @@ -4627,9 +4636,10 @@ static PyObject * wstring_at(const wchar_t *ptr, int size) { - if (size == -1) - size = wcslen(ptr); - return PyUnicode_FromWideChar(ptr, size); + Py_ssize_t ssize = size; + if (ssize == -1) + ssize = wcslen(ptr); + return PyUnicode_FromWideChar(ptr, ssize); } #endif @@ -4829,7 +4839,7 @@ return (PyObject *)unicode; } -int My_PyUnicode_AsWideChar(PyUnicodeObject *unicode, +Py_ssize_t My_PyUnicode_AsWideChar(PyUnicodeObject *unicode, register wchar_t *w, Py_ssize_t size) { Modified: python/branches/py3k-struni/Modules/_ctypes/callbacks.c ============================================================================== --- python/branches/py3k-struni/Modules/_ctypes/callbacks.c (original) +++ python/branches/py3k-struni/Modules/_ctypes/callbacks.c Wed Jun 13 20:07:49 2007 @@ -124,10 +124,10 @@ PyObject *converters, void **pArgs) { - int i; + Py_ssize_t i; PyObject *result; PyObject *arglist = NULL; - int nArgs; + Py_ssize_t nArgs; #ifdef WITH_THREAD PyGILState_STATE state = PyGILState_Ensure(); #endif @@ -265,7 +265,7 @@ { int result; ffi_info *p; - int nArgs, i; + Py_ssize_t nArgs, i; ffi_abi cc; nArgs = PySequence_Size(converters); @@ -308,7 +308,8 @@ if (is_cdecl == 0) cc = FFI_STDCALL; #endif - result = ffi_prep_cif(&p->cif, cc, nArgs, + result = ffi_prep_cif(&p->cif, cc, + Py_SAFE_DOWNCAST(nArgs, Py_ssize_t, int), GetType(restype), &p->atypes[0]); if (result != FFI_OK) { Modified: python/branches/py3k-struni/Modules/_ctypes/callproc.c ============================================================================== --- python/branches/py3k-struni/Modules/_ctypes/callproc.c (original) +++ python/branches/py3k-struni/Modules/_ctypes/callproc.c Wed Jun 13 20:07:49 2007 @@ -361,13 +361,13 @@ case 'z': case 'Z': case 'P': - sprintf(buffer, "", - self->tag, (long)self->value.p); + sprintf(buffer, "", + self->tag, self->value.p); break; default: - sprintf(buffer, "", - self->tag, (long)self); + sprintf(buffer, "", + self->tag, self); break; } return PyUnicode_FromString(buffer); @@ -464,7 +464,7 @@ /* * Convert a single Python object into a PyCArgObject and return it. */ -static int ConvParam(PyObject *obj, int index, struct argument *pa) +static int ConvParam(PyObject *obj, Py_ssize_t index, struct argument *pa) { StgDictObject *dict; pa->keep = NULL; /* so we cannot forget it later */ @@ -566,7 +566,8 @@ return result; } PyErr_Format(PyExc_TypeError, - "Don't know how to convert parameter %d", index); + "Don't know how to convert parameter %d", + Py_SAFE_DOWNCAST(index, Py_ssize_t, int)); return -1; } } @@ -906,7 +907,7 @@ PyObject *restype, PyObject *checker) { - int i, n, argcount, argtype_count; + Py_ssize_t i, n, argcount, argtype_count; void *resbuf; struct argument *args, *pa; ffi_type **atypes; @@ -996,7 +997,10 @@ } if (-1 == _call_function_pointer(flags, pProc, avalues, atypes, - rtype, resbuf, argcount)) + rtype, resbuf, + Py_SAFE_DOWNCAST(argcount, + Py_ssize_t, + int))) goto cleanup; #ifdef WORDS_BIGENDIAN @@ -1036,6 +1040,15 @@ return retval; } +static int +_parse_voidp(PyObject *obj, void **address) +{ + *address = PyLong_AsVoidPtr(obj); + if (*address == NULL) + return 0; + return 1; +} + #ifdef MS_WIN32 #ifdef _UNICODE @@ -1123,7 +1136,7 @@ static PyObject *free_library(PyObject *self, PyObject *args) { void *hMod; - if (!PyArg_ParseTuple(args, PY_VOID_P_CODE ":FreeLibrary", &hMod)) + if (!PyArg_ParseTuple(args, "O&:FreeLibrary", &_parse_voidp, &hMod)) return NULL; if (!FreeLibrary((HMODULE)hMod)) return PyErr_SetFromWindowsErr(GetLastError()); @@ -1246,7 +1259,7 @@ { void *handle; - if (!PyArg_ParseTuple(args, PY_VOID_P_CODE ":dlclose", &handle)) + if (!PyArg_ParseTuple(args, "O&:dlclose", &_parse_voidp, &handle)) return NULL; if (dlclose(handle)) { PyErr_SetString(PyExc_OSError, @@ -1263,7 +1276,8 @@ void *handle; void *ptr; - if (!PyArg_ParseTuple(args, PY_VOID_P_CODE "s:dlsym", &handle, &name)) + if (!PyArg_ParseTuple(args, "O&s:dlsym", + &_parse_voidp, &handle, &name)) return NULL; ptr = ctypes_dlsym((void*)handle, name); if (!ptr) { @@ -1288,8 +1302,8 @@ PyObject *result; if (!PyArg_ParseTuple(args, - PY_VOID_P_CODE "O!", - &func, + "O&O!", + &_parse_voidp, &func, &PyTuple_Type, &arguments)) return NULL; @@ -1319,8 +1333,8 @@ PyObject *result; if (!PyArg_ParseTuple(args, - PY_VOID_P_CODE "O!", - &func, + "O&O!", + &_parse_voidp, &func, &PyTuple_Type, &arguments)) return NULL; @@ -1352,10 +1366,10 @@ dict = PyType_stgdict(obj); if (dict) - return PyInt_FromLong(dict->size); + return PyInt_FromSsize_t(dict->size); if (CDataObject_Check(obj)) - return PyInt_FromLong(((CDataObject *)obj)->b_size); + return PyInt_FromSsize_t(((CDataObject *)obj)->b_size); PyErr_SetString(PyExc_TypeError, "this type has no size"); return NULL; @@ -1373,11 +1387,11 @@ dict = PyType_stgdict(obj); if (dict) - return PyInt_FromLong(dict->align); + return PyInt_FromSsize_t(dict->align); dict = PyObject_stgdict(obj); if (dict) - return PyInt_FromLong(dict->align); + return PyInt_FromSsize_t(dict->align); PyErr_SetString(PyExc_TypeError, "no alignment info"); Modified: python/branches/py3k-struni/Modules/_ctypes/cfield.c ============================================================================== --- python/branches/py3k-struni/Modules/_ctypes/cfield.c (original) +++ python/branches/py3k-struni/Modules/_ctypes/cfield.c Wed Jun 13 20:07:49 2007 @@ -35,14 +35,14 @@ * prev_desc points to the type of the previous bitfield, if any. */ PyObject * -CField_FromDesc(PyObject *desc, int index, - int *pfield_size, int bitsize, int *pbitofs, - int *psize, int *poffset, int *palign, +CField_FromDesc(PyObject *desc, Py_ssize_t index, + Py_ssize_t *pfield_size, int bitsize, int *pbitofs, + Py_ssize_t *psize, Py_ssize_t *poffset, Py_ssize_t *palign, int pack, int big_endian) { CFieldObject *self; PyObject *proto; - int size, align, length; + Py_ssize_t size, align, length; SETFUNC setfunc = NULL; GETFUNC getfunc = NULL; StgDictObject *dict; @@ -147,7 +147,7 @@ else align = dict->align; if (align && *poffset % align) { - int delta = align - (*poffset % align); + Py_ssize_t delta = align - (*poffset % align); *psize += delta; *poffset += delta; } @@ -220,21 +220,13 @@ static PyObject * CField_get_offset(PyObject *self, void *data) { -#if (PY_VERSION_HEX < 0x02050000) - return PyInt_FromLong(((CFieldObject *)self)->offset); -#else return PyInt_FromSsize_t(((CFieldObject *)self)->offset); -#endif } static PyObject * CField_get_size(PyObject *self, void *data) { -#if (PY_VERSION_HEX < 0x02050000) - return PyInt_FromLong(((CFieldObject *)self)->size); -#else return PyInt_FromSsize_t(((CFieldObject *)self)->size); -#endif } static PyGetSetDef CField_getset[] = { @@ -268,8 +260,8 @@ CField_repr(CFieldObject *self) { PyObject *result; - int bits = self->size >> 16; - int size = self->size & 0xFFFF; + Py_ssize_t bits = self->size >> 16; + Py_ssize_t size = self->size & 0xFFFF; const char *name; name = ((PyTypeObject *)self->proto)->tp_name; @@ -279,7 +271,7 @@ #if (PY_VERSION_HEX < 0x02050000) "", #else - "", + "", #endif name, self->offset, size, bits); else @@ -287,7 +279,7 @@ #if (PY_VERSION_HEX < 0x02050000) "", #else - "", + "", #endif name, self->offset, size); return result; @@ -519,7 +511,7 @@ */ static PyObject * -b_set(void *ptr, PyObject *value, unsigned size) +b_set(void *ptr, PyObject *value, Py_ssize_t size) { long val; if (get_long(value, &val) < 0) @@ -530,7 +522,7 @@ static PyObject * -b_get(void *ptr, unsigned size) +b_get(void *ptr, Py_ssize_t size) { signed char val = *(signed char *)ptr; GET_BITFIELD(val, size); @@ -538,7 +530,7 @@ } static PyObject * -B_set(void *ptr, PyObject *value, unsigned size) +B_set(void *ptr, PyObject *value, Py_ssize_t size) { unsigned long val; if (get_ulong(value, &val) < 0) @@ -550,7 +542,7 @@ static PyObject * -B_get(void *ptr, unsigned size) +B_get(void *ptr, Py_ssize_t size) { unsigned char val = *(unsigned char *)ptr; GET_BITFIELD(val, size); @@ -558,7 +550,7 @@ } static PyObject * -h_set(void *ptr, PyObject *value, unsigned size) +h_set(void *ptr, PyObject *value, Py_ssize_t size) { long val; short x; @@ -572,7 +564,7 @@ static PyObject * -h_set_sw(void *ptr, PyObject *value, unsigned size) +h_set_sw(void *ptr, PyObject *value, Py_ssize_t size) { long val; short field; @@ -587,7 +579,7 @@ } static PyObject * -h_get(void *ptr, unsigned size) +h_get(void *ptr, Py_ssize_t size) { short val; memcpy(&val, ptr, sizeof(val)); @@ -596,7 +588,7 @@ } static PyObject * -h_get_sw(void *ptr, unsigned size) +h_get_sw(void *ptr, Py_ssize_t size) { short val; memcpy(&val, ptr, sizeof(val)); @@ -606,7 +598,7 @@ } static PyObject * -H_set(void *ptr, PyObject *value, unsigned size) +H_set(void *ptr, PyObject *value, Py_ssize_t size) { unsigned long val; unsigned short x; @@ -619,7 +611,7 @@ } static PyObject * -H_set_sw(void *ptr, PyObject *value, unsigned size) +H_set_sw(void *ptr, PyObject *value, Py_ssize_t size) { unsigned long val; unsigned short field; @@ -635,7 +627,7 @@ static PyObject * -H_get(void *ptr, unsigned size) +H_get(void *ptr, Py_ssize_t size) { unsigned short val; memcpy(&val, ptr, sizeof(val)); @@ -644,7 +636,7 @@ } static PyObject * -H_get_sw(void *ptr, unsigned size) +H_get_sw(void *ptr, Py_ssize_t size) { unsigned short val; memcpy(&val, ptr, sizeof(val)); @@ -654,7 +646,7 @@ } static PyObject * -i_set(void *ptr, PyObject *value, unsigned size) +i_set(void *ptr, PyObject *value, Py_ssize_t size) { long val; int x; @@ -667,7 +659,7 @@ } static PyObject * -i_set_sw(void *ptr, PyObject *value, unsigned size) +i_set_sw(void *ptr, PyObject *value, Py_ssize_t size) { long val; int field; @@ -683,7 +675,7 @@ static PyObject * -i_get(void *ptr, unsigned size) +i_get(void *ptr, Py_ssize_t size) { int val; memcpy(&val, ptr, sizeof(val)); @@ -692,7 +684,7 @@ } static PyObject * -i_get_sw(void *ptr, unsigned size) +i_get_sw(void *ptr, Py_ssize_t size) { int val; memcpy(&val, ptr, sizeof(val)); @@ -704,7 +696,7 @@ #ifdef MS_WIN32 /* short BOOL - VARIANT_BOOL */ static PyObject * -vBOOL_set(void *ptr, PyObject *value, unsigned size) +vBOOL_set(void *ptr, PyObject *value, Py_ssize_t size) { switch (PyObject_IsTrue(value)) { case -1: @@ -719,7 +711,7 @@ } static PyObject * -vBOOL_get(void *ptr, unsigned size) +vBOOL_get(void *ptr, Py_ssize_t size) { return PyBool_FromLong((long)*(short int *)ptr); } @@ -734,7 +726,7 @@ #endif static PyObject * -t_set(void *ptr, PyObject *value, unsigned size) +t_set(void *ptr, PyObject *value, Py_ssize_t size) { switch (PyObject_IsTrue(value)) { case -1: @@ -749,13 +741,13 @@ } static PyObject * -t_get(void *ptr, unsigned size) +t_get(void *ptr, Py_ssize_t size) { return PyBool_FromLong((long)*(BOOL_TYPE *)ptr); } static PyObject * -I_set(void *ptr, PyObject *value, unsigned size) +I_set(void *ptr, PyObject *value, Py_ssize_t size) { unsigned long val; unsigned int x; @@ -768,7 +760,7 @@ } static PyObject * -I_set_sw(void *ptr, PyObject *value, unsigned size) +I_set_sw(void *ptr, PyObject *value, Py_ssize_t size) { unsigned long val; unsigned int field; @@ -783,7 +775,7 @@ static PyObject * -I_get(void *ptr, unsigned size) +I_get(void *ptr, Py_ssize_t size) { unsigned int val; memcpy(&val, ptr, sizeof(val)); @@ -792,7 +784,7 @@ } static PyObject * -I_get_sw(void *ptr, unsigned size) +I_get_sw(void *ptr, Py_ssize_t size) { unsigned int val; memcpy(&val, ptr, sizeof(val)); @@ -802,7 +794,7 @@ } static PyObject * -l_set(void *ptr, PyObject *value, unsigned size) +l_set(void *ptr, PyObject *value, Py_ssize_t size) { long val; long x; @@ -815,7 +807,7 @@ } static PyObject * -l_set_sw(void *ptr, PyObject *value, unsigned size) +l_set_sw(void *ptr, PyObject *value, Py_ssize_t size) { long val; long field; @@ -831,7 +823,7 @@ static PyObject * -l_get(void *ptr, unsigned size) +l_get(void *ptr, Py_ssize_t size) { long val; memcpy(&val, ptr, sizeof(val)); @@ -840,7 +832,7 @@ } static PyObject * -l_get_sw(void *ptr, unsigned size) +l_get_sw(void *ptr, Py_ssize_t size) { long val; memcpy(&val, ptr, sizeof(val)); @@ -850,7 +842,7 @@ } static PyObject * -L_set(void *ptr, PyObject *value, unsigned size) +L_set(void *ptr, PyObject *value, Py_ssize_t size) { unsigned long val; unsigned long x; @@ -863,7 +855,7 @@ } static PyObject * -L_set_sw(void *ptr, PyObject *value, unsigned size) +L_set_sw(void *ptr, PyObject *value, Py_ssize_t size) { unsigned long val; unsigned long field; @@ -879,7 +871,7 @@ static PyObject * -L_get(void *ptr, unsigned size) +L_get(void *ptr, Py_ssize_t size) { unsigned long val; memcpy(&val, ptr, sizeof(val)); @@ -888,7 +880,7 @@ } static PyObject * -L_get_sw(void *ptr, unsigned size) +L_get_sw(void *ptr, Py_ssize_t size) { unsigned long val; memcpy(&val, ptr, sizeof(val)); @@ -899,7 +891,7 @@ #ifdef HAVE_LONG_LONG static PyObject * -q_set(void *ptr, PyObject *value, unsigned size) +q_set(void *ptr, PyObject *value, Py_ssize_t size) { PY_LONG_LONG val; PY_LONG_LONG x; @@ -912,7 +904,7 @@ } static PyObject * -q_set_sw(void *ptr, PyObject *value, unsigned size) +q_set_sw(void *ptr, PyObject *value, Py_ssize_t size) { PY_LONG_LONG val; PY_LONG_LONG field; @@ -927,7 +919,7 @@ } static PyObject * -q_get(void *ptr, unsigned size) +q_get(void *ptr, Py_ssize_t size) { PY_LONG_LONG val; memcpy(&val, ptr, sizeof(val)); @@ -936,7 +928,7 @@ } static PyObject * -q_get_sw(void *ptr, unsigned size) +q_get_sw(void *ptr, Py_ssize_t size) { PY_LONG_LONG val; memcpy(&val, ptr, sizeof(val)); @@ -946,7 +938,7 @@ } static PyObject * -Q_set(void *ptr, PyObject *value, unsigned size) +Q_set(void *ptr, PyObject *value, Py_ssize_t size) { unsigned PY_LONG_LONG val; unsigned PY_LONG_LONG x; @@ -959,7 +951,7 @@ } static PyObject * -Q_set_sw(void *ptr, PyObject *value, unsigned size) +Q_set_sw(void *ptr, PyObject *value, Py_ssize_t size) { unsigned PY_LONG_LONG val; unsigned PY_LONG_LONG field; @@ -974,7 +966,7 @@ } static PyObject * -Q_get(void *ptr, unsigned size) +Q_get(void *ptr, Py_ssize_t size) { unsigned PY_LONG_LONG val; memcpy(&val, ptr, sizeof(val)); @@ -983,7 +975,7 @@ } static PyObject * -Q_get_sw(void *ptr, unsigned size) +Q_get_sw(void *ptr, Py_ssize_t size) { unsigned PY_LONG_LONG val; memcpy(&val, ptr, sizeof(val)); @@ -1000,7 +992,7 @@ static PyObject * -d_set(void *ptr, PyObject *value, unsigned size) +d_set(void *ptr, PyObject *value, Py_ssize_t size) { double x; @@ -1016,7 +1008,7 @@ } static PyObject * -d_get(void *ptr, unsigned size) +d_get(void *ptr, Py_ssize_t size) { double val; memcpy(&val, ptr, sizeof(val)); @@ -1024,7 +1016,7 @@ } static PyObject * -d_set_sw(void *ptr, PyObject *value, unsigned size) +d_set_sw(void *ptr, PyObject *value, Py_ssize_t size) { double x; @@ -1046,7 +1038,7 @@ } static PyObject * -d_get_sw(void *ptr, unsigned size) +d_get_sw(void *ptr, Py_ssize_t size) { #ifdef WORDS_BIGENDIAN return PyFloat_FromDouble(_PyFloat_Unpack8(ptr, 1)); @@ -1056,7 +1048,7 @@ } static PyObject * -f_set(void *ptr, PyObject *value, unsigned size) +f_set(void *ptr, PyObject *value, Py_ssize_t size) { float x; @@ -1072,7 +1064,7 @@ } static PyObject * -f_get(void *ptr, unsigned size) +f_get(void *ptr, Py_ssize_t size) { float val; memcpy(&val, ptr, sizeof(val)); @@ -1080,7 +1072,7 @@ } static PyObject * -f_set_sw(void *ptr, PyObject *value, unsigned size) +f_set_sw(void *ptr, PyObject *value, Py_ssize_t size) { float x; @@ -1102,7 +1094,7 @@ } static PyObject * -f_get_sw(void *ptr, unsigned size) +f_get_sw(void *ptr, Py_ssize_t size) { #ifdef WORDS_BIGENDIAN return PyFloat_FromDouble(_PyFloat_Unpack4(ptr, 1)); @@ -1122,7 +1114,7 @@ Py_DECREF on destruction. Maybe only when b_needsfree is non-zero. */ static PyObject * -O_get(void *ptr, unsigned size) +O_get(void *ptr, Py_ssize_t size) { PyObject *ob = *(PyObject **)ptr; if (ob == NULL) { @@ -1137,7 +1129,7 @@ } static PyObject * -O_set(void *ptr, PyObject *value, unsigned size) +O_set(void *ptr, PyObject *value, Py_ssize_t size) { /* Hm, does the memory block need it's own refcount or not? */ *(PyObject **)ptr = value; @@ -1147,7 +1139,7 @@ static PyObject * -c_set(void *ptr, PyObject *value, unsigned size) +c_set(void *ptr, PyObject *value, Py_ssize_t size) { if (!PyString_Check(value) || (1 != PyString_Size(value))) { PyErr_Format(PyExc_TypeError, @@ -1160,7 +1152,7 @@ static PyObject * -c_get(void *ptr, unsigned size) +c_get(void *ptr, Py_ssize_t size) { return PyString_FromStringAndSize((char *)ptr, 1); } @@ -1168,9 +1160,9 @@ #ifdef CTYPES_UNICODE /* u - a single wchar_t character */ static PyObject * -u_set(void *ptr, PyObject *value, unsigned size) +u_set(void *ptr, PyObject *value, Py_ssize_t size) { - int len; + Py_ssize_t len; if (PyString_Check(value)) { value = PyUnicode_FromEncodedObject(value, @@ -1202,17 +1194,17 @@ static PyObject * -u_get(void *ptr, unsigned size) +u_get(void *ptr, Py_ssize_t size) { return PyUnicode_FromWideChar((wchar_t *)ptr, 1); } /* U - a unicode string */ static PyObject * -U_get(void *ptr, unsigned size) +U_get(void *ptr, Py_ssize_t size) { PyObject *result; - unsigned int len; + Py_ssize_t len; Py_UNICODE *p; size /= sizeof(wchar_t); /* we count character units here, not bytes */ @@ -1240,9 +1232,9 @@ } static PyObject * -U_set(void *ptr, PyObject *value, unsigned length) +U_set(void *ptr, PyObject *value, Py_ssize_t length) { - unsigned int size; + Py_ssize_t size; /* It's easier to calculate in characters than in bytes */ length /= sizeof(wchar_t); @@ -1263,7 +1255,11 @@ size = PyUnicode_GET_SIZE(value); if (size > length) { PyErr_Format(PyExc_ValueError, +#if (PY_VERSION_HEX < 0x02050000) "string too long (%d, maximum length %d)", +#else + "string too long (%zd, maximum length %zd)", +#endif size, length); Py_DECREF(value); return NULL; @@ -1277,9 +1273,10 @@ #endif static PyObject * -s_get(void *ptr, unsigned size) +s_get(void *ptr, Py_ssize_t size) { PyObject *result; + size_t slen; result = PyString_FromString((char *)ptr); if (!result) @@ -1287,7 +1284,8 @@ /* chop off at the first NUL character, if any. * On error, result will be deallocated and set to NULL. */ - size = min(size, strlen(PyString_AS_STRING(result))); + slen = strlen(PyString_AS_STRING(result)); + size = min(size, (Py_ssize_t)slen); if (result->ob_refcnt == 1) { /* shorten the result */ _PyString_Resize(&result, size); @@ -1298,10 +1296,10 @@ } static PyObject * -s_set(void *ptr, PyObject *value, unsigned length) +s_set(void *ptr, PyObject *value, Py_ssize_t length) { char *data; - unsigned size; + Py_ssize_t size; data = PyString_AsString(value); if (!data) @@ -1314,7 +1312,11 @@ ++size; } else if (size > length) { PyErr_Format(PyExc_ValueError, +#if (PY_VERSION_HEX < 0x02050000) "string too long (%d, maximum length %d)", +#else + "string too long (%zd, maximum length %zd)", +#endif size, length); return NULL; } @@ -1324,7 +1326,7 @@ } static PyObject * -z_set(void *ptr, PyObject *value, unsigned size) +z_set(void *ptr, PyObject *value, Py_ssize_t size) { if (value == Py_None) { *(char **)ptr = NULL; @@ -1358,7 +1360,7 @@ } static PyObject * -z_get(void *ptr, unsigned size) +z_get(void *ptr, Py_ssize_t size) { /* XXX What about invalid pointers ??? */ if (*(void **)ptr) { @@ -1379,7 +1381,7 @@ #ifdef CTYPES_UNICODE static PyObject * -Z_set(void *ptr, PyObject *value, unsigned size) +Z_set(void *ptr, PyObject *value, Py_ssize_t size) { if (value == Py_None) { *(wchar_t **)ptr = NULL; @@ -1447,7 +1449,7 @@ } static PyObject * -Z_get(void *ptr, unsigned size) +Z_get(void *ptr, Py_ssize_t size) { wchar_t *p; p = *(wchar_t **)ptr; @@ -1470,7 +1472,7 @@ #ifdef MS_WIN32 static PyObject * -BSTR_set(void *ptr, PyObject *value, unsigned size) +BSTR_set(void *ptr, PyObject *value, Py_ssize_t size) { BSTR bstr; @@ -1494,8 +1496,13 @@ /* create a BSTR from value */ if (value) { + Py_ssize_t size = PyUnicode_GET_SIZE(value); + if ((unsigned) size != size) { + PyErr_SetString(PyExc_ValueError, "String too long for BSTR"); + return NULL; + } bstr = SysAllocStringLen(PyUnicode_AS_UNICODE(value), - PyUnicode_GET_SIZE(value)); + (unsigned)size); Py_DECREF(value); } else bstr = NULL; @@ -1513,7 +1520,7 @@ static PyObject * -BSTR_get(void *ptr, unsigned size) +BSTR_get(void *ptr, Py_ssize_t size) { BSTR p; p = *(BSTR *)ptr; @@ -1530,7 +1537,7 @@ #endif static PyObject * -P_set(void *ptr, PyObject *value, unsigned size) +P_set(void *ptr, PyObject *value, Py_ssize_t size) { void *v; if (value == Py_None) { @@ -1563,7 +1570,7 @@ } static PyObject * -P_get(void *ptr, unsigned size) +P_get(void *ptr, Py_ssize_t size) { if (*(void **)ptr == NULL) { Py_INCREF(Py_None); Modified: python/branches/py3k-struni/Modules/_ctypes/ctypes.h ============================================================================== --- python/branches/py3k-struni/Modules/_ctypes/ctypes.h (original) +++ python/branches/py3k-struni/Modules/_ctypes/ctypes.h Wed Jun 13 20:07:49 2007 @@ -4,6 +4,7 @@ #if (PY_VERSION_HEX < 0x02050000) typedef int Py_ssize_t; +#define PyInt_FromSsize_t PyInt_FromLong #endif #ifndef MS_WIN32 @@ -23,16 +24,10 @@ #define PY_LONG_LONG LONG_LONG #endif -#if SIZEOF_VOID_P == SIZEOF_LONG -#define PY_VOID_P_CODE "k" -#elif defined(HAVE_LONG_LONG) && (SIZEOF_VOID_P == SIZEOF_LONG_LONG) -#define PY_VOID_P_CODE "K" -#endif - typedef struct tagPyCArgObject PyCArgObject; typedef struct tagCDataObject CDataObject; -typedef PyObject *(* GETFUNC)(void *, unsigned size); -typedef PyObject *(* SETFUNC)(void *, PyObject *value, unsigned size); +typedef PyObject *(* GETFUNC)(void *, Py_ssize_t size); +typedef PyObject *(* SETFUNC)(void *, PyObject *value, Py_ssize_t size); typedef PyCArgObject *(* PARAMFUNC)(CDataObject *obj); /* A default buffer in CDataObject, which can be used for small C types. If @@ -137,9 +132,9 @@ extern PyObject * -CField_FromDesc(PyObject *desc, int index, - int *pfield_size, int bitsize, int *pbitofs, - int *psize, int *poffset, int *palign, +CField_FromDesc(PyObject *desc, Py_ssize_t index, + Py_ssize_t *pfield_size, int bitsize, int *pbitofs, + Py_ssize_t *psize, Py_ssize_t *poffset, Py_ssize_t *palign, int pack, int is_big_endian); extern PyObject *CData_AtAddress(PyObject *type, void *buf); @@ -310,7 +305,7 @@ void *p; } value; PyObject *obj; - int size; /* for the 'V' tag */ + Py_ssize_t size; /* for the 'V' tag */ }; extern PyTypeObject PyCArg_Type; @@ -387,7 +382,7 @@ # define PyUnicode_AsWideChar My_PyUnicode_AsWideChar extern PyObject *My_PyUnicode_FromWideChar(const wchar_t *, Py_ssize_t); -extern int My_PyUnicode_AsWideChar(PyUnicodeObject *, wchar_t *, Py_ssize_t); +extern Py_ssize_t My_PyUnicode_AsWideChar(PyUnicodeObject *, wchar_t *, Py_ssize_t); #endif Modified: python/branches/py3k-struni/Modules/_ctypes/libffi/src/x86/ffi.c ============================================================================== --- python/branches/py3k-struni/Modules/_ctypes/libffi/src/x86/ffi.c (original) +++ python/branches/py3k-struni/Modules/_ctypes/libffi/src/x86/ffi.c Wed Jun 13 20:07:49 2007 @@ -174,7 +174,7 @@ /*@out@*/ extended_cif *, unsigned, unsigned, /*@out@*/ unsigned *, - void (*fn)()); + void (*fn)(void)); /*@=declundef@*/ /*@=exportheader@*/ @@ -185,13 +185,13 @@ /*@out@*/ extended_cif *, unsigned, unsigned, /*@out@*/ unsigned *, - void (*fn)()); + void (*fn)(void)); /*@=declundef@*/ /*@=exportheader@*/ #endif /* X86_WIN32 */ void ffi_call(/*@dependent@*/ ffi_cif *cif, - void (*fn)(), + void (*fn)(void), /*@out@*/ void *rvalue, /*@dependent@*/ void **avalue) { @@ -405,7 +405,7 @@ /*@out@*/ extended_cif *, unsigned, unsigned, /*@out@*/ unsigned *, - void (*fn)()); + void (*fn)(void)); #ifdef X86_WIN32 extern void @@ -413,12 +413,12 @@ /*@out@*/ extended_cif *, unsigned, unsigned, /*@out@*/ unsigned *, - void (*fn)()); + void (*fn)(void)); #endif /* X86_WIN32 */ void ffi_raw_call(/*@dependent@*/ ffi_cif *cif, - void (*fn)(), + void (*fn)(void), /*@out@*/ void *rvalue, /*@dependent@*/ ffi_raw *fake_avalue) { Modified: python/branches/py3k-struni/Modules/_ctypes/libffi/src/x86/ffi64.c ============================================================================== --- python/branches/py3k-struni/Modules/_ctypes/libffi/src/x86/ffi64.c (original) +++ python/branches/py3k-struni/Modules/_ctypes/libffi/src/x86/ffi64.c Wed Jun 13 20:07:49 2007 @@ -42,7 +42,7 @@ }; extern void ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags, - void *raddr, void (*fnaddr)(), unsigned ssecount); + void *raddr, void (*fnaddr)(void), unsigned ssecount); /* All reference to register classes here is identical to the code in gcc/config/i386/i386.c. Do *not* change one without the other. */ @@ -339,7 +339,7 @@ } void -ffi_call (ffi_cif *cif, void (*fn)(), void *rvalue, void **avalue) +ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) { enum x86_64_reg_class classes[MAX_CLASSES]; char *stack, *argp; Modified: python/branches/py3k-struni/Modules/_ctypes/stgdict.c ============================================================================== --- python/branches/py3k-struni/Modules/_ctypes/stgdict.c (original) +++ python/branches/py3k-struni/Modules/_ctypes/stgdict.c Wed Jun 13 20:07:49 2007 @@ -50,7 +50,7 @@ StgDict_clone(StgDictObject *dst, StgDictObject *src) { char *d, *s; - int size; + Py_ssize_t size; StgDict_clear(dst); PyMem_Free(dst->ffi_type_pointer.elements); @@ -285,13 +285,13 @@ StructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct) { StgDictObject *stgdict, *basedict; - int len, offset, size, align, i; - int union_size, total_align; - int field_size = 0; + Py_ssize_t len, offset, size, align, i; + Py_ssize_t union_size, total_align; + Py_ssize_t field_size = 0; int bitofs; PyObject *isPacked; int pack = 0; - int ffi_ofs; + Py_ssize_t ffi_ofs; int big_endian; /* HACK Alert: I cannot be bothered to fix ctypes.com, so there has to @@ -402,7 +402,11 @@ if (dict == NULL) { Py_DECREF(pair); PyErr_Format(PyExc_TypeError, +#if (PY_VERSION_HEX < 0x02050000) "second item in _fields_ tuple (index %d) must be a C type", +#else + "second item in _fields_ tuple (index %zd) must be a C type", +#endif i); return -1; } @@ -480,7 +484,9 @@ /* Adjust the size according to the alignment requirements */ size = ((size + total_align - 1) / total_align) * total_align; - stgdict->ffi_type_pointer.alignment = total_align; + stgdict->ffi_type_pointer.alignment = Py_SAFE_DOWNCAST(total_align, + Py_ssize_t, + unsigned short); stgdict->ffi_type_pointer.size = size; stgdict->size = size; Modified: python/branches/py3k-struni/Modules/_sqlite/cache.c ============================================================================== --- python/branches/py3k-struni/Modules/_sqlite/cache.c (original) +++ python/branches/py3k-struni/Modules/_sqlite/cache.c Wed Jun 13 20:07:49 2007 @@ -243,6 +243,7 @@ } template = PyString_FromString("%s <- %s ->%s\n"); if (!template) { + Py_DECREF(fmt_args); return NULL; } display_str = PyString_Format(template, fmt_args); Modified: python/branches/py3k-struni/Modules/_sqlite/module.c ============================================================================== --- python/branches/py3k-struni/Modules/_sqlite/module.c (original) +++ python/branches/py3k-struni/Modules/_sqlite/module.c Wed Jun 13 20:07:49 2007 @@ -287,12 +287,12 @@ /*** Create DB-API Exception hierarchy */ - if (!(pysqlite_Error = PyErr_NewException(MODULE_NAME ".Error", PyExc_StandardError, NULL))) { + if (!(pysqlite_Error = PyErr_NewException(MODULE_NAME ".Error", PyExc_Exception, NULL))) { goto error; } PyDict_SetItemString(dict, "Error", pysqlite_Error); - if (!(pysqlite_Warning = PyErr_NewException(MODULE_NAME ".Warning", PyExc_StandardError, NULL))) { + if (!(pysqlite_Warning = PyErr_NewException(MODULE_NAME ".Warning", PyExc_Exception, NULL))) { goto error; } PyDict_SetItemString(dict, "Warning", pysqlite_Warning); Modified: python/branches/py3k-struni/Modules/_testcapimodule.c ============================================================================== --- python/branches/py3k-struni/Modules/_testcapimodule.c (original) +++ python/branches/py3k-struni/Modules/_testcapimodule.c Wed Jun 13 20:07:49 2007 @@ -726,7 +726,7 @@ e->tv_sec -=1; e->tv_usec += 1000000; } - printf("Test %d: %d.%06ds\n", test, (int)e->tv_sec, e->tv_usec); + printf("Test %d: %d.%06ds\n", test, (int)e->tv_sec, (int)e->tv_usec); } static PyObject * @@ -884,6 +884,10 @@ unsigned long ulong_member; float float_member; double double_member; +#ifdef HAVE_LONG_LONG + PY_LONG_LONG longlong_member; + unsigned PY_LONG_LONG ulonglong_member; +#endif } all_structmembers; typedef struct { @@ -902,23 +906,40 @@ {"T_ULONG", T_ULONG, offsetof(test_structmembers, structmembers.ulong_member), 0, NULL}, {"T_FLOAT", T_FLOAT, offsetof(test_structmembers, structmembers.float_member), 0, NULL}, {"T_DOUBLE", T_DOUBLE, offsetof(test_structmembers, structmembers.double_member), 0, NULL}, +#ifdef HAVE_LONG_LONG + {"T_LONGLONG", T_LONGLONG, offsetof(test_structmembers, structmembers.longlong_member), 0, NULL}, + {"T_ULONGLONG", T_ULONGLONG, offsetof(test_structmembers, structmembers.ulonglong_member), 0, NULL}, +#endif {NULL} }; static PyObject *test_structmembers_new(PyTypeObject *type, PyObject *args, PyObject *kwargs){ static char *keywords[]={"T_BYTE", "T_UBYTE", "T_SHORT", "T_USHORT", "T_INT", "T_UINT", - "T_LONG", "T_ULONG", "T_FLOAT", "T_DOUBLE", NULL}; + "T_LONG", "T_ULONG", "T_FLOAT", "T_DOUBLE", + #ifdef HAVE_LONG_LONG + "T_LONGLONG", "T_ULONGLONG", + #endif + NULL}; + static char *fmt="|bBhHiIlkfd" + #ifdef HAVE_LONG_LONG + "LK" + #endif + ; test_structmembers *ob=PyObject_New(test_structmembers, type); if (ob==NULL) return NULL; memset(&ob->structmembers, 0, sizeof(all_structmembers)); - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|bBhHiIlkfd", keywords, + if (!PyArg_ParseTupleAndKeywords(args, kwargs, fmt, keywords, &ob->structmembers.byte_member, &ob->structmembers.ubyte_member, &ob->structmembers.short_member, &ob->structmembers.ushort_member, &ob->structmembers.int_member, &ob->structmembers.uint_member, &ob->structmembers.long_member, &ob->structmembers.ulong_member, - &ob->structmembers.float_member, &ob->structmembers.double_member)){ + &ob->structmembers.float_member, &ob->structmembers.double_member + #ifdef HAVE_LONG_LONG + ,&ob->structmembers.longlong_member, &ob->structmembers.ulonglong_member + #endif + )){ Py_DECREF(ob); return NULL; } @@ -1001,6 +1022,9 @@ PyModule_AddObject(m, "FLT_MIN", PyFloat_FromDouble(FLT_MIN)); PyModule_AddObject(m, "DBL_MAX", PyFloat_FromDouble(DBL_MAX)); PyModule_AddObject(m, "DBL_MIN", PyFloat_FromDouble(DBL_MIN)); + 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)); Modified: python/branches/py3k-struni/Modules/cjkcodecs/multibytecodec.c ============================================================================== --- python/branches/py3k-struni/Modules/cjkcodecs/multibytecodec.c (original) +++ python/branches/py3k-struni/Modules/cjkcodecs/multibytecodec.c Wed Jun 13 20:07:49 2007 @@ -1220,6 +1220,8 @@ cres = NULL; for (;;) { + int endoffile; + if (sizehint < 0) cres = PyObject_CallMethod(self->stream, (char *)method, NULL); @@ -1245,6 +1247,8 @@ goto errorexit; } + endoffile = (PyString_GET_SIZE(cres) == 0); + if (self->pendingsize > 0) { PyObject *ctr; char *ctrdata; @@ -1272,7 +1276,7 @@ (MultibyteStatefulDecoderContext *)self, &buf)) goto errorexit; - if (rsize == 0 || sizehint < 0) { /* end of file */ + if (endoffile || sizehint < 0) { if (buf.inbuf < buf.inbuf_end && multibytecodec_decerror(self->codec, &self->state, &buf, self->errors, MBERR_TOOFEW)) Modified: python/branches/py3k-struni/Modules/getbuildinfo.c ============================================================================== --- python/branches/py3k-struni/Modules/getbuildinfo.c (original) +++ python/branches/py3k-struni/Modules/getbuildinfo.c Wed Jun 13 20:07:49 2007 @@ -20,7 +20,14 @@ #endif #endif +/* on unix, SVNVERSION is passed on the command line. + * on Windows, the string is interpolated using + * subwcrev.exe + */ +#ifndef SVNVERSION #define SVNVERSION "$WCRANGE$$WCMODS?M:$" +#endif + const char * Py_GetBuildInfo(void) { @@ -39,7 +46,7 @@ { /* the following string can be modified by subwcrev.exe */ static const char svnversion[] = SVNVERSION; - if (!strstr(svnversion, "$")) - return svnversion; /* it was interpolated */ + if (svnversion[0] != '$') + return svnversion; /* it was interpolated, or passed on command line */ return "exported"; } Modified: python/branches/py3k-struni/Modules/socketmodule.c ============================================================================== --- python/branches/py3k-struni/Modules/socketmodule.c (original) +++ python/branches/py3k-struni/Modules/socketmodule.c Wed Jun 13 20:07:49 2007 @@ -361,8 +361,11 @@ #define BTPROTO_L2CAP BLUETOOTH_PROTO_L2CAP #define BTPROTO_RFCOMM BLUETOOTH_PROTO_RFCOMM #define BTPROTO_HCI BLUETOOTH_PROTO_HCI +#define SOL_HCI SOL_HCI_RAW +#define HCI_FILTER SO_HCI_RAW_FILTER #define sockaddr_l2 sockaddr_l2cap #define sockaddr_rc sockaddr_rfcomm +#define hci_dev hci_node #define _BT_L2_MEMB(sa, memb) ((sa)->l2cap_##memb) #define _BT_RC_MEMB(sa, memb) ((sa)->rfcomm_##memb) #define _BT_HCI_MEMB(sa, memb) ((sa)->hci_##memb) @@ -4335,10 +4338,10 @@ PyModule_AddIntConstant(m, "BTPROTO_L2CAP", BTPROTO_L2CAP); PyModule_AddIntConstant(m, "BTPROTO_HCI", BTPROTO_HCI); PyModule_AddIntConstant(m, "SOL_HCI", SOL_HCI); - PyModule_AddIntConstant(m, "HCI_TIME_STAMP", HCI_TIME_STAMP); - PyModule_AddIntConstant(m, "HCI_DATA_DIR", HCI_DATA_DIR); PyModule_AddIntConstant(m, "HCI_FILTER", HCI_FILTER); #if !defined(__FreeBSD__) + PyModule_AddIntConstant(m, "HCI_TIME_STAMP", HCI_TIME_STAMP); + PyModule_AddIntConstant(m, "HCI_DATA_DIR", HCI_DATA_DIR); PyModule_AddIntConstant(m, "BTPROTO_SCO", BTPROTO_SCO); #endif PyModule_AddIntConstant(m, "BTPROTO_RFCOMM", BTPROTO_RFCOMM); Modified: python/branches/py3k-struni/Objects/abstract.c ============================================================================== --- python/branches/py3k-struni/Objects/abstract.c (original) +++ python/branches/py3k-struni/Objects/abstract.c Wed Jun 13 20:07:49 2007 @@ -969,6 +969,22 @@ return PyFloat_FromString(o); } + +PyObject * +PyNumber_ToBase(PyObject *n, int base) +{ + PyObject *res; + PyObject *index = PyNumber_Index(n); + + if (!index) + return NULL; + assert(PyLong_Check(index)); + res = _PyLong_Format(index, base); + Py_DECREF(index); + return res; +} + + /* Operations on sequences */ int Modified: python/branches/py3k-struni/Objects/bufferobject.c ============================================================================== --- python/branches/py3k-struni/Objects/bufferobject.c (original) +++ python/branches/py3k-struni/Objects/bufferobject.c Wed Jun 13 20:07:49 2007 @@ -19,7 +19,7 @@ READ_BUFFER, WRITE_BUFFER, CHAR_BUFFER, - ANY_BUFFER, + ANY_BUFFER }; static int Modified: python/branches/py3k-struni/Objects/exceptions.c ============================================================================== --- python/branches/py3k-struni/Objects/exceptions.c (original) +++ python/branches/py3k-struni/Objects/exceptions.c Wed Jun 13 20:07:49 2007 @@ -314,17 +314,9 @@ /* - * StandardError extends Exception + * TypeError extends Exception */ -SimpleExtendsException(PyExc_Exception, StandardError, - "Base class for all standard Python exceptions that do not represent\n" - "interpreter exiting."); - - -/* - * TypeError extends StandardError - */ -SimpleExtendsException(PyExc_StandardError, TypeError, +SimpleExtendsException(PyExc_Exception, TypeError, "Inappropriate argument type."); @@ -405,14 +397,14 @@ /* - * ImportError extends StandardError + * ImportError extends Exception */ -SimpleExtendsException(PyExc_StandardError, ImportError, +SimpleExtendsException(PyExc_Exception, ImportError, "Import can't find module, or can't find name in module."); /* - * EnvironmentError extends StandardError + * EnvironmentError extends Exception */ /* Where a function has a single filename, such as open() or some @@ -561,7 +553,7 @@ {NULL} }; -ComplexExtendsException(PyExc_StandardError, EnvironmentError, +ComplexExtendsException(PyExc_Exception, EnvironmentError, EnvironmentError, EnvironmentError_dealloc, EnvironmentError_methods, EnvironmentError_members, EnvironmentError_str, @@ -695,16 +687,16 @@ /* - * EOFError extends StandardError + * EOFError extends Exception */ -SimpleExtendsException(PyExc_StandardError, EOFError, +SimpleExtendsException(PyExc_Exception, EOFError, "Read beyond end of file."); /* - * RuntimeError extends StandardError + * RuntimeError extends Exception */ -SimpleExtendsException(PyExc_StandardError, RuntimeError, +SimpleExtendsException(PyExc_Exception, RuntimeError, "Unspecified run-time error."); @@ -715,9 +707,9 @@ "Method or function hasn't been implemented yet."); /* - * NameError extends StandardError + * NameError extends Exception */ -SimpleExtendsException(PyExc_StandardError, NameError, +SimpleExtendsException(PyExc_Exception, NameError, "Name not found globally."); /* @@ -727,14 +719,14 @@ "Local name referenced but not bound to a value."); /* - * AttributeError extends StandardError + * AttributeError extends Exception */ -SimpleExtendsException(PyExc_StandardError, AttributeError, +SimpleExtendsException(PyExc_Exception, AttributeError, "Attribute not found."); /* - * SyntaxError extends StandardError + * SyntaxError extends Exception */ static int @@ -884,7 +876,7 @@ {NULL} /* Sentinel */ }; -ComplexExtendsException(PyExc_StandardError, SyntaxError, SyntaxError, +ComplexExtendsException(PyExc_Exception, SyntaxError, SyntaxError, SyntaxError_dealloc, 0, SyntaxError_members, SyntaxError_str, "Invalid syntax."); @@ -904,9 +896,9 @@ /* - * LookupError extends StandardError + * LookupError extends Exception */ -SimpleExtendsException(PyExc_StandardError, LookupError, +SimpleExtendsException(PyExc_Exception, LookupError, "Base class for lookup errors."); @@ -943,9 +935,9 @@ /* - * ValueError extends StandardError + * ValueError extends Exception */ -SimpleExtendsException(PyExc_StandardError, ValueError, +SimpleExtendsException(PyExc_Exception, ValueError, "Inappropriate argument value (of correct type)."); /* @@ -1558,16 +1550,16 @@ /* - * AssertionError extends StandardError + * AssertionError extends Exception */ -SimpleExtendsException(PyExc_StandardError, AssertionError, +SimpleExtendsException(PyExc_Exception, AssertionError, "Assertion failed."); /* - * ArithmeticError extends StandardError + * ArithmeticError extends Exception */ -SimpleExtendsException(PyExc_StandardError, ArithmeticError, +SimpleExtendsException(PyExc_Exception, ArithmeticError, "Base class for arithmetic errors."); @@ -1593,9 +1585,9 @@ /* - * SystemError extends StandardError + * SystemError extends Exception */ -SimpleExtendsException(PyExc_StandardError, SystemError, +SimpleExtendsException(PyExc_Exception, SystemError, "Internal error in the Python interpreter.\n" "\n" "Please report this to the Python maintainer, along with the traceback,\n" @@ -1603,16 +1595,16 @@ /* - * ReferenceError extends StandardError + * ReferenceError extends Exception */ -SimpleExtendsException(PyExc_StandardError, ReferenceError, +SimpleExtendsException(PyExc_Exception, ReferenceError, "Weak ref proxy used after referent went away."); /* - * MemoryError extends StandardError + * MemoryError extends Exception */ -SimpleExtendsException(PyExc_StandardError, MemoryError, "Out of memory."); +SimpleExtendsException(PyExc_Exception, MemoryError, "Out of memory."); /* Warning category docstrings */ @@ -1725,7 +1717,6 @@ PRE_INIT(BaseException) PRE_INIT(Exception) - PRE_INIT(StandardError) PRE_INIT(TypeError) PRE_INIT(StopIteration) PRE_INIT(GeneratorExit) @@ -1785,7 +1776,6 @@ POST_INIT(BaseException) POST_INIT(Exception) - POST_INIT(StandardError) POST_INIT(TypeError) POST_INIT(StopIteration) POST_INIT(GeneratorExit) Modified: python/branches/py3k-struni/Objects/intobject.c ============================================================================== --- python/branches/py3k-struni/Objects/intobject.c (original) +++ python/branches/py3k-struni/Objects/intobject.c Wed Jun 13 20:07:49 2007 @@ -918,28 +918,6 @@ } static PyObject * -int_oct(PyIntObject *v) -{ - long x = v -> ob_ival; - if (x < 0) - return PyUnicode_FromFormat("-0%lo", -x); - else if (x == 0) - return PyUnicode_FromString("0"); - else - return PyUnicode_FromFormat("0%lo", x); -} - -static PyObject * -int_hex(PyIntObject *v) -{ - long x = v -> ob_ival; - if (x < 0) - return PyUnicode_FromFormat("-0x%lx", -x); - else - return PyUnicode_FromFormat("0x%lx", x); -} - -static PyObject * int_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds); static PyObject * @@ -1064,8 +1042,8 @@ (unaryfunc)int_int, /*nb_int*/ (unaryfunc)int_long, /*nb_long*/ (unaryfunc)int_float, /*nb_float*/ - (unaryfunc)int_oct, /*nb_oct*/ - (unaryfunc)int_hex, /*nb_hex*/ + 0, /*nb_oct*/ /* not in use */ + 0, /*nb_hex*/ /* not in use */ 0, /*nb_inplace_add*/ 0, /*nb_inplace_subtract*/ 0, /*nb_inplace_multiply*/ Modified: python/branches/py3k-struni/Objects/longobject.c ============================================================================== --- python/branches/py3k-struni/Objects/longobject.c (original) +++ python/branches/py3k-struni/Objects/longobject.c Wed Jun 13 20:07:49 2007 @@ -80,7 +80,6 @@ static PyLongObject *mul1(PyLongObject *, wdigit); static PyLongObject *muladd1(PyLongObject *, wdigit, wdigit); static PyLongObject *divrem1(PyLongObject *, digit, digit *); -static PyObject *long_format(PyObject *aa, int base); #define SIGCHECK(PyTryBlock) \ if (--_Py_Ticker < 0) { \ @@ -1384,7 +1383,7 @@ /* Divide long pin, w/ size digits, by non-zero digit n, storing quotient in pout, and returning the remainder. pin and pout point at the LSD. It's OK for pin == pout on entry, which saves oodles of mallocs/frees in - long_format, but that should be done with great care since longs are + _PyLong_Format, but that should be done with great care since longs are immutable. */ static digit @@ -1424,10 +1423,10 @@ /* Convert a long int object to a string, using a given conversion base. Return a string object. - If base is 8 or 16, add the proper prefix '0' or '0x'. */ + If base is 2, 8 or 16, add the proper prefix '0b', '0o' or '0x'. */ -static PyObject * -long_format(PyObject *aa, int base) +PyObject * +_PyLong_Format(PyObject *aa, int base) { register PyLongObject *a = (PyLongObject *)aa; PyObject *str; @@ -1551,14 +1550,18 @@ Py_DECREF(scratch); } - if (base == 8) { - if (size_a != 0) - *--p = '0'; - } - else if (base == 16) { + if (base == 16) { *--p = 'x'; *--p = '0'; } + else if (base == 8) { + *--p = 'o'; + *--p = '0'; + } + else if (base == 2) { + *--p = 'b'; + *--p = '0'; + } else if (base != 10) { *--p = '#'; *--p = '0' + base%10; @@ -1677,9 +1680,9 @@ PyObject * PyLong_FromString(char *str, char **pend, int base) { - int sign = 1; + int sign = 1, error_if_nonzero = 0; char *start, *orig_str = str; - PyLongObject *z; + PyLongObject *z = NULL; PyObject *strobj, *strrepr; Py_ssize_t slen; @@ -1703,10 +1706,21 @@ base = 10; else if (str[1] == 'x' || str[1] == 'X') base = 16; - else + else if (str[1] == 'o' || str[1] == 'O') base = 8; + else if (str[1] == 'b' || str[1] == 'B') + base = 2; + else { + /* "old" (C-style) octal literal, now invalid. + it might still be zero though */ + error_if_nonzero = 1; + base = 10; + } } - if (base == 16 && str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) + if (str[0] == '0' && + ((base == 16 && (str[1] == 'x' || str[1] == 'X')) || + (base == 8 && (str[1] == 'o' || str[1] == 'O')) || + (base == 2 && (str[1] == 'b' || str[1] == 'B')))) str += 2; start = str; @@ -1910,6 +1924,15 @@ } if (z == NULL) return NULL; + if (error_if_nonzero) { + /* reset the base to 0, else the exception message + doesn't make too much sense */ + base = 0; + if (z->ob_size != 0) + goto onError; + /* there might still be other problems, therefore base + remains zero here for the same reason */ + } if (str == start) goto onError; if (sign < 0) @@ -2130,7 +2153,7 @@ static PyObject * long_repr(PyObject *v) { - return long_format(v, 10); + return _PyLong_Format(v, 10); } static int @@ -3489,18 +3512,6 @@ } static PyObject * -long_oct(PyObject *v) -{ - return long_format(v, 8); -} - -static PyObject * -long_hex(PyObject *v) -{ - return long_format(v, 16); -} - -static PyObject * long_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds); static PyObject * @@ -3631,8 +3642,8 @@ long_int, /*nb_int*/ long_long, /*nb_long*/ long_float, /*nb_float*/ - long_oct, /*nb_oct*/ - long_hex, /*nb_hex*/ + 0, /*nb_oct*/ /* not used */ + 0, /*nb_hex*/ /* not used */ 0, /* nb_inplace_add */ 0, /* nb_inplace_subtract */ 0, /* nb_inplace_multiply */ Modified: python/branches/py3k-struni/Objects/stringobject.c ============================================================================== --- python/branches/py3k-struni/Objects/stringobject.c (original) +++ python/branches/py3k-struni/Objects/stringobject.c Wed Jun 13 20:07:49 2007 @@ -3265,7 +3265,7 @@ { const char *e, *p; char *q; - Py_ssize_t i, j; + Py_ssize_t i, j, old_j; PyObject *u; int tabsize = 8; @@ -3273,21 +3273,38 @@ return NULL; /* First pass: determine size of output string */ - i = j = 0; + i = j = old_j = 0; e = PyString_AS_STRING(self) + PyString_GET_SIZE(self); for (p = PyString_AS_STRING(self); p < e; p++) if (*p == '\t') { - if (tabsize > 0) + if (tabsize > 0) { j += tabsize - (j % tabsize); + if (old_j > j) { + PyErr_SetString(PyExc_OverflowError, + "new string is too long"); + return NULL; + } + old_j = j; + } } else { j++; if (*p == '\n' || *p == '\r') { i += j; - j = 0; + old_j = j = 0; + if (i < 0) { + PyErr_SetString(PyExc_OverflowError, + "new string is too long"); + return NULL; + } } } + if ((i + j) < 0) { + PyErr_SetString(PyExc_OverflowError, "new string is too long"); + return NULL; + } + /* Second pass: create output string and fill it */ u = PyString_FromStringAndSize(NULL, i + j); if (!u) @@ -4199,12 +4216,13 @@ result = val->ob_type->tp_str(val); break; case 'o': - result = val->ob_type->tp_as_number->nb_oct(val); + numnondigits = 2; + result = PyNumber_ToBase(val, 8); break; case 'x': case 'X': numnondigits = 2; - result = val->ob_type->tp_as_number->nb_hex(val); + result = PyNumber_ToBase(val, 16); break; default: assert(!"'type' not in [duoxX]"); @@ -4239,32 +4257,16 @@ assert(numdigits > 0); /* Get rid of base marker unless F_ALT */ - if ((flags & F_ALT) == 0) { - /* Need to skip 0x, 0X or 0. */ - int skipped = 0; - switch (type) { - case 'o': - assert(buf[sign] == '0'); - /* If 0 is only digit, leave it alone. */ - if (numdigits > 1) { - skipped = 1; - --numdigits; - } - break; - case 'x': - case 'X': - assert(buf[sign] == '0'); - assert(buf[sign + 1] == 'x'); - skipped = 2; - numnondigits -= 2; - break; - } - if (skipped) { - buf += skipped; - len -= skipped; - if (sign) - buf[0] = '-'; - } + if (((flags & F_ALT) == 0 && + (type == 'o' || type == 'x' || type == 'X'))) { + assert(buf[sign] == '0'); + assert(buf[sign+1] == 'x' || buf[sign+1] == 'X' || + buf[sign+1] == 'o'); + numnondigits -= 2; + buf += 2; + len -= 2; + if (sign) + buf[0] = '-'; assert(len == numnondigits + numdigits); assert(numdigits > 0); } @@ -4333,9 +4335,10 @@ prec = 1; if ((flags & F_ALT) && - (type == 'x' || type == 'X')) { - /* When converting under %#x or %#X, there are a number + (type == 'x' || type == 'X' || type == 'o')) { + /* When converting under %#o, %#x or %#X, there are a number * of issues that cause pain: + * - for %#o, we want a different base marker than C * - when 0 is being converted, the C standard leaves off * the '0x' or '0X', which is inconsistent with other * %#x/%#X conversions and inconsistent with Python's @@ -4363,7 +4366,7 @@ prec, type); } - /* buf = '+'/'-'/'' + '0'/'0x'/'' + '[0-9]'*max(prec, len(x in octal)) + /* buf = '+'/'-'/'' + '0o'/'0x'/'' + '[0-9]'*max(prec, len(x in octal)) * worst case buf = '-0x' + [0-9]*prec, where prec >= 11 */ if (buflen <= 14 || buflen <= (size_t)3 + (size_t)prec) { @@ -4751,7 +4754,8 @@ if (width > len) width--; } - if ((flags & F_ALT) && (c == 'x' || c == 'X')) { + if ((flags & F_ALT) && + (c == 'x' || c == 'X' || c == 'o')) { assert(pbuf[0] == '0'); assert(pbuf[1] == c); if (fill != ' ') { @@ -4774,7 +4778,7 @@ if (sign) *res++ = sign; if ((flags & F_ALT) && - (c == 'x' || c == 'X')) { + (c == 'x' || c == 'X' || c == 'o')) { assert(pbuf[0] == '0'); assert(pbuf[1] == c); *res++ = *pbuf++; Modified: python/branches/py3k-struni/Objects/typeobject.c ============================================================================== --- python/branches/py3k-struni/Objects/typeobject.c (original) +++ python/branches/py3k-struni/Objects/typeobject.c Wed Jun 13 20:07:49 2007 @@ -1,6 +1,7 @@ /* Type object implementation */ #include "Python.h" +#include "frameobject.h" #include "structmember.h" #include @@ -3190,8 +3191,6 @@ COPYNUM(nb_int); COPYNUM(nb_long); COPYNUM(nb_float); - COPYNUM(nb_oct); - COPYNUM(nb_hex); COPYNUM(nb_inplace_add); COPYNUM(nb_inplace_subtract); COPYNUM(nb_inplace_multiply); @@ -4510,8 +4509,6 @@ SLOT0(slot_nb_int, "__int__") SLOT0(slot_nb_long, "__long__") SLOT0(slot_nb_float, "__float__") -SLOT0(slot_nb_oct, "__oct__") -SLOT0(slot_nb_hex, "__hex__") SLOT1(slot_nb_inplace_add, "__iadd__", PyObject *, "O") SLOT1(slot_nb_inplace_subtract, "__isub__", PyObject *, "O") SLOT1(slot_nb_inplace_multiply, "__imul__", PyObject *, "O") @@ -5168,10 +5165,6 @@ "long(x)"), UNSLOT("__float__", nb_float, slot_nb_float, wrap_unaryfunc, "float(x)"), - UNSLOT("__oct__", nb_oct, slot_nb_oct, wrap_unaryfunc, - "oct(x)"), - UNSLOT("__hex__", nb_hex, slot_nb_hex, wrap_unaryfunc, - "hex(x)"), NBSLOT("__index__", nb_index, slot_nb_index, wrap_unaryfunc, "x[y:z] <==> x[y.__index__():z.__index__()]"), IBSLOT("__iadd__", nb_inplace_add, slot_nb_inplace_add, @@ -5834,14 +5827,77 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds) { superobject *su = (superobject *)self; - PyTypeObject *type; + PyTypeObject *type = NULL; PyObject *obj = NULL; PyTypeObject *obj_type = NULL; if (!_PyArg_NoKeywords("super", kwds)) return -1; - if (!PyArg_ParseTuple(args, "O!|O:super", &PyType_Type, &type, &obj)) + if (!PyArg_ParseTuple(args, "|O!O:super", &PyType_Type, &type, &obj)) return -1; + + if (type == NULL) { + /* Call super(), without args -- fill in from __class__ + and first local variable on the stack. */ + PyFrameObject *f = PyThreadState_GET()->frame; + PyCodeObject *co = f->f_code; + int i, n; + if (co == NULL) { + PyErr_SetString(PyExc_SystemError, + "super(): no code object"); + return -1; + } + if (co->co_argcount == 0) { + PyErr_SetString(PyExc_SystemError, + "super(): no arguments"); + return -1; + } + obj = f->f_localsplus[0]; + if (obj == NULL) { + PyErr_SetString(PyExc_SystemError, + "super(): arg[0] deleted"); + return -1; + } + if (co->co_freevars == NULL) + n = 0; + else { + assert(PyTuple_Check(co->co_freevars)); + n = PyTuple_GET_SIZE(co->co_freevars); + } + for (i = 0; i < n; i++) { + PyObject *name = PyTuple_GET_ITEM(co->co_freevars, i); + assert(PyUnicode_Check(name)); + if (!PyUnicode_CompareWithASCIIString(name, + "__class__")) { + PyObject *cell = + f->f_localsplus[co->co_nlocals + i]; + if (cell == NULL || !PyCell_Check(cell)) { + PyErr_SetString(PyExc_SystemError, + "super(): bad __class__ cell"); + return -1; + } + type = (PyTypeObject *) PyCell_GET(cell); + if (type == NULL) { + PyErr_SetString(PyExc_SystemError, + "super(): empty __class__ cell"); + return -1; + } + if (!PyType_Check(type)) { + PyErr_Format(PyExc_SystemError, + "super(): __class__ is not a type (%s)", + type->ob_type->tp_name); + return -1; + } + break; + } + } + if (type == NULL) { + PyErr_SetString(PyExc_SystemError, + "super(): __class__ cell not found"); + return -1; + } + } + if (obj == Py_None) obj = NULL; if (obj != NULL) { @@ -5858,13 +5914,19 @@ } PyDoc_STRVAR(super_doc, +"super() -> same as super(__class__, )\n" "super(type) -> unbound super object\n" "super(type, obj) -> bound super object; requires isinstance(obj, type)\n" "super(type, type2) -> bound super object; requires issubclass(type2, type)\n" "Typical use to call a cooperative superclass method:\n" "class C(B):\n" " def meth(self, arg):\n" -" super(C, self).meth(arg)"); +" super().meth(arg)\n" +"This works for class methods too:\n" +"class C(B):\n" +" @classmethod\n" +" def cmeth(cls, arg):\n" +" super().cmeth(arg)\n"); static int super_traverse(PyObject *self, visitproc visit, void *arg) Modified: python/branches/py3k-struni/Objects/unicodeobject.c ============================================================================== --- python/branches/py3k-struni/Objects/unicodeobject.c (original) +++ python/branches/py3k-struni/Objects/unicodeobject.c Wed Jun 13 20:07:49 2007 @@ -6217,7 +6217,7 @@ Py_UNICODE *e; Py_UNICODE *p; Py_UNICODE *q; - Py_ssize_t i, j; + Py_ssize_t i, j, old_j; PyUnicodeObject *u; int tabsize = 8; @@ -6225,21 +6225,38 @@ return NULL; /* First pass: determine size of output string */ - i = j = 0; + i = j = old_j = 0; e = self->str + self->length; for (p = self->str; p < e; p++) if (*p == '\t') { - if (tabsize > 0) + if (tabsize > 0) { j += tabsize - (j % tabsize); + if (old_j > j) { + PyErr_SetString(PyExc_OverflowError, + "new string is too long"); + return NULL; + } + old_j = j; + } } else { j++; if (*p == '\n' || *p == '\r') { i += j; - j = 0; + old_j = j = 0; + if (i < 0) { + PyErr_SetString(PyExc_OverflowError, + "new string is too long"); + return NULL; + } } } + if ((i + j) < 0) { + PyErr_SetString(PyExc_OverflowError, "new string is too long"); + return NULL; + } + /* Second pass: create output string and fill it */ u = _PyUnicode_New(i + j); if (!u) @@ -7997,9 +8014,10 @@ } if ((flags & F_ALT) && - (type == 'x' || type == 'X')) { - /* When converting under %#x or %#X, there are a number + (type == 'x' || type == 'X' || type == 'o')) { + /* When converting under %#o, %#x or %#X, there are a number * of issues that cause pain: + * - for %#o, we want a different base marker than C * - when 0 is being converted, the C standard leaves off * the '0x' or '0X', which is inconsistent with other * %#x/%#X conversions and inconsistent with Python's @@ -8457,7 +8475,7 @@ if (width > len) width--; } - if ((flags & F_ALT) && (c == 'x' || c == 'X')) { + if ((flags & F_ALT) && (c == 'x' || c == 'X' || c == 'o')) { assert(pbuf[0] == '0'); assert(pbuf[1] == c); if (fill != ' ') { @@ -8479,7 +8497,7 @@ if (fill == ' ') { if (sign) *res++ = sign; - if ((flags & F_ALT) && (c == 'x' || c == 'X')) { + if ((flags & F_ALT) && (c == 'x' || c == 'X' || c == 'o')) { assert(pbuf[0] == '0'); assert(pbuf[1] == c); *res++ = *pbuf++; Modified: python/branches/py3k-struni/PC/os2emx/python25.def ============================================================================== --- python/branches/py3k-struni/PC/os2emx/python25.def (original) +++ python/branches/py3k-struni/PC/os2emx/python25.def Wed Jun 13 20:07:49 2007 @@ -767,7 +767,6 @@ "_PyExc_Fini" "PyExc_BaseException" "PyExc_Exception" - "PyExc_StandardError" "PyExc_TypeError" "PyExc_StopIteration" "PyExc_GeneratorExit" Modified: python/branches/py3k-struni/PC/os2vacpp/python.def ============================================================================== --- python/branches/py3k-struni/PC/os2vacpp/python.def (original) +++ python/branches/py3k-struni/PC/os2vacpp/python.def Wed Jun 13 20:07:49 2007 @@ -30,7 +30,6 @@ PyExc_OSError PyExc_OverflowError PyExc_RuntimeError - PyExc_StandardError PyExc_SyntaxError PyExc_SystemError PyExc_SystemExit Modified: python/branches/py3k-struni/PC/pyconfig.h ============================================================================== --- python/branches/py3k-struni/PC/pyconfig.h (original) +++ python/branches/py3k-struni/PC/pyconfig.h Wed Jun 13 20:07:49 2007 @@ -247,6 +247,9 @@ #define COMPILER "[gcc]" #define hypot _hypot #define PY_LONG_LONG long long +#define PY_LLONG_MIN LLONG_MIN +#define PY_LLONG_MAX LLONG_MAX +#define PY_ULLONG_MAX ULLONG_MAX #endif /* GNUC */ /* ------------------------------------------------------------------------*/ @@ -272,6 +275,9 @@ #define HAVE_LONG_LONG 1 #ifndef PY_LONG_LONG # define PY_LONG_LONG __int64 +# define PY_LLONG_MAX LLONG_MAX +# define PY_LLONG_MIN LLONG_MIN +# define PY_ULLONG_MAX ULLONG_MAX #endif /* For Windows the Python core is in a DLL by default. Test Modified: python/branches/py3k-struni/PCbuild/_bsddb.vcproj ============================================================================== --- python/branches/py3k-struni/PCbuild/_bsddb.vcproj (original) +++ python/branches/py3k-struni/PCbuild/_bsddb.vcproj Wed Jun 13 20:07:49 2007 @@ -213,7 +213,7 @@ done = E_TOKEN; tok_backup(tok, c); return ERRORTOKEN; Modified: python/branches/py3k-struni/Python/ast.c ============================================================================== --- python/branches/py3k-struni/Python/ast.c (original) +++ python/branches/py3k-struni/Python/ast.c Wed Jun 13 20:07:49 2007 @@ -376,10 +376,6 @@ switch (e->kind) { case Attribute_kind: - if (ctx == Store && - !PyUnicode_CompareWithASCIIString(e->v.Attribute.attr, "None")) { - return ast_error(n, "assignment to None"); - } e->v.Attribute.ctx = ctx; break; case Subscript_kind: @@ -600,10 +596,6 @@ assert(TYPE(n) == tfpdef || TYPE(n) == vfpdef); ch = CHILD(n, 0); - if (!strcmp(STR(ch), "None")) { - ast_error(ch, "assignment to None"); - return NULL; - } name = NEW_IDENTIFIER(ch); if (!name) return NULL; @@ -641,10 +633,6 @@ case tfpdef: if (i + 1 < NCH(n) && TYPE(CHILD(n, i + 1)) == EQUAL) { expression = ast_for_expr(c, CHILD(n, i + 2)); - if (!expression) { - ast_error(ch, "assignment to None"); - goto error; - } asdl_seq_SET(kwdefaults, j, expression); i += 2; /* '=' and test */ } @@ -663,10 +651,6 @@ annotation = NULL; } ch = CHILD(ch, 0); - if (!strcmp(STR(ch), "None")) { - ast_error(ch, "assignment to None"); - goto error; - } arg = arg(NEW_IDENTIFIER(ch), annotation, c->c_arena); if (!arg) { ast_error(ch, "expecting name"); @@ -817,10 +801,6 @@ if (res == -1) goto error; i = res; /* res has new position to process */ } - else if (!strcmp(STR(CHILD(ch, 0)), "None")) { - ast_error(CHILD(ch, 0), "assignment to None"); - goto error; - } else { vararg = NEW_IDENTIFIER(CHILD(ch, 0)); if (NCH(ch) > 1) { @@ -841,10 +821,6 @@ case DOUBLESTAR: ch = CHILD(n, i+1); /* tfpdef */ assert(TYPE(ch) == tfpdef || TYPE(ch) == vfpdef); - if (!strcmp(STR(CHILD(ch, 0)), "None")) { - ast_error(CHILD(ch, 0), "assignment to None"); - goto error; - } kwarg = NEW_IDENTIFIER(CHILD(ch, 0)); if (NCH(ch) > 1) { /* there is an annotation on the kwarg */ @@ -971,10 +947,6 @@ name = NEW_IDENTIFIER(CHILD(n, name_i)); if (!name) return NULL; - else if (!strcmp(STR(CHILD(n, name_i)), "None")) { - ast_error(CHILD(n, name_i), "assignment to None"); - return NULL; - } args = ast_for_arguments(c, CHILD(n, name_i + 1)); if (!args) return NULL; @@ -2913,11 +2885,6 @@ REQ(n, classdef); - if (!strcmp(STR(CHILD(n, 1)), "None")) { - ast_error(n, "assignment to None"); - return NULL; - } - if (NCH(n) == 4) { /* class NAME ':' suite */ s = ast_for_suite(c, CHILD(n, 3)); if (!s) @@ -3039,8 +3006,6 @@ #ifndef WITHOUT_COMPLEX imflag = *end == 'j' || *end == 'J'; #endif - if (*end == 'l' || *end == 'L') - return PyLong_FromString((char *)s, (char **)0, 0); if (s[0] == '0') { x = (long) PyOS_strtoul((char *)s, (char **)&end, 0); if (x < 0 && errno == 0) { Modified: python/branches/py3k-struni/Python/bltinmodule.c ============================================================================== --- python/branches/py3k-struni/Python/bltinmodule.c (original) +++ python/branches/py3k-struni/Python/bltinmodule.c Wed Jun 13 20:07:49 2007 @@ -31,7 +31,8 @@ static PyObject * builtin___build_class__(PyObject *self, PyObject *args, PyObject *kwds) { - PyObject *func, *name, *bases, *mkw, *meta, *prep, *ns, *res; + PyObject *func, *name, *bases, *mkw, *meta, *prep, *ns, *cell; + PyObject *cls = NULL; Py_ssize_t nargs, nbases; assert(args != NULL); @@ -112,22 +113,25 @@ return NULL; } } - res = PyObject_CallFunctionObjArgs(func, ns, NULL); - if (res != NULL) { + cell = PyObject_CallFunctionObjArgs(func, ns, NULL); + if (cell != NULL) { PyObject *margs; - Py_DECREF(res); - res = NULL; margs = Py_BuildValue("OOO", name, bases, ns); if (margs != NULL) { - res = PyEval_CallObjectWithKeywords(meta, margs, mkw); + cls = PyEval_CallObjectWithKeywords(meta, margs, mkw); Py_DECREF(margs); } + if (cls != NULL && PyCell_Check(cell)) { + Py_INCREF(cls); + PyCell_SET(cell, cls); + } + Py_DECREF(cell); } Py_DECREF(ns); Py_DECREF(meta); Py_XDECREF(mkw); Py_DECREF(bases); - return res; + return cls; } PyDoc_STRVAR(build_class_doc, @@ -245,6 +249,18 @@ static PyObject * +builtin_bin(PyObject *self, PyObject *v) +{ + return PyNumber_ToBase(v, 2); +} + +PyDoc_STRVAR(bin_doc, +"bin(number) -> string\n\ +\n\ +Return the binary representation of an integer or long integer."); + + +static PyObject * builtin_filter(PyObject *self, PyObject *args) { PyObject *func, *seq, *result, *it, *arg; @@ -1192,24 +1208,7 @@ static PyObject * builtin_hex(PyObject *self, PyObject *v) { - PyNumberMethods *nb; - PyObject *res; - - if ((nb = v->ob_type->tp_as_number) == NULL || - nb->nb_hex == NULL) { - PyErr_SetString(PyExc_TypeError, - "hex() argument can't be converted to hex"); - return NULL; - } - res = (*nb->nb_hex)(v); - if (res && !PyString_Check(res) && !PyUnicode_Check(res)) { - PyErr_Format(PyExc_TypeError, - "__hex__ returned non-string (type %.200s)", - res->ob_type->tp_name); - Py_DECREF(res); - return NULL; - } - return res; + return PyNumber_ToBase(v, 16); } PyDoc_STRVAR(hex_doc, @@ -1392,24 +1391,7 @@ static PyObject * builtin_oct(PyObject *self, PyObject *v) { - PyNumberMethods *nb; - PyObject *res; - - if (v == NULL || (nb = v->ob_type->tp_as_number) == NULL || - nb->nb_oct == NULL) { - PyErr_SetString(PyExc_TypeError, - "oct() argument can't be converted to oct"); - return NULL; - } - res = (*nb->nb_oct)(v); - if (res && !PyString_Check(res) && !PyUnicode_Check(res)) { - PyErr_Format(PyExc_TypeError, - "__oct__ returned non-string (type %.200s)", - res->ob_type->tp_name); - Py_DECREF(res); - return NULL; - } - return res; + return PyNumber_ToBase(v, 8); } PyDoc_STRVAR(oct_doc, @@ -1949,6 +1931,7 @@ {"abs", builtin_abs, METH_O, abs_doc}, {"all", builtin_all, METH_O, all_doc}, {"any", builtin_any, METH_O, any_doc}, + {"bin", builtin_bin, METH_O, bin_doc}, {"chr", builtin_chr, METH_VARARGS, chr_doc}, {"chr8", builtin_chr8, METH_VARARGS, chr8_doc}, {"cmp", builtin_cmp, METH_VARARGS, cmp_doc}, Modified: python/branches/py3k-struni/Python/compile.c ============================================================================== --- python/branches/py3k-struni/Python/compile.c (original) +++ python/branches/py3k-struni/Python/compile.c Wed Jun 13 20:07:49 2007 @@ -373,10 +373,12 @@ while (PyDict_Next(src, &pos, &k, &v)) { /* XXX this should probably be a macro in symtable.h */ + long vi; assert(PyInt_Check(v)); - scope = (PyInt_AS_LONG(v) >> SCOPE_OFFSET) & SCOPE_MASK; + vi = PyInt_AS_LONG(v); + scope = (vi >> SCOPE_OFFSET) & SCOPE_MASK; - if (scope == scope_type || PyInt_AS_LONG(v) & flag) { + if (scope == scope_type || vi & flag) { PyObject *tuple, *item = PyInt_FromLong(i); if (item == NULL) { Py_DECREF(dest); @@ -1125,7 +1127,8 @@ if (!asdl_seq_LEN(stmts)) return 1; st = (stmt_ty)asdl_seq_GET(stmts, 0); - if (compiler_isdocstring(st)) { + if (compiler_isdocstring(st) && Py_OptimizeFlag < 2) { + /* don't generate docstrings if -OO */ i = 1; VISIT(c, expr, st->v.Expr.value); if (!compiler_nameop(c, __doc__, Store)) @@ -1251,7 +1254,8 @@ else /* (reftype == FREE) */ arg = compiler_lookup_arg(c->u->u_freevars, name); if (arg == -1) { - printf("lookup %s in %s %d %d\n" + fprintf(stderr, + "lookup %s in %s %d %d\n" "freevars of %s: %s\n", PyObject_REPR(name), PyString_AS_STRING(c->u->u_name), @@ -1474,7 +1478,6 @@ static int compiler_class(struct compiler *c, stmt_ty s) { - static PyObject *build_class = NULL; static PyObject *locals = NULL; PyCodeObject *co; PyObject *str; @@ -1485,13 +1488,7 @@ if (!compiler_decorators(c, decos)) return 0; - /* initialize statics */ - if (build_class == NULL) { - build_class = PyUnicode_FromString("__build_class__"); - if (build_class == NULL) - return 0; - } if (locals == NULL) { locals = PyUnicode_FromString("__locals__"); if (locals == NULL) @@ -1501,14 +1498,16 @@ /* ultimately generate code for: = __build_class__(, , *, **) where: - is a function/closure created from the class body + is a function/closure created from the class body; + it has a single argument (__locals__) where the dict + (or MutableSequence) representing the locals is passed is the class name is the positional arguments and *varargs argument is the keyword arguments and **kwds argument This borrows from compiler_call. */ - /* 0. Create a fake variable named __locals__ */ + /* 0. Create a fake argument named __locals__ */ ste = PySymtable_Lookup(c->c_st, s); if (ste == NULL) return 0; @@ -1528,11 +1527,11 @@ c->u->u_private = s->v.ClassDef.name; /* force it to have one mandatory argument */ c->u->u_argcount = 1; - /* load the first argument ... */ + /* load the first argument (__locals__) ... */ ADDOP_I(c, LOAD_FAST, 0); /* ... and store it into f_locals */ ADDOP_IN_SCOPE(c, STORE_LOCALS); - /* load __name__ ... */ + /* load (global) __name__ ... */ str = PyUnicode_InternFromString("__name__"); if (!str || !compiler_nameop(c, str, Load)) { Py_XDECREF(str); @@ -1553,8 +1552,24 @@ compiler_exit_scope(c); return 0; } - /* return None */ - ADDOP_O(c, LOAD_CONST, Py_None, consts); + /* return the (empty) __class__ cell */ + str = PyUnicode_InternFromString("__class__"); + if (str == NULL) { + compiler_exit_scope(c); + return 0; + } + i = compiler_lookup_arg(c->u->u_cellvars, str); + Py_DECREF(str); + if (i == -1) { + /* This happens when nobody references the cell */ + PyErr_Clear(); + /* Return None */ + ADDOP_O(c, LOAD_CONST, Py_None, consts); + } + else { + /* Return the cell where to store __class__ */ + ADDOP_I(c, LOAD_CLOSURE, i); + } ADDOP_IN_SCOPE(c, RETURN_VALUE); /* create the code object */ co = assemble(c, 1); @@ -2421,7 +2436,7 @@ return compiler_error(c, "can not assign to __debug__"); } -mangled = _Py_Mangle(c->u->u_private, name); + mangled = _Py_Mangle(c->u->u_private, name); if (!mangled) return 0; @@ -2947,6 +2962,7 @@ static int expr_constant(expr_ty e) { + char *id; switch (e->kind) { case Ellipsis_kind: return 1; @@ -2955,11 +2971,13 @@ case Str_kind: return PyObject_IsTrue(e->v.Str.s); case Name_kind: - /* __debug__ is not assignable, so we can optimize - * it away in if and while statements */ - if (PyUnicode_CompareWithASCIIString(e->v.Name.id, - "__debug__") == 0) - return ! Py_OptimizeFlag; + /* optimize away names that can't be reassigned */ + id = _PyUnicode_AsDefaultEncodedString(e->v.Name.id, NULL); + if (strcmp(id, "True") == 0) return 1; + if (strcmp(id, "False") == 0) return 0; + if (strcmp(id, "None") == 0) return 0; + if (strcmp(id, "__debug__") == 0) + return ! Py_OptimizeFlag; /* fall through */ default: return -1; Modified: python/branches/py3k-struni/Python/mystrtoul.c ============================================================================== --- python/branches/py3k-struni/Python/mystrtoul.c (original) +++ python/branches/py3k-struni/Python/mystrtoul.c Wed Jun 13 20:07:49 2007 @@ -91,7 +91,7 @@ ** This is a general purpose routine for converting ** an ascii string to an integer in an arbitrary base. ** Leading white space is ignored. If 'base' is zero -** it looks for a leading 0, 0x or 0X to tell which +** it looks for a leading 0b, 0o or 0x to tell which ** base. If these are absent it defaults to 10. ** Base must be 0 or between 2 and 36 (inclusive). ** If 'ptr' is non-NULL it will contain a pointer to @@ -110,29 +110,57 @@ while (*str && isspace(Py_CHARMASK(*str))) ++str; - /* check for leading 0 or 0x for auto-base or base 16 */ + /* check for leading 0b, 0o or 0x for auto-base or base 16 */ switch (base) { - case 0: /* look for leading 0, 0x or 0X */ - if (*str == '0') { + case 0: /* look for leading 0b, 0o or 0x */ + if (*str == '0') { + ++str; + if (*str == 'x' || *str == 'X') { ++str; - if (*str == 'x' || *str == 'X') { - ++str; - base = 16; - } - else - base = 8; - } - else - base = 10; - break; - - case 16: /* skip leading 0x or 0X */ - if (*str == '0') { + base = 16; + } else if (*str == 'o' || *str == 'O') { ++str; - if (*str == 'x' || *str == 'X') + base = 8; + } else if (*str == 'b' || *str == 'B') { + ++str; + base = 2; + } else { + /* skip all zeroes... */ + while (*str == '0') + ++str; + while (isspace(Py_CHARMASK(*str))) ++str; + if (ptr) + *ptr = str; + return 0; } - break; + } + else + base = 10; + break; + + /* even with explicit base, skip leading 0? prefix */ + case 16: + if (*str == '0') { + ++str; + if (*str == 'x' || *str == 'X') + ++str; + } + break; + case 8: + if (*str == '0') { + ++str; + if (*str == 'o' || *str == 'O') + ++str; + } + break; + case 2: + if(*str == '0') { + ++str; + if (*str == 'b' || *str == 'B') + ++str; + } + break; } /* catch silly bases */ Modified: python/branches/py3k-struni/Python/peephole.c ============================================================================== --- python/branches/py3k-struni/Python/peephole.c (original) +++ python/branches/py3k-struni/Python/peephole.c Wed Jun 13 20:07:49 2007 @@ -257,6 +257,37 @@ return blocks; } +/* Helper to replace LOAD_NAME None/True/False with LOAD_CONST + Returns: 0 if no change, 1 if change, -1 if error */ +static int +load_global(unsigned char *codestr, Py_ssize_t i, char *name, PyObject *consts) +{ + Py_ssize_t j; + PyObject *obj; + if (name == NULL) + return 0; + if (strcmp(name, "None") == 0) + obj = Py_None; + else if (strcmp(name, "True") == 0) + obj = Py_True; + else if (strcmp(name, "False") == 0) + obj = Py_False; + else + return 0; + for (j = 0; j < PyList_GET_SIZE(consts); j++) { + if (PyList_GET_ITEM(consts, j) == obj) + break; + } + if (j == PyList_GET_SIZE(consts)) { + if (PyList_Append(consts, obj) < 0) + return -1; + } + assert(PyList_GET_ITEM(consts, j) == obj); + codestr[i] = LOAD_CONST; + SETARG(codestr, i, j); + return 1; +} + /* Perform basic peephole optimizations to components of a code object. The consts object should still be in list form to allow new constants to be appended. @@ -302,7 +333,7 @@ /* Avoid situations where jump retargeting could overflow */ assert(PyString_Check(code)); - codelen = PyString_Size(code); + codelen = PyString_GET_SIZE(code); if (codelen > 32700) goto exitUnchanged; @@ -371,25 +402,17 @@ codestr[i+3] = NOP; break; - /* Replace LOAD_GLOBAL/LOAD_NAME None - with LOAD_CONST None */ + /* Replace LOAD_GLOBAL/LOAD_NAME None/True/False + with LOAD_CONST None/True/False */ case LOAD_NAME: case LOAD_GLOBAL: j = GETARG(codestr, i); name = PyString_AsString(PyTuple_GET_ITEM(names, j)); - if (name == NULL || strcmp(name, "None") != 0) + h = load_global(codestr, i, name, consts); + if (h < 0) + goto exitUnchanged; + else if (h == 0) continue; - for (j=0 ; j < PyList_GET_SIZE(consts) ; j++) { - if (PyList_GET_ITEM(consts, j) == Py_None) - break; - } - if (j == PyList_GET_SIZE(consts)) { - if (PyList_Append(consts, Py_None) == -1) - goto exitUnchanged; - } - assert(PyList_GET_ITEM(consts, j) == Py_None); - codestr[i] = LOAD_CONST; - SETARG(codestr, i, j); cumlc = lastlc + 1; break; Modified: python/branches/py3k-struni/Python/structmember.c ============================================================================== --- python/branches/py3k-struni/Python/structmember.c (original) +++ python/branches/py3k-struni/Python/structmember.c Wed Jun 13 20:07:49 2007 @@ -289,31 +289,25 @@ } break; #ifdef HAVE_LONG_LONG - case T_LONGLONG: - if (!PyLong_Check(v)) { - PyErr_BadArgument(); + case T_LONGLONG:{ + PY_LONG_LONG value; + *(PY_LONG_LONG*)addr = value = PyLong_AsLongLong(v); + if ((value == -1) && PyErr_Occurred()) return -1; - } else { - PY_LONG_LONG value; - *(PY_LONG_LONG*)addr = value = PyLong_AsLongLong(v); - if ((value == -1) && PyErr_Occurred()) { - return -1; - } - } - break; - case T_ULONGLONG: - if (!PyLong_Check(v)) { - PyErr_BadArgument(); - return -1; - } else { - unsigned PY_LONG_LONG value; - *(unsigned PY_LONG_LONG*)addr = value = PyLong_AsUnsignedLongLong(v); - if ((value == (unsigned PY_LONG_LONG)-1) && - PyErr_Occurred()) { - return -1; - } - } - break; + break; + } + case T_ULONGLONG:{ + unsigned PY_LONG_LONG value; + /* ??? PyLong_AsLongLong accepts an int, but PyLong_AsUnsignedLongLong + doesn't ??? */ + if (PyLong_Check(v)) + *(unsigned PY_LONG_LONG*)addr = value = PyLong_AsUnsignedLongLong(v); + else + *(unsigned PY_LONG_LONG*)addr = value = PyInt_AsLong(v); + if ((value == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred()) + return -1; + break; + } #endif /* HAVE_LONG_LONG */ default: PyErr_Format(PyExc_SystemError, Modified: python/branches/py3k-struni/Python/symtable.c ============================================================================== --- python/branches/py3k-struni/Python/symtable.c (original) +++ python/branches/py3k-struni/Python/symtable.c Wed Jun 13 20:07:49 2007 @@ -183,7 +183,7 @@ static identifier top = NULL, lambda = NULL, genexpr = NULL, - listcomp = NULL, setcomp = NULL; + listcomp = NULL, setcomp = NULL, __class__ = NULL; #define GET_IDENTIFIER(VAR) \ ((VAR) ? (VAR) : ((VAR) = PyUnicode_InternFromString(# VAR))) @@ -317,7 +317,7 @@ /* Analyze raw symbol information to determine scope of each name. - The next several functions are helpers for PySymtable_Analyze(), + The next several functions are helpers for symtable_analyze(), which determines whether a name is local, global, or free. In addition, it determines which local variables are cell variables; they provide bindings that are used for free variables in enclosed blocks. @@ -464,10 +464,13 @@ Note that the current block's free variables are included in free. That's safe because no name can be free and local in the same scope. + + The 'restrict' argument may be set to a string to restrict the analysis + to the one variable whose name equals that string (e.g. "__class__"). */ static int -analyze_cells(PyObject *scopes, PyObject *free) +analyze_cells(PyObject *scopes, PyObject *free, const char *restrict) { PyObject *name, *v, *v_cell; int success = 0; @@ -484,6 +487,9 @@ continue; if (!PySet_Contains(free, name)) continue; + if (restrict != NULL && + PyUnicode_CompareWithASCIIString(name, restrict)) + continue; /* Replace LOCAL with CELL for this name, and remove from free. It is safe to replace the value of name in the dict, because it will not cause a resize. @@ -589,7 +595,7 @@ } Py_DECREF(v_new); } - /* It's a cell, or already a free variable in this scope */ + /* It's a cell, or already free in this scope */ Py_DECREF(name); continue; } @@ -675,8 +681,7 @@ goto error; } - /* Populate global and bound sets to be passed to children. - */ + /* Populate global and bound sets to be passed to children. */ if (ste->ste_type != ClassBlock) { /* Add function locals to bound set */ if (ste->ste_type == FunctionBlock) { @@ -695,6 +700,14 @@ goto error; Py_DECREF(newglobal); } + else { + /* Special-case __class__ */ + if (!GET_IDENTIFIER(__class__)) + goto error; + assert(PySet_Contains(local, __class__) == 1); + if (PySet_Add(newbound, __class__) < 0) + goto error; + } /* Recursively call analyze_block() on each child block */ for (i = 0; i < PyList_GET_SIZE(ste->ste_children); ++i) { @@ -709,8 +722,12 @@ ste->ste_child_free = 1; } - /* Check if any local variables need to be converted to cell variables */ - if (ste->ste_type == FunctionBlock && !analyze_cells(scopes, newfree)) + /* Check if any local variables must be converted to cell variables */ + if (ste->ste_type == FunctionBlock && !analyze_cells(scopes, newfree, + NULL)) + goto error; + else if (ste->ste_type == ClassBlock && !analyze_cells(scopes, newfree, + "__class__")) goto error; /* Records the results of the analysis in the symbol table entry */ if (!update_symbols(ste->ste_symbols, scopes, bound, newfree, @@ -1027,6 +1044,11 @@ if (!symtable_enter_block(st, s->v.ClassDef.name, ClassBlock, (void *)s, s->lineno)) return 0; + if (!GET_IDENTIFIER(__class__) || + !symtable_add_def(st, __class__, DEF_LOCAL)) { + symtable_exit_block(st, s); + return 0; + } tmp = st->st_private; st->st_private = s->v.ClassDef.name; VISIT_SEQ_IN_BLOCK(st, stmt, s->v.ClassDef.body, s); @@ -1294,6 +1316,14 @@ if (!symtable_add_def(st, e->v.Name.id, e->v.Name.ctx == Load ? USE : DEF_LOCAL)) return 0; + /* Special-case super: it counts as a use of __class__ */ + if (e->v.Name.ctx == Load && + st->st_cur->ste_type == FunctionBlock && + !PyUnicode_CompareWithASCIIString(e->v.Name.id, "super")) { + if (!GET_IDENTIFIER(__class__) || + !symtable_add_def(st, __class__, USE)) + return 0; + } break; /* child nodes of List and Tuple will have expr_context set */ case List_kind: Modified: python/branches/py3k-struni/README ============================================================================== --- python/branches/py3k-struni/README (original) +++ python/branches/py3k-struni/README Wed Jun 13 20:07:49 2007 @@ -666,7 +666,11 @@ News regarding these platforms with more recent Cygwin versions would be appreciated! -AtheOS: From Octavian Cerna : +AtheOS: Official support has been stopped as of Python 2.6. All code will be + removed in Python 2.7 unless a maintainer steps forward for this + platform. + + From Octavian Cerna : Before building: Modified: python/branches/py3k-struni/Tools/i18n/msgfmt.py ============================================================================== --- python/branches/py3k-struni/Tools/i18n/msgfmt.py (original) +++ python/branches/py3k-struni/Tools/i18n/msgfmt.py Wed Jun 13 20:07:49 2007 @@ -83,7 +83,7 @@ voffsets += [l2, o2+valuestart] offsets = koffsets + voffsets output = struct.pack("Iiiiiii", - 0x950412deL, # Magic + 0x950412de, # Magic 0, # Version len(keys), # # of entries 7*4, # start of key index Modified: python/branches/py3k-struni/Tools/pybench/Arithmetic.py ============================================================================== --- python/branches/py3k-struni/Tools/pybench/Arithmetic.py (original) +++ python/branches/py3k-struni/Tools/pybench/Arithmetic.py Wed Jun 13 20:07:49 2007 @@ -476,9 +476,9 @@ for i in range(self.rounds): - a = 2220001L - b = 100001L - c = 30005L + a = 2220001 + b = 100001 + c = 30005 c = a + b c = b + c @@ -504,9 +504,9 @@ c = b / a c = c / b - a = 2220001L - b = 100001L - c = 30005L + a = 2220001 + b = 100001 + c = 30005 c = a + b c = b + c @@ -532,9 +532,9 @@ c = b / a c = c / b - a = 2220001L - b = 100001L - c = 30005L + a = 2220001 + b = 100001 + c = 30005 c = a + b c = b + c @@ -560,9 +560,9 @@ c = b / a c = c / b - a = 2220001L - b = 100001L - c = 30005L + a = 2220001 + b = 100001 + c = 30005 c = a + b c = b + c @@ -588,9 +588,9 @@ c = b / a c = c / b - a = 2220001L - b = 100001L - c = 30005L + a = 2220001 + b = 100001 + c = 30005 c = a + b c = b + c Modified: python/branches/py3k-struni/Tools/pybench/CommandLine.py ============================================================================== --- python/branches/py3k-struni/Tools/pybench/CommandLine.py (original) +++ python/branches/py3k-struni/Tools/pybench/CommandLine.py Wed Jun 13 20:07:49 2007 @@ -82,7 +82,7 @@ else: f = open(name, mode) if 'w' in mode: - os.chmod(name, 0600) + os.chmod(name, 0o600) return f def option_dict(options): Modified: python/branches/py3k-struni/Tools/pybench/Numbers.py ============================================================================== --- python/branches/py3k-struni/Tools/pybench/Numbers.py (original) +++ python/branches/py3k-struni/Tools/pybench/Numbers.py Wed Jun 13 20:07:49 2007 @@ -598,185 +598,185 @@ for i in range(self.rounds): - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L - - 1234567890L < 3456789012345L - 1234567890L > 3456789012345L - 1234567890L == 3456789012345L - 1234567890L > 3456789012345L - 1234567890L < 3456789012345L + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 + + 1234567890 < 3456789012345 + 1234567890 > 3456789012345 + 1234567890 == 3456789012345 + 1234567890 > 3456789012345 + 1234567890 < 3456789012345 def calibrate(self): Modified: python/branches/py3k-struni/Tools/pybench/systimes.py ============================================================================== --- python/branches/py3k-struni/Tools/pybench/systimes.py (original) +++ python/branches/py3k-struni/Tools/pybench/systimes.py Wed Jun 13 20:07:49 2007 @@ -180,9 +180,9 @@ ### Testing def some_workload(): - x = 0L - for i in range(10000000L): - x = x + 1L + x = 0 + for i in range(10000000): + x = x + 1 def test_workload(): print 'Testing systimes() under load conditions' Modified: python/branches/py3k-struni/Tools/scripts/classfix.py ============================================================================== --- python/branches/py3k-struni/Tools/scripts/classfix.py (original) +++ python/branches/py3k-struni/Tools/scripts/classfix.py Wed Jun 13 20:07:49 2007 @@ -129,7 +129,7 @@ # First copy the file's mode to the temp file try: statbuf = os.stat(filename) - os.chmod(tempname, statbuf[ST_MODE] & 07777) + os.chmod(tempname, statbuf[ST_MODE] & 0o7777) except os.error as msg: err('%s: warning: chmod failed (%r)\n' % (tempname, msg)) # Then make a backup of the original file as filename~ Modified: python/branches/py3k-struni/Tools/scripts/fixcid.py ============================================================================== --- python/branches/py3k-struni/Tools/scripts/fixcid.py (original) +++ python/branches/py3k-struni/Tools/scripts/fixcid.py Wed Jun 13 20:07:49 2007 @@ -174,7 +174,7 @@ # First copy the file's mode to the temp file try: statbuf = os.stat(filename) - os.chmod(tempname, statbuf[ST_MODE] & 07777) + os.chmod(tempname, statbuf[ST_MODE] & 0o7777) except os.error as msg: err(tempname + ': warning: chmod failed (' + str(msg) + ')\n') # Then make a backup of the original file as filename~ Modified: python/branches/py3k-struni/Tools/scripts/ftpmirror.py ============================================================================== --- python/branches/py3k-struni/Tools/scripts/ftpmirror.py (original) +++ python/branches/py3k-struni/Tools/scripts/ftpmirror.py Wed Jun 13 20:07:49 2007 @@ -375,7 +375,7 @@ return dirname = os.path.dirname(pathname) if dirname: makedir(dirname) - os.mkdir(pathname, 0777) + os.mkdir(pathname, 0o777) # Write a dictionary to a file in a way that can be read back using # rval() but is still somewhat readable (i.e. not a single long line). Modified: python/branches/py3k-struni/Tools/scripts/linktree.py ============================================================================== --- python/branches/py3k-struni/Tools/scripts/linktree.py (original) +++ python/branches/py3k-struni/Tools/scripts/linktree.py Wed Jun 13 20:07:49 2007 @@ -31,7 +31,7 @@ print oldtree + ': not a directory' return 1 try: - os.mkdir(newtree, 0777) + os.mkdir(newtree, 0o777) except os.error as msg: print newtree + ': cannot mkdir:', msg return 1 @@ -63,7 +63,7 @@ if os.path.isdir(oldname) and \ not os.path.islink(oldname): try: - os.mkdir(newname, 0777) + os.mkdir(newname, 0o777) ok = 1 except: print newname + \ Modified: python/branches/py3k-struni/Tools/scripts/methfix.py ============================================================================== --- python/branches/py3k-struni/Tools/scripts/methfix.py (original) +++ python/branches/py3k-struni/Tools/scripts/methfix.py Wed Jun 13 20:07:49 2007 @@ -140,7 +140,7 @@ # First copy the file's mode to the temp file try: statbuf = os.stat(filename) - os.chmod(tempname, statbuf[ST_MODE] & 07777) + os.chmod(tempname, statbuf[ST_MODE] & 0o7777) except os.error as msg: err('%s: warning: chmod failed (%r)\n' % (tempname, msg)) # Then make a backup of the original file as filename~ Modified: python/branches/py3k-struni/Tools/scripts/pathfix.py ============================================================================== --- python/branches/py3k-struni/Tools/scripts/pathfix.py (original) +++ python/branches/py3k-struni/Tools/scripts/pathfix.py Wed Jun 13 20:07:49 2007 @@ -121,7 +121,7 @@ # First copy the file's mode to the temp file try: statbuf = os.stat(filename) - os.chmod(tempname, statbuf[ST_MODE] & 07777) + os.chmod(tempname, statbuf[ST_MODE] & 0o7777) except os.error as msg: err('%s: warning: chmod failed (%r)\n' % (tempname, msg)) # Then make a backup of the original file as filename~ Modified: python/branches/py3k-struni/Tools/scripts/which.py ============================================================================== --- python/branches/py3k-struni/Tools/scripts/which.py (original) +++ python/branches/py3k-struni/Tools/scripts/which.py Wed Jun 13 20:07:49 2007 @@ -35,7 +35,7 @@ msg(filename + ': not a disk file') else: mode = S_IMODE(st[ST_MODE]) - if mode & 0111: + if mode & 0o111: if not ident: print filename ident = st[:3] Modified: python/branches/py3k-struni/Tools/unicode/makeunicodedata.py ============================================================================== --- python/branches/py3k-struni/Tools/unicode/makeunicodedata.py (original) +++ python/branches/py3k-struni/Tools/unicode/makeunicodedata.py Wed Jun 13 20:07:49 2007 @@ -757,7 +757,7 @@ h = 0 for c in map(ord, s.upper()): h = (h * magic) + c - ix = h & 0xff000000L + ix = h & 0xff000000 if ix: h = (h ^ ((ix>>24) & 0xff)) & 0x00ffffff return h Modified: python/branches/py3k-struni/Tools/webchecker/websucker.py ============================================================================== --- python/branches/py3k-struni/Tools/webchecker/websucker.py (original) +++ python/branches/py3k-struni/Tools/webchecker/websucker.py Wed Jun 13 20:07:49 2007 @@ -119,7 +119,7 @@ print "Huh? Don't know how to make dir", dir return makedirs(head) - os.mkdir(dir, 0777) + os.mkdir(dir, 0o777) if __name__ == '__main__': sys.exit(main() or 0) Modified: python/branches/py3k-struni/configure ============================================================================== --- python/branches/py3k-struni/configure (original) +++ python/branches/py3k-struni/configure Wed Jun 13 20:07:49 2007 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 53610 . +# From configure.in Revision: 54283 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 3.0. # @@ -3753,7 +3753,7 @@ # Check for unsupported systems case $ac_sys_system/$ac_sys_release in -Linux*/1*) +atheos*|Linux*/1*) echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported. echo See README for details. exit 1;; Modified: python/branches/py3k-struni/configure.in ============================================================================== --- python/branches/py3k-struni/configure.in (original) +++ python/branches/py3k-struni/configure.in Wed Jun 13 20:07:49 2007 @@ -450,7 +450,7 @@ # Check for unsupported systems case $ac_sys_system/$ac_sys_release in -Linux*/1*) +atheos*|Linux*/1*) echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported. echo See README for details. exit 1;; Modified: python/branches/py3k-struni/setup.py ============================================================================== --- python/branches/py3k-struni/setup.py (original) +++ python/branches/py3k-struni/setup.py Wed Jun 13 20:07:49 2007 @@ -1486,8 +1486,8 @@ def install(self): outfiles = install_lib.install(self) - self.set_file_modes(outfiles, 0644, 0755) - self.set_dir_modes(self.install_dir, 0755) + self.set_file_modes(outfiles, 0o644, 0o755) + self.set_dir_modes(self.install_dir, 0o755) return outfiles def set_file_modes(self, files, defaultMode, sharedLibMode): From python-3000-checkins at python.org Wed Jun 13 23:51:32 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Wed, 13 Jun 2007 23:51:32 +0200 (CEST) Subject: [Python-3000-checkins] r55964 - in python/branches/py3k-struni/Lib: os.py test/test_os.py Message-ID: <20070613215132.39A0C1E4002@bag.python.org> Author: guido.van.rossum Date: Wed Jun 13 23:51:27 2007 New Revision: 55964 Modified: python/branches/py3k-struni/Lib/os.py python/branches/py3k-struni/Lib/test/test_os.py Log: Following an idea by Ron Adam, make sure keys and values in the environ dict are strings (in particular, not 8-bit strings). Modified: python/branches/py3k-struni/Lib/os.py ============================================================================== --- python/branches/py3k-struni/Lib/os.py (original) +++ python/branches/py3k-struni/Lib/os.py Wed Jun 13 23:51:27 2007 @@ -420,12 +420,12 @@ self.unsetenv = unsetenv self.data = data = {} for key, value in environ.items(): - data[keymap(key)] = value + data[keymap(key)] = str(value) def __getitem__(self, key): return self.data[self.keymap(key)] - def __setitem__(self, key, item): - self.putenv(key, item) - self.data[self.keymap(key)] = item + def __setitem__(self, key, value): + self.putenv(key, str(value)) + self.data[self.keymap(key)] = str(value) def __delitem__(self, key): self.unsetenv(key) del self.data[self.keymap(key)] @@ -438,7 +438,7 @@ return dict(self) def setdefault(self, key, value): if key not in self: - self[key] = value + self[key] = str(value) return self[key] try: @@ -456,9 +456,9 @@ __all__.append("unsetenv") if name in ('os2', 'nt'): # Where Env Var Names Must Be UPPERCASE - _keymap = lambda key: key.upper() + _keymap = lambda key: str(key.upper()) else: # Where Env Var Names Can Be Mixed Case - _keymap = lambda key: key + _keymap = lambda key: str(key) environ = _Environ(environ, _keymap, _putenv, _unsetenv) Modified: python/branches/py3k-struni/Lib/test/test_os.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_os.py (original) +++ python/branches/py3k-struni/Lib/test/test_os.py Wed Jun 13 23:51:27 2007 @@ -273,6 +273,13 @@ value = os.popen("/bin/sh -c 'echo $HELLO'").read().strip() self.assertEquals(value, "World") + # Verify environ keys and values from the OS are of the + # correct str type. + def test_keyvalue_types(self): + for key, val in os.environ.items(): + self.assertEquals(type(key), str) + self.assertEquals(type(val), str) + class WalkTests(unittest.TestCase): """Tests for os.walk().""" From python-3000-checkins at python.org Wed Jun 13 23:52:42 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Wed, 13 Jun 2007 23:52:42 +0200 (CEST) Subject: [Python-3000-checkins] r55965 - python/branches/py3k-struni/Lib/os.py Message-ID: <20070613215242.BCF151E4002@bag.python.org> Author: guido.van.rossum Date: Wed Jun 13 23:52:41 2007 New Revision: 55965 Modified: python/branches/py3k-struni/Lib/os.py Log: Reduce redundant calls to str() in _Environ class. Modified: python/branches/py3k-struni/Lib/os.py ============================================================================== --- python/branches/py3k-struni/Lib/os.py (original) +++ python/branches/py3k-struni/Lib/os.py Wed Jun 13 23:52:41 2007 @@ -424,8 +424,9 @@ def __getitem__(self, key): return self.data[self.keymap(key)] def __setitem__(self, key, value): - self.putenv(key, str(value)) - self.data[self.keymap(key)] = str(value) + value = str(value) + self.putenv(key, value) + self.data[self.keymap(key)] = value def __delitem__(self, key): self.unsetenv(key) del self.data[self.keymap(key)] @@ -438,7 +439,7 @@ return dict(self) def setdefault(self, key, value): if key not in self: - self[key] = str(value) + self[key] = value return self[key] try: From python-3000-checkins at python.org Thu Jun 14 02:03:41 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 14 Jun 2007 02:03:41 +0200 (CEST) Subject: [Python-3000-checkins] r55966 - python/branches/py3k-struni/Lib/abc.py Message-ID: <20070614000341.C95121E4002@bag.python.org> Author: guido.van.rossum Date: Thu Jun 14 02:03:37 2007 New Revision: 55966 Added: python/branches/py3k-struni/Lib/abc.py (contents, props changed) Log: Somehow this needed adding. Added: python/branches/py3k-struni/Lib/abc.py ============================================================================== --- (empty file) +++ python/branches/py3k-struni/Lib/abc.py Thu Jun 14 02:03:37 2007 @@ -0,0 +1,179 @@ +# Copyright 2007 Google, Inc. All Rights Reserved. +# Licensed to PSF under a Contributor Agreement. + +"""Abstract Base Classes (ABCs) according to PEP 3119.""" + + +def abstractmethod(funcobj): + """A decorator indicating abstract methods. + + Requires that the metaclass is ABCMeta or derived from it. A + class that has a metaclass derived from ABCMeta cannot be + instantiated unless all of its abstract methods are overridden. + The abstract methods can be called using any of the the normal + 'super' call mechanisms. + + Usage: + + class C(metaclass=ABCMeta): + @abstractmethod + def my_abstract_method(self, ...): + ... + """ + funcobj.__isabstractmethod__ = True + return funcobj + + +class _Abstract(object): + + """Helper class inserted into the bases by ABCMeta (using _fix_bases()). + + You should never need to explicitly subclass this class. + + There should never be a base class between _Abstract and object. + """ + + def __new__(cls, *args, **kwds): + am = cls.__dict__.get("__abstractmethods__") + if am: + raise TypeError("Can't instantiate abstract class %s " + "with abstract methods %s" % + (cls.__name__, ", ".join(sorted(am)))) + if (args or kwds) and cls.__init__ is object.__init__: + raise TypeError("Can't pass arguments to __new__ " + "without overriding __init__") + return object.__new__(cls) + + @classmethod + def __subclasshook__(cls, subclass): + """Abstract classes can override this to customize issubclass(). + + This is invoked early on by __subclasscheck__() below. It + should return True, False or NotImplemented. If it returns + NotImplemented, the normal algorithm is used. Otherwise, it + overrides the normal algorithm (and the outcome is cached). + """ + return NotImplemented + + +def _fix_bases(bases): + """Helper method that inserts _Abstract in the bases if needed.""" + for base in bases: + if issubclass(base, _Abstract): + # _Abstract is already a base (maybe indirectly) + return bases + if object in bases: + # Replace object with _Abstract + return tuple([_Abstract if base is object else base + for base in bases]) + # Append _Abstract to the end + return bases + (_Abstract,) + + +class ABCMeta(type): + + """Metaclass for defining Abstract Base Classes (ABCs). + + Use this metaclass to create an ABC. An ABC can be subclassed + directly, and then acts as a mix-in class. You can also register + unrelated concrete classes (even built-in classes) and unrelated + ABCs as 'virtual subclasses' -- these and their descendants will + be considered subclasses of the registering ABC by the built-in + issubclass() function, but the registering ABC won't show up in + their MRO (Method Resolution Order) nor will method + implementations defined by the registering ABC be callable (not + even via super()). + + """ + + # A global counter that is incremented each time a class is + # registered as a virtual subclass of anything. It forces the + # negative cache to be cleared before its next use. + __invalidation_counter = 0 + + def __new__(mcls, name, bases, namespace): + bases = _fix_bases(bases) + cls = super(ABCMeta, mcls).__new__(mcls, name, bases, namespace) + # Compute set of abstract method names + abstracts = {name + for name, value in namespace.items() + if getattr(value, "__isabstractmethod__", False)} + for base in bases: + for name in getattr(base, "__abstractmethods__", set()): + value = getattr(cls, name, None) + if getattr(value, "__isabstractmethod__", False): + abstracts.add(name) + cls.__abstractmethods__ = abstracts + # Set up inheritance registry + cls.__registry = set() + cls.__cache = set() + cls.__negative_cache = set() + cls.__negative_cache_version = ABCMeta.__invalidation_counter + return cls + + def register(cls, subclass): + """Register a virtual subclass of an ABC.""" + if not isinstance(cls, type): + raise TypeError("Can only register classes") + if issubclass(subclass, cls): + return # Already a subclass + # Subtle: test for cycles *after* testing for "already a subclass"; + # this means we allow X.register(X) and interpret it as a no-op. + if issubclass(cls, subclass): + # This would create a cycle, which is bad for the algorithm below + raise RuntimeError("Refusing to create an inheritance cycle") + cls.__registry.add(subclass) + ABCMeta.__invalidation_counter += 1 # Invalidate negative cache + + def _dump_registry(cls, file=None): + """Debug helper to print the ABC registry.""" + print("Class: %s.%s" % (cls.__module__, cls.__name__), file=file) + print("Inv.counter: %s" % ABCMeta.__invalidation_counter, file=file) + for name in sorted(cls.__dict__.keys()): + if name.startswith("__abc_"): + value = getattr(cls, name) + print("%s: %r" % (name, value), file=file) + + def __instancecheck__(cls, instance): + """Override for isinstance(instance, cls).""" + return any(cls.__subclasscheck__(c) + for c in {instance.__class__, type(instance)}) + + def __subclasscheck__(cls, subclass): + """Override for issubclass(subclass, cls).""" + # Check cache + if subclass in cls.__cache: + return True + # Check negative cache; may have to invalidate + if cls.__negative_cache_version < ABCMeta.__invalidation_counter: + # Invalidate the negative cache + cls.__negative_cache_version = ABCMeta.__invalidation_counter + cls.__negative_cache = set() + elif subclass in cls.__negative_cache: + return False + # Check the subclass hook + ok = cls.__subclasshook__(subclass) + if ok is not NotImplemented: + assert isinstance(ok, bool) + if ok: + cls.__cache.add(subclass) + else: + cls.__negative_cache.add(subclass) + return ok + # Check if it's a direct subclass + if cls in subclass.__mro__: + cls.__cache.add(subclass) + return True + # Check if it's a subclass of a registered class (recursive) + for rcls in cls.__registry: + if issubclass(subclass, rcls): + cls.__registry.add(subclass) + return True + # Check if it's a subclass of a subclass (recursive) + for scls in cls.__subclasses__(): + if issubclass(subclass, scls): + cls.__registry.add(subclass) + return True + # No dice; update negative cache + cls.__negative_cache.add(subclass) + return False From python-3000-checkins at python.org Thu Jun 14 02:04:48 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 14 Jun 2007 02:04:48 +0200 (CEST) Subject: [Python-3000-checkins] r55967 - python/branches/py3k-struni/Lib/test/string_tests.py python/branches/py3k-struni/Lib/test/test_str.py python/branches/py3k-struni/Lib/test/test_unicode.py python/branches/py3k-struni/Lib/test/test_userstring.py Message-ID: <20070614000448.417451E4002@bag.python.org> Author: guido.van.rossum Date: Thu Jun 14 02:04:46 2007 New Revision: 55967 Modified: python/branches/py3k-struni/Lib/test/string_tests.py python/branches/py3k-struni/Lib/test/test_str.py python/branches/py3k-struni/Lib/test/test_unicode.py python/branches/py3k-struni/Lib/test/test_userstring.py Log: Fix some tests by deleting stuff. Modified: python/branches/py3k-struni/Lib/test/string_tests.py ============================================================================== --- python/branches/py3k-struni/Lib/test/string_tests.py (original) +++ python/branches/py3k-struni/Lib/test/string_tests.py Thu Jun 14 02:04:46 2007 @@ -1096,58 +1096,6 @@ self.checkraises(TypeError, S, 'rpartition', None) -class MixinStrStringUserStringTest: - # Additional tests for 8bit strings, i.e. str, UserString and - # the string module - - def test_maketrans(self): - self.assertEqual( - ''.join(map(chr, range(256))).replace('abc', 'xyz'), - string.maketrans('abc', 'xyz') - ) - self.assertRaises(ValueError, string.maketrans, 'abc', 'xyzw') - - def test_translate(self): - table = string.maketrans('abc', 'xyz') - self.checkequal('xyzxyz', 'xyzabcdef', 'translate', table, 'def') - - table = string.maketrans('a', 'A') - self.checkequal('Abc', 'abc', 'translate', table) - self.checkequal('xyz', 'xyz', 'translate', table) - self.checkequal('yz', 'xyz', 'translate', table, 'x') - self.checkequal('yx', 'zyzzx', 'translate', None, 'z') - self.checkequal('zyzzx', 'zyzzx', 'translate', None, '') - self.checkequal('zyzzx', 'zyzzx', 'translate', None) - self.checkraises(ValueError, 'xyz', 'translate', 'too short', 'strip') - self.checkraises(ValueError, 'xyz', 'translate', 'too short') - - -class MixinStrUserStringTest: - # Additional tests that only work with - # 8bit compatible object, i.e. str and UserString - - def test_encoding_decoding(self): - codecs = [('rot13', b'uryyb jbeyq'), - ('base64', b'aGVsbG8gd29ybGQ=\n'), - ('hex', b'68656c6c6f20776f726c64'), - ('uu', b'begin 666 \n+:&5L;&\\@=V]R;&0 \n \nend\n')] - for encoding, data in codecs: - self.checkequal(data, 'hello world', 'encode', encoding) - self.checkequal('hello world', data, 'decode', encoding) - # zlib is optional, so we make the test optional too... - try: - import zlib - except ImportError: - pass - else: - data = b'x\x9c\xcbH\xcd\xc9\xc9W(\xcf/\xcaI\x01\x00\x1a\x0b\x04]' - self.checkequal(data, 'hello world', 'encode', 'zlib') - self.checkequal('hello world', data, 'decode', 'zlib') - - self.checkraises(TypeError, 'xyz', 'decode', 42) - self.checkraises(TypeError, 'xyz', 'encode', 42) - - class MixinStrUnicodeTest: # Additional tests that only work with str and unicode. Modified: python/branches/py3k-struni/Lib/test/test_str.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_str.py (original) +++ python/branches/py3k-struni/Lib/test/test_str.py Thu Jun 14 02:04:46 2007 @@ -8,7 +8,6 @@ class StrTest( string_tests.CommonTest, string_tests.MixinStrUnicodeUserStringTest, - string_tests.MixinStrUserStringTest, string_tests.MixinStrUnicodeTest, ): Modified: python/branches/py3k-struni/Lib/test/test_unicode.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_unicode.py (original) +++ python/branches/py3k-struni/Lib/test/test_unicode.py Thu Jun 14 02:04:46 2007 @@ -791,7 +791,7 @@ # to take a 64-bit long, this test should apply to all platforms. if sys.maxint > (1 << 32) or struct.calcsize('P') != 4: return - self.assertRaises(OverflowError, u't\tt\t'.expandtabs, sys.maxint) + self.assertRaises(OverflowError, 't\tt\t'.expandtabs, sys.maxint) def test_main(): Modified: python/branches/py3k-struni/Lib/test/test_userstring.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_userstring.py (original) +++ python/branches/py3k-struni/Lib/test/test_userstring.py Thu Jun 14 02:04:46 2007 @@ -10,8 +10,6 @@ class UserStringTest( string_tests.CommonTest, string_tests.MixinStrUnicodeUserStringTest, - string_tests.MixinStrStringUserStringTest, - string_tests.MixinStrUserStringTest ): type2test = UserString From python-3000-checkins at python.org Thu Jun 14 02:28:05 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 14 Jun 2007 02:28:05 +0200 (CEST) Subject: [Python-3000-checkins] r55968 - python/branches/py3k-struni/Python/compile.c Message-ID: <20070614002805.496911E4002@bag.python.org> Author: guido.van.rossum Date: Thu Jun 14 02:28:01 2007 New Revision: 55968 Modified: python/branches/py3k-struni/Python/compile.c Log: Looks like an oopsie -- I ignored a warning at my peril. Modified: python/branches/py3k-struni/Python/compile.c ============================================================================== --- python/branches/py3k-struni/Python/compile.c (original) +++ python/branches/py3k-struni/Python/compile.c Thu Jun 14 02:28:01 2007 @@ -2972,7 +2972,8 @@ return PyObject_IsTrue(e->v.Str.s); case Name_kind: /* optimize away names that can't be reassigned */ - id = _PyUnicode_AsDefaultEncodedString(e->v.Name.id, NULL); + id = PyString_AS_STRING( + _PyUnicode_AsDefaultEncodedString(e->v.Name.id, NULL)); if (strcmp(id, "True") == 0) return 1; if (strcmp(id, "False") == 0) return 0; if (strcmp(id, "None") == 0) return 0; From python-3000-checkins at python.org Thu Jun 14 02:29:49 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 14 Jun 2007 02:29:49 +0200 (CEST) Subject: [Python-3000-checkins] r55969 - python/branches/py3k-struni/Modules/cjkcodecs/multibytecodec.c Message-ID: <20070614002949.503941E4003@bag.python.org> Author: guido.van.rossum Date: Thu Jun 14 02:29:43 2007 New Revision: 55969 Modified: python/branches/py3k-struni/Modules/cjkcodecs/multibytecodec.c Log: Fix another issue likely introduced by the merge. Modified: python/branches/py3k-struni/Modules/cjkcodecs/multibytecodec.c ============================================================================== --- python/branches/py3k-struni/Modules/cjkcodecs/multibytecodec.c (original) +++ python/branches/py3k-struni/Modules/cjkcodecs/multibytecodec.c Thu Jun 14 02:29:43 2007 @@ -1247,7 +1247,7 @@ goto errorexit; } - endoffile = (PyString_GET_SIZE(cres) == 0); + endoffile = (PyBytes_GET_SIZE(cres) == 0); if (self->pendingsize > 0) { PyObject *ctr; From python-3000-checkins at python.org Thu Jun 14 02:31:23 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 14 Jun 2007 02:31:23 +0200 (CEST) Subject: [Python-3000-checkins] r55970 - python/branches/py3k-struni/Include/bytesobject.h Message-ID: <20070614003123.5C49B1E400D@bag.python.org> Author: guido.van.rossum Date: Thu Jun 14 02:31:21 2007 New Revision: 55970 Modified: python/branches/py3k-struni/Include/bytesobject.h Log: Add asserts to PyBytes_AS_STRING and PyBytes_GET_SIZE. Modified: python/branches/py3k-struni/Include/bytesobject.h ============================================================================== --- python/branches/py3k-struni/Include/bytesobject.h (original) +++ python/branches/py3k-struni/Include/bytesobject.h Thu Jun 14 02:31:21 2007 @@ -41,8 +41,8 @@ PyAPI_FUNC(int) PyBytes_Resize(PyObject *, Py_ssize_t); /* Macros, trading safety for speed */ -#define PyBytes_AS_STRING(self) (((PyBytesObject *)(self))->ob_bytes) -#define PyBytes_GET_SIZE(self) (((PyBytesObject *)(self))->ob_size) +#define PyBytes_AS_STRING(self) (assert(PyBytes_Check(self)),((PyBytesObject *)(self))->ob_bytes) +#define PyBytes_GET_SIZE(self) (assert(PyBytes_Check(self)),((PyBytesObject *)(self))->ob_size) #ifdef __cplusplus } From nnorwitz at gmail.com Thu Jun 14 03:52:34 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Wed, 13 Jun 2007 21:52:34 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures refleak (1) Message-ID: <20070614015234.GA2782@python.psfb.org> test_threading_local leaked [-1, 1, -91] references, sum=-91 test_urllib2_localnet leaked [13, 3, 0] references, sum=16 From python-3000-checkins at python.org Thu Jun 14 05:28:01 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 14 Jun 2007 05:28:01 +0200 (CEST) Subject: [Python-3000-checkins] r55971 - python/branches/py3k-struni/Lib/abc.py Message-ID: <20070614032801.2EADC1E4002@bag.python.org> Author: guido.van.rossum Date: Thu Jun 14 05:27:55 2007 New Revision: 55971 Modified: python/branches/py3k-struni/Lib/abc.py Log: Modernize the super() call in ABCMeta.__new__() -- I had messed with it when I thought something was broken, and forgotten to restore it before checking in (maybe I did a svn revert which had the wrong effect?). Modified: python/branches/py3k-struni/Lib/abc.py ============================================================================== --- python/branches/py3k-struni/Lib/abc.py (original) +++ python/branches/py3k-struni/Lib/abc.py Thu Jun 14 05:27:55 2007 @@ -93,7 +93,7 @@ def __new__(mcls, name, bases, namespace): bases = _fix_bases(bases) - cls = super(ABCMeta, mcls).__new__(mcls, name, bases, namespace) + cls = super().__new__(mcls, name, bases, namespace) # Compute set of abstract method names abstracts = {name for name, value in namespace.items() From python-3000-checkins at python.org Fri Jun 15 02:00:14 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Fri, 15 Jun 2007 02:00:14 +0200 (CEST) Subject: [Python-3000-checkins] r55978 - python/branches/py3k-struni/Objects/stringobject.c Message-ID: <20070615000014.D73D51E4003@bag.python.org> Author: guido.van.rossum Date: Fri Jun 15 02:00:12 2007 New Revision: 55978 Modified: python/branches/py3k-struni/Objects/stringobject.c Log: Patch by Ron Adam to make repr(str8(...)) return something looking like s'...' instead of '...', allowing it to be distinguished from unicode strings. This doesn't roundtrip -- for now, that's intentional, as the goal is to rip these out rather than to make it a feature, and making them stand out (breaking 8 more tests) helps us track them down so we can rip them out. Modified: python/branches/py3k-struni/Objects/stringobject.c ============================================================================== --- python/branches/py3k-struni/Objects/stringobject.c (original) +++ python/branches/py3k-struni/Objects/stringobject.c Fri Jun 15 02:00:12 2007 @@ -835,7 +835,7 @@ static const char *hexdigits = "0123456789abcdef"; register PyStringObject* op = (PyStringObject*) obj; Py_ssize_t length = PyString_GET_SIZE(op); - size_t newsize = 2 + 4 * op->ob_size; + size_t newsize = 3 + 4 * op->ob_size; PyObject *v; if (newsize > PY_SSIZE_T_MAX || newsize / 4 != op->ob_size) { PyErr_SetString(PyExc_OverflowError, @@ -867,7 +867,7 @@ ; } - *p++ = quote; + *p++ = 's', *p++ = quote; for (i = 0; i < op->ob_size; i++) { /* There's at least enough room for a hex escape and a closing quote. */ From python-3000-checkins at python.org Fri Jun 15 05:14:41 2007 From: python-3000-checkins at python.org (neal.norwitz) Date: Fri, 15 Jun 2007 05:14:41 +0200 (CEST) Subject: [Python-3000-checkins] r55985 - python/branches/p3yk/Misc/build.sh Message-ID: <20070615031441.E12931E4003@bag.python.org> Author: neal.norwitz Date: Fri Jun 15 05:14:38 2007 New Revision: 55985 Modified: python/branches/p3yk/Misc/build.sh Log: All these tests have been flaky wrt reporting leaks. Disable them. Modified: python/branches/p3yk/Misc/build.sh ============================================================================== --- python/branches/p3yk/Misc/build.sh (original) +++ python/branches/p3yk/Misc/build.sh Fri Jun 15 05:14:38 2007 @@ -67,7 +67,7 @@ # Note: test_XXX (none currently) really leak, but are disabled # so we don't send spam. Any test which really leaks should only # be listed here if there are also test cases under Lib/test/leakers. -LEAKY_TESTS="test_(cmd_line|socket)" +LEAKY_TESTS="test_(cmd_line|popen2|socket|threading_local|urllib2_localnet)" # These tests always fail, so skip them so we don't get false positives. _ALWAYS_SKIP="" @@ -170,7 +170,6 @@ start=`current_time` make install >& build/$F update_status "Installing" "$F" $start - mail_on_failure "install" build/$F if [ ! -x $PYTHON ]; then ln -s ${PYTHON}3.* $PYTHON From python-3000-checkins at python.org Fri Jun 15 05:34:11 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Fri, 15 Jun 2007 05:34:11 +0200 (CEST) Subject: [Python-3000-checkins] r55986 - python/branches/py3k-struni/runtests.sh Message-ID: <20070615033411.947CD1E4003@bag.python.org> Author: guido.van.rossum Date: Fri Jun 15 05:33:56 2007 New Revision: 55986 Modified: python/branches/py3k-struni/runtests.sh Log: Fix a typo in the name of an output file. Modified: python/branches/py3k-struni/runtests.sh ============================================================================== --- python/branches/py3k-struni/runtests.sh (original) +++ python/branches/py3k-struni/runtests.sh Fri Jun 15 05:33:56 2007 @@ -54,7 +54,7 @@ else echo " BAD" echo $T >>BAD - echo "---------- Re-running test in verbose mode ----------" >>OUT/$T + echo "--------- Re-running test in verbose mode ---------" >>OUT/$T.out $PYTHON Lib/test/regrtest.py -v $UFLAG $T >>OUT/$T.out 2>&1 fi done From python-3000-checkins at python.org Fri Jun 15 05:35:50 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Fri, 15 Jun 2007 05:35:50 +0200 (CEST) Subject: [Python-3000-checkins] r55987 - in python/branches/py3k-struni: Lib/pickle.py Lib/test/test_popen.py Modules/cPickle.c Message-ID: <20070615033550.547AF1E4003@bag.python.org> Author: guido.van.rossum Date: Fri Jun 15 05:35:38 2007 New Revision: 55987 Modified: python/branches/py3k-struni/Lib/pickle.py python/branches/py3k-struni/Lib/test/test_popen.py python/branches/py3k-struni/Modules/cPickle.c Log: Fix some problems introduced by the str8 repr change. Modified: python/branches/py3k-struni/Lib/pickle.py ============================================================================== --- python/branches/py3k-struni/Lib/pickle.py (original) +++ python/branches/py3k-struni/Lib/pickle.py Fri Jun 15 05:35:38 2007 @@ -501,7 +501,8 @@ else: self.write(BINSTRING + pack("write_func(self, &string, 1) < 0) goto err; From python-3000-checkins at python.org Fri Jun 15 05:49:09 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Fri, 15 Jun 2007 05:49:09 +0200 (CEST) Subject: [Python-3000-checkins] r55991 - in python/branches/py3k-struni: Lib/test/test_popen.py Python/sysmodule.c Message-ID: <20070615034909.AB3051E400C@bag.python.org> Author: guido.van.rossum Date: Fri Jun 15 05:49:03 2007 New Revision: 55991 Modified: python/branches/py3k-struni/Lib/test/test_popen.py python/branches/py3k-struni/Python/sysmodule.c Log: Make sys.path and sys.argv into lists of strings. Remove the hack in test_popen.py to overcome this issue. Modified: python/branches/py3k-struni/Lib/test/test_popen.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_popen.py (original) +++ python/branches/py3k-struni/Lib/test/test_popen.py Fri Jun 15 05:49:03 2007 @@ -20,7 +20,7 @@ class PopenTest(unittest.TestCase): def _do_test_commandline(self, cmdline, expected): - cmd = '%s -c "import sys; print(list(map(str, sys.argv)))" %s' + cmd = '%s -c "import sys; print(sys.argv)" %s' cmd = cmd % (python, cmdline) data = os.popen(cmd).read() got = eval(data)[1:] # strip off argv[0] Modified: python/branches/py3k-struni/Python/sysmodule.c ============================================================================== --- python/branches/py3k-struni/Python/sysmodule.c (original) +++ python/branches/py3k-struni/Python/sysmodule.c Fri Jun 15 05:49:03 2007 @@ -1145,7 +1145,7 @@ p = strchr(path, delim); if (p == NULL) p = strchr(path, '\0'); /* End of string */ - w = PyString_FromStringAndSize(path, (Py_ssize_t) (p - path)); + w = PyUnicode_FromStringAndSize(path, (Py_ssize_t) (p - path)); if (w == NULL) { Py_DECREF(v); return NULL; @@ -1190,14 +1190,14 @@ if (i == 0) { char* fn = decc$translate_vms(argv[0]); if ((fn == (char *)0) || fn == (char *)-1) - v = PyString_FromString(argv[0]); + v = PyUnicode_FromString(argv[0]); else - v = PyString_FromString( + v = PyUnicode_FromString( decc$translate_vms(argv[0])); } else - v = PyString_FromString(argv[i]); + v = PyUnicode_FromString(argv[i]); #else - PyObject *v = PyString_FromString(argv[i]); + PyObject *v = PyUnicode_FromString(argv[i]); #endif if (v == NULL) { Py_DECREF(av); @@ -1301,7 +1301,7 @@ #endif /* Unix */ } #endif /* All others */ - a = PyString_FromStringAndSize(argv0, n); + a = PyUnicode_FromStringAndSize(argv0, n); if (a == NULL) Py_FatalError("no mem for sys.path insertion"); if (PyList_Insert(path, 0, a) < 0) From nnorwitz at gmail.com Fri Jun 15 15:52:28 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Fri, 15 Jun 2007 09:52:28 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures refleak (1) Message-ID: <20070615135228.GA13685@python.psfb.org> test_os leaked [270, 270, 270] references, sum=810 test_threading_local leaked [0, 0, -91] references, sum=-91 test_urllib2_localnet leaked [3, 3, 3] references, sum=9 From nnorwitz at gmail.com Sat Jun 16 03:52:42 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Fri, 15 Jun 2007 21:52:42 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures refleak (1) Message-ID: <20070616015242.GA18754@python.psfb.org> test_os leaked [270, 270, 270] references, sum=810 test_threading_local leaked [0, 0, -91] references, sum=-91 test_urllib2_localnet leaked [3, 3, 3] references, sum=9 From python-3000-checkins at python.org Sat Jun 16 04:41:16 2007 From: python-3000-checkins at python.org (neal.norwitz) Date: Sat, 16 Jun 2007 04:41:16 +0200 (CEST) Subject: [Python-3000-checkins] r56003 - python/branches/p3yk/Lib/_abcoll.py Message-ID: <20070616024116.910F91E4003@bag.python.org> Author: neal.norwitz Date: Sat Jun 16 04:41:09 2007 New Revision: 56003 Modified: python/branches/p3yk/Lib/_abcoll.py Log: Fix typo (certain). Modified: python/branches/p3yk/Lib/_abcoll.py ============================================================================== --- python/branches/p3yk/Lib/_abcoll.py (original) +++ python/branches/p3yk/Lib/_abcoll.py Sat Jun 16 04:41:09 2007 @@ -4,7 +4,7 @@ """Abstract Base Classes (ABCs) for collections, according to PEP 3119. DON'T USE THIS MODULE DIRECTLY! The classes here should be imported -via collections; they are defined here only to alleviate ceratin +via collections; they are defined here only to alleviate certain bootstrapping issues. Unit tests are in test_collections. """ From python-3000-checkins at python.org Sat Jun 16 05:54:29 2007 From: python-3000-checkins at python.org (neal.norwitz) Date: Sat, 16 Jun 2007 05:54:29 +0200 (CEST) Subject: [Python-3000-checkins] r56004 - python/branches/p3yk/Lib/test/regrtest.py Message-ID: <20070616035429.6FAA31E4003@bag.python.org> Author: neal.norwitz Date: Sat Jun 16 05:54:18 2007 New Revision: 56004 Modified: python/branches/p3yk/Lib/test/regrtest.py Log: Fix it so test_os no longer reports ref leaks by clearing all the caches the ABCMeta stores on the class. Apply this to all the ABC collections as well as the class of os.environ which inherits from an ABC collection. Modified: python/branches/p3yk/Lib/test/regrtest.py ============================================================================== --- python/branches/p3yk/Lib/test/regrtest.py (original) +++ python/branches/p3yk/Lib/test/regrtest.py Sat Jun 16 05:54:18 2007 @@ -697,7 +697,7 @@ import gc, copy_reg import _strptime, linecache, dircache import urlparse, urllib, urllib2, mimetypes, doctest - import struct, filecmp, collections + import struct, filecmp, _abcoll from distutils.dir_util import _path_created # Restore some original values. @@ -708,8 +708,10 @@ sys.path_importer_cache.update(pic) # Clear ABC registries. - for obj in [collections.Hashable, collections.Iterable]: + for obj in [getattr(_abcoll, a) for a in _abcoll.__all__] + [os.environ]: obj._ABCMeta__registry.clear() + obj._ABCMeta__cache.clear() + obj._ABCMeta__negative_cache.clear() # Clear assorted module caches. _path_created.clear() From nnorwitz at gmail.com Sat Jun 16 15:52:45 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sat, 16 Jun 2007 09:52:45 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures refleak (1) Message-ID: <20070616135245.GA30826@python.psfb.org> test_os leaked [255, 255, 255] references, sum=765 test_threading_local leaked [0, 0, -91] references, sum=-91 test_urllib2_localnet leaked [3, 3, 3] references, sum=9 From guido at python.org Sat Jun 16 16:44:59 2007 From: guido at python.org (Guido van Rossum) Date: Sat, 16 Jun 2007 07:44:59 -0700 Subject: [Python-3000-checkins] r56004 - python/branches/p3yk/Lib/test/regrtest.py In-Reply-To: <20070616035429.6FAA31E4003@bag.python.org> References: <20070616035429.6FAA31E4003@bag.python.org> Message-ID: This won't scale once there are other modules using ABCs, and there will be (starting with io). But you're right that the registries and caches keep stuff alive. I need to start using weakrefs instead. Regarding the name _abcoll: I read it as "ABstract Collections". :-) --Guido On 6/15/07, neal.norwitz wrote: > Author: neal.norwitz > Date: Sat Jun 16 05:54:18 2007 > New Revision: 56004 > > Modified: > python/branches/p3yk/Lib/test/regrtest.py > Log: > Fix it so test_os no longer reports ref leaks by clearing all the caches > the ABCMeta stores on the class. Apply this to all the ABC collections > as well as the class of os.environ which inherits from an ABC collection. > > > Modified: python/branches/p3yk/Lib/test/regrtest.py > ============================================================================== > --- python/branches/p3yk/Lib/test/regrtest.py (original) > +++ python/branches/p3yk/Lib/test/regrtest.py Sat Jun 16 05:54:18 2007 > @@ -697,7 +697,7 @@ > import gc, copy_reg > import _strptime, linecache, dircache > import urlparse, urllib, urllib2, mimetypes, doctest > - import struct, filecmp, collections > + import struct, filecmp, _abcoll > from distutils.dir_util import _path_created > > # Restore some original values. > @@ -708,8 +708,10 @@ > sys.path_importer_cache.update(pic) > > # Clear ABC registries. > - for obj in [collections.Hashable, collections.Iterable]: > + for obj in [getattr(_abcoll, a) for a in _abcoll.__all__] + [os.environ]: > obj._ABCMeta__registry.clear() > + obj._ABCMeta__cache.clear() > + obj._ABCMeta__negative_cache.clear() > > # Clear assorted module caches. > _path_created.clear() > _______________________________________________ > 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 nnorwitz at gmail.com Sun Jun 17 03:52:30 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sat, 16 Jun 2007 21:52:30 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures refleak (1) Message-ID: <20070617015230.GA8607@python.psfb.org> test_os leaked [255, 255, 255] references, sum=765 test_threading_local leaked [0, 0, -91] references, sum=-91 test_urllib2_localnet leaked [3, 3, 3] references, sum=9 From nnorwitz at gmail.com Sun Jun 17 15:52:44 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sun, 17 Jun 2007 09:52:44 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures refleak (1) Message-ID: <20070617135244.GA13722@python.psfb.org> test_os leaked [255, 255, 255] references, sum=765 test_threading_local leaked [0, 0, -91] references, sum=-91 test_urllib2_localnet leaked [3, 3, 3] references, sum=9 From nnorwitz at gmail.com Mon Jun 18 03:52:39 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sun, 17 Jun 2007 21:52:39 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures refleak (1) Message-ID: <20070618015239.GA19679@python.psfb.org> test_os leaked [255, 255, 255] references, sum=765 test_threading_local leaked [0, 0, -91] references, sum=-91 test_urllib2_localnet leaked [3, 3, 3] references, sum=9 From python-3000-checkins at python.org Mon Jun 18 04:56:34 2007 From: python-3000-checkins at python.org (neal.norwitz) Date: Mon, 18 Jun 2007 04:56:34 +0200 (CEST) Subject: [Python-3000-checkins] r56013 - python/branches/p3yk/Lib/test/regrtest.py Message-ID: <20070618025634.132891E4005@bag.python.org> Author: neal.norwitz Date: Mon Jun 18 04:56:31 2007 New Revision: 56013 Modified: python/branches/p3yk/Lib/test/regrtest.py Log: This should make it a little easier when adding new collections which use ABCs. The new subclass won't need to be listed in regrtest. It will be even better when Guido adds weakrefs. :-) Modified: python/branches/p3yk/Lib/test/regrtest.py ============================================================================== --- python/branches/p3yk/Lib/test/regrtest.py (original) +++ python/branches/p3yk/Lib/test/regrtest.py Mon Jun 18 04:56:31 2007 @@ -708,10 +708,11 @@ sys.path_importer_cache.update(pic) # Clear ABC registries. - for obj in [getattr(_abcoll, a) for a in _abcoll.__all__] + [os.environ]: - obj._ABCMeta__registry.clear() - obj._ABCMeta__cache.clear() - obj._ABCMeta__negative_cache.clear() + for abc in [getattr(_abcoll, a) for a in _abcoll.__all__]: + for obj in abc.__subclasses__() + [abc]: + obj._ABCMeta__registry.clear() + obj._ABCMeta__cache.clear() + obj._ABCMeta__negative_cache.clear() # Clear assorted module caches. _path_created.clear() From nnorwitz at gmail.com Mon Jun 18 04:58:14 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sun, 17 Jun 2007 19:58:14 -0700 Subject: [Python-3000-checkins] r56004 - python/branches/p3yk/Lib/test/regrtest.py In-Reply-To: References: <20070616035429.6FAA31E4003@bag.python.org> Message-ID: On 6/16/07, Guido van Rossum wrote: > This won't scale once there are other modules using ABCs, and there > will be (starting with io). Right, I improved it a little to use __subclasses__() so that each object doesn't have to be listed. Until ... > But you're right that the registries and caches keep stuff alive. I > need to start using weakrefs instead. this is implemented which will make it even nicer. :-) > Regarding the name _abcoll: I read it as "ABstract Collections". :-) "Although that way may not be obvious at first unless you're Dutch." :-) n From python-3000-checkins at python.org Mon Jun 18 05:15:55 2007 From: python-3000-checkins at python.org (martin.v.loewis) Date: Mon, 18 Jun 2007 05:15:55 +0200 (CEST) Subject: [Python-3000-checkins] r56014 - python/branches/p3yk/Objects/longobject.c Message-ID: <20070618031555.40F2B1E4005@bag.python.org> Author: martin.v.loewis Date: Mon Jun 18 05:15:51 2007 New Revision: 56014 Modified: python/branches/p3yk/Objects/longobject.c Log: Drop inline, as it's not support by VS 2003. Modified: python/branches/p3yk/Objects/longobject.c ============================================================================== --- python/branches/p3yk/Objects/longobject.c (original) +++ python/branches/p3yk/Objects/longobject.c Mon Jun 18 05:15:51 2007 @@ -24,7 +24,7 @@ int quick_int_allocs, quick_neg_int_allocs; #endif -static inline PyObject * +static PyObject * get_small_int(int ival) { PyObject *v = (PyObject*)(small_ints + ival + NSMALLNEGINTS); From python-3000-checkins at python.org Mon Jun 18 05:17:23 2007 From: python-3000-checkins at python.org (martin.v.loewis) Date: Mon, 18 Jun 2007 05:17:23 +0200 (CEST) Subject: [Python-3000-checkins] r56015 - python/branches/p3yk/PC/_winreg.c Message-ID: <20070618031723.761D51E4005@bag.python.org> Author: martin.v.loewis Date: Mon Jun 18 05:17:19 2007 New Revision: 56015 Modified: python/branches/p3yk/PC/_winreg.c Log: Expect long objects for DWORD values. Modified: python/branches/p3yk/PC/_winreg.c ============================================================================== --- python/branches/p3yk/PC/_winreg.c (original) +++ python/branches/p3yk/PC/_winreg.c Mon Jun 18 05:17:19 2007 @@ -693,9 +693,10 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize) { int i,j; + DWORD d; switch (typ) { case REG_DWORD: - if (value != Py_None && !PyInt_Check(value)) + if (value != Py_None && !PyLong_Check(value)) return FALSE; *retDataBuf = (BYTE *)PyMem_NEW(DWORD, 1); if (*retDataBuf==NULL){ @@ -707,10 +708,10 @@ DWORD zero = 0; memcpy(*retDataBuf, &zero, sizeof(DWORD)); } - else - memcpy(*retDataBuf, - &PyInt_AS_LONG((PyIntObject *)value), - sizeof(DWORD)); + else { + d = PyLong_AsLong(value); + memcpy(*retDataBuf, &d, sizeof(DWORD)); + } break; case REG_SZ: case REG_EXPAND_SZ: From python-3000-checkins at python.org Mon Jun 18 05:18:05 2007 From: python-3000-checkins at python.org (martin.v.loewis) Date: Mon, 18 Jun 2007 05:18:05 +0200 (CEST) Subject: [Python-3000-checkins] r56016 - python/branches/p3yk/PC/config.c Message-ID: <20070618031805.DA7441E4005@bag.python.org> Author: martin.v.loewis Date: Mon Jun 18 05:18:01 2007 New Revision: 56016 Modified: python/branches/p3yk/PC/config.c Log: Drop modules that have been deleted. Modified: python/branches/p3yk/PC/config.c ============================================================================== --- python/branches/p3yk/PC/config.c (original) +++ python/branches/p3yk/PC/config.c Mon Jun 18 05:18:01 2007 @@ -14,11 +14,9 @@ extern void initerrno(void); extern void initgc(void); extern void initmath(void); -extern void init_md5(void); extern void initnt(void); extern void initoperator(void); extern void initsignal(void); -extern void init_sha(void); extern void init_sha256(void); extern void init_sha512(void); extern void inittime(void); @@ -61,7 +59,6 @@ extern void init_lsprof(void); extern void init_ast(void); extern void init_types(void); -extern void initatexit(void); /* tools/freeze/makeconfig.py marker for additional "extern" */ /* -- ADDMODULE MARKER 1 -- */ @@ -73,7 +70,6 @@ {"array", initarray}, {"_ast", init_ast}, - {"atexit", initatexit}, #ifdef MS_WINDOWS #ifndef MS_WINI64 {"audioop", initaudioop}, @@ -84,11 +80,9 @@ {"errno", initerrno}, {"gc", initgc}, {"math", initmath}, - {"_md5", init_md5}, {"nt", initnt}, /* Use the NT os functions, not posix */ {"operator", initoperator}, {"signal", initsignal}, - {"_sha", init_sha}, {"_sha256", init_sha256}, {"_sha512", init_sha512}, {"time", inittime}, From python-3000-checkins at python.org Mon Jun 18 05:18:57 2007 From: python-3000-checkins at python.org (martin.v.loewis) Date: Mon, 18 Jun 2007 05:18:57 +0200 (CEST) Subject: [Python-3000-checkins] r56017 - in python/branches/p3yk: PC/pyconfig.h PCbuild/pythoncore.vcproj Message-ID: <20070618031857.8F5401E4005@bag.python.org> Author: martin.v.loewis Date: Mon Jun 18 05:18:55 2007 New Revision: 56017 Modified: python/branches/p3yk/PC/pyconfig.h python/branches/p3yk/PCbuild/pythoncore.vcproj Log: Bump DLL version number to 30. Modified: python/branches/p3yk/PC/pyconfig.h ============================================================================== --- python/branches/p3yk/PC/pyconfig.h (original) +++ python/branches/p3yk/PC/pyconfig.h Mon Jun 18 05:18:55 2007 @@ -303,9 +303,9 @@ their Makefile (other compilers are generally taken care of by distutils.) */ # ifdef _DEBUG -# pragma comment(lib,"python26_d.lib") +# pragma comment(lib,"python30_d.lib") # else -# pragma comment(lib,"python26.lib") +# pragma comment(lib,"python30.lib") # endif /* _DEBUG */ # endif /* _MSC_VER */ # endif /* Py_BUILD_CORE */ Modified: python/branches/p3yk/PCbuild/pythoncore.vcproj ============================================================================== --- python/branches/p3yk/PCbuild/pythoncore.vcproj (original) +++ python/branches/p3yk/PCbuild/pythoncore.vcproj Mon Jun 18 05:18:55 2007 @@ -39,15 +39,15 @@ @@ -99,15 +99,15 @@ @@ -166,15 +166,15 @@ Name="VCLinkerTool" AdditionalOptions=" /MACHINE:IA64 /USELINK:MS_SDK" AdditionalDependencies="getbuildinfo.o" - OutputFile="./python26.dll" + OutputFile="./python30.dll" LinkIncremental="1" SuppressStartupBanner="FALSE" IgnoreDefaultLibraryNames="libc" GenerateDebugInformation="TRUE" - ProgramDatabaseFile=".\./python26.pdb" + ProgramDatabaseFile=".\./python30.pdb" SubSystem="2" BaseAddress="0x1e000000" - ImportLibrary=".\./python26.lib" + ImportLibrary=".\./python30.lib" TargetMachine="0"/> @@ -233,15 +233,15 @@ Name="VCLinkerTool" AdditionalOptions=" /MACHINE:AMD64 /USELINK:MS_SDK" AdditionalDependencies="getbuildinfo.o" - OutputFile="./python26.dll" + OutputFile="./python30.dll" LinkIncremental="1" SuppressStartupBanner="TRUE" IgnoreDefaultLibraryNames="libc" GenerateDebugInformation="TRUE" - ProgramDatabaseFile=".\./python26.pdb" + ProgramDatabaseFile=".\./python30.pdb" SubSystem="2" BaseAddress="0x1e000000" - ImportLibrary=".\./python26.lib" + ImportLibrary=".\./python30.lib" TargetMachine="0"/> @@ -365,6 +365,9 @@ RelativePath="..\Modules\_codecsmodule.c"> + + - - Author: neal.norwitz Date: Mon Jun 18 05:55:43 2007 New Revision: 56018 Added: python/branches/p3yk/Tools/buildbot/README.tcltk-AMD64 - copied unchanged from r56012, python/trunk/Tools/buildbot/README.tcltk-AMD64 Modified: python/branches/p3yk/ (props changed) python/branches/p3yk/Doc/api/concrete.tex python/branches/p3yk/Doc/howto/unicode.rst python/branches/p3yk/Doc/lib/libsqlite3.tex python/branches/p3yk/Include/pyerrors.h python/branches/p3yk/Include/structmember.h python/branches/p3yk/Misc/developers.txt python/branches/p3yk/Objects/exceptions.c python/branches/p3yk/PC/pyconfig.h python/branches/p3yk/Python/structmember.c python/branches/p3yk/Tools/buildbot/external-amd64.bat Log: Merged revisions 55951-56013 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r55956 | thomas.heller | 2007-06-13 00:07:03 -0700 (Wed, 13 Jun 2007) | 2 lines Do not hardcode the buildbot's directory name. ........ r55957 | thomas.heller | 2007-06-13 00:07:41 -0700 (Wed, 13 Jun 2007) | 2 lines Notes about building tcl/tk for windows/AMD64. ........ r55958 | thomas.heller | 2007-06-13 00:54:57 -0700 (Wed, 13 Jun 2007) | 2 lines Build bzip2. ........ r55962 | walter.doerwald | 2007-06-13 09:57:12 -0700 (Wed, 13 Jun 2007) | 8 lines Add T_PYSSIZET in structmember.h: This can be used for Py_ssize_t members. Simplify the implementation of UnicodeError objects: start and end attributes are now stored directly as Py_ssize_t members, which simplifies various get and set functions. ........ r55975 | martin.v.loewis | 2007-06-14 13:46:25 -0700 (Thu, 14 Jun 2007) | 3 lines Patch #1734014: Use _I64_MAX instead of LLONG_MAX. Will backport to 2.5. ........ r55984 | neal.norwitz | 2007-06-14 20:11:41 -0700 (Thu, 14 Jun 2007) | 4 lines urllib2_localnet says it leaks probably due to threads. So ignore it. popen2 is also complaining probably for similar reasons. make install always reports failure, so don't mail in this case. ........ r56001 | andrew.kuchling | 2007-06-15 15:43:03 -0700 (Fri, 15 Jun 2007) | 1 line Add a word ........ r56005 | martin.v.loewis | 2007-06-16 03:08:43 -0700 (Sat, 16 Jun 2007) | 2 lines Mention Senthil Kumaran. ........ r56006 | georg.brandl | 2007-06-16 10:10:12 -0700 (Sat, 16 Jun 2007) | 2 lines Add missing \versionadded. ........ r56009 | neal.norwitz | 2007-06-17 11:48:32 -0700 (Sun, 17 Jun 2007) | 1 line SF #1738670, make example in doc work ........ r56011 | neal.norwitz | 2007-06-17 19:46:36 -0700 (Sun, 17 Jun 2007) | 1 line SF #1738754, remove extra backslash in string ........ r56012 | neal.norwitz | 2007-06-17 19:50:15 -0700 (Sun, 17 Jun 2007) | 1 line Revert last change for SF #1738754, there's no print in there. ........ Modified: python/branches/p3yk/Doc/api/concrete.tex ============================================================================== --- python/branches/p3yk/Doc/api/concrete.tex (original) +++ python/branches/p3yk/Doc/api/concrete.tex Mon Jun 18 05:55:43 2007 @@ -99,6 +99,7 @@ \begin{csimplemacrodesc}{Py_RETURN_NONE} Properly handle returning \cdata{Py_None} from within a C function. + \versionadded{2.4} \end{csimplemacrodesc} Modified: python/branches/p3yk/Doc/howto/unicode.rst ============================================================================== --- python/branches/p3yk/Doc/howto/unicode.rst (original) +++ python/branches/p3yk/Doc/howto/unicode.rst Mon Jun 18 05:55:43 2007 @@ -152,7 +152,7 @@ 4. Many Internet standards are defined in terms of textual data, and can't handle content with embedded zero bytes. -Generally people don't use this encoding, choosing other encodings +Generally people don't use this encoding, instead choosing other encodings that are more efficient and convenient. Encodings don't have to handle every possible Unicode character, and Modified: python/branches/p3yk/Doc/lib/libsqlite3.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libsqlite3.tex (original) +++ python/branches/p3yk/Doc/lib/libsqlite3.tex Mon Jun 18 05:55:43 2007 @@ -42,6 +42,12 @@ # Insert a row of data c.execute("""insert into stocks values ('2006-01-05','BUY','RHAT',100,35.14)""") + +# Save (commit) the changes +conn.commit() + +# We can also close the cursor if we are done with it +c.close() \end{verbatim} Usually your SQL operations will need to use values from Python Modified: python/branches/p3yk/Include/pyerrors.h ============================================================================== --- python/branches/p3yk/Include/pyerrors.h (original) +++ python/branches/p3yk/Include/pyerrors.h Mon Jun 18 05:55:43 2007 @@ -31,8 +31,8 @@ PyObject *args; PyObject *encoding; PyObject *object; - PyObject *start; - PyObject *end; + Py_ssize_t start; + Py_ssize_t end; PyObject *reason; } PyUnicodeErrorObject; #endif Modified: python/branches/p3yk/Include/structmember.h ============================================================================== --- python/branches/p3yk/Include/structmember.h (original) +++ python/branches/p3yk/Include/structmember.h Mon Jun 18 05:55:43 2007 @@ -68,9 +68,10 @@ #ifdef HAVE_LONG_LONG #define T_LONGLONG 17 #define T_ULONGLONG 18 +#define T_PYSSIZET 19 /* Py_ssize_t */ #endif /* HAVE_LONG_LONG */ -#define T_NONE 19 /* Value is always None */ +#define T_NONE 20 /* Value is always None */ /* Flags */ #define READONLY 1 Modified: python/branches/p3yk/Misc/developers.txt ============================================================================== --- python/branches/p3yk/Misc/developers.txt (original) +++ python/branches/p3yk/Misc/developers.txt Mon Jun 18 05:55:43 2007 @@ -17,6 +17,10 @@ Permissions History ------------------- +- Senthil Kumaran was given SVN access on June 16 2007 + by MvL, for his Summer-of-Code project, mentored by + Skip Montanaro. + - Alexandre Vassalotti was given SVN access on May 21 2007 by MvL, for his Summer-of-Code project, mentored by Brett Cannon. Modified: python/branches/p3yk/Objects/exceptions.c ============================================================================== --- python/branches/p3yk/Objects/exceptions.c (original) +++ python/branches/p3yk/Objects/exceptions.c Mon Jun 18 05:55:43 2007 @@ -1149,36 +1149,6 @@ "Unicode related error."); #ifdef Py_USING_UNICODE -static int -get_int(PyObject *attr, Py_ssize_t *value, const char *name) -{ - if (!attr) { - PyErr_Format(PyExc_TypeError, "%.200s attribute not set", name); - return -1; - } - - if (PyLong_Check(attr)) { - *value = PyLong_AsSsize_t(attr); - if (*value == -1 && PyErr_Occurred()) - return -1; - } else { - PyErr_Format(PyExc_TypeError, "%.200s attribute must be int", name); - return -1; - } - return 0; -} - -static int -set_ssize_t(PyObject **attr, Py_ssize_t value) -{ - PyObject *obj = PyInt_FromSsize_t(value); - if (!obj) - return -1; - Py_CLEAR(*attr); - *attr = obj; - return 0; -} - static PyObject * get_string(PyObject *attr, const char *name) { @@ -1258,40 +1228,38 @@ int PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start) { - if (!get_int(((PyUnicodeErrorObject *)exc)->start, start, "start")) { - Py_ssize_t size; - PyObject *obj = get_unicode(((PyUnicodeErrorObject *)exc)->object, - "object"); - if (!obj) return -1; - size = PyUnicode_GET_SIZE(obj); - if (*start<0) - *start = 0; /*XXX check for values <0*/ - if (*start>=size) - *start = size-1; - Py_DECREF(obj); - return 0; - } - return -1; + Py_ssize_t size; + PyObject *obj = get_unicode(((PyUnicodeErrorObject *)exc)->object, + "object"); + if (!obj) + return -1; + *start = ((PyUnicodeErrorObject *)exc)->start; + size = PyUnicode_GET_SIZE(obj); + if (*start<0) + *start = 0; /*XXX check for values <0*/ + if (*start>=size) + *start = size-1; + Py_DECREF(obj); + return 0; } int PyUnicodeDecodeError_GetStart(PyObject *exc, Py_ssize_t *start) { - if (!get_int(((PyUnicodeErrorObject *)exc)->start, start, "start")) { - Py_ssize_t size; - PyObject *obj = get_string(((PyUnicodeErrorObject *)exc)->object, - "object"); - if (!obj) return -1; - size = PyString_GET_SIZE(obj); - if (*start<0) - *start = 0; - if (*start>=size) - *start = size-1; - Py_DECREF(obj); - return 0; - } - return -1; + Py_ssize_t size; + PyObject *obj = get_string(((PyUnicodeErrorObject *)exc)->object, + "object"); + if (!obj) + return -1; + size = PyString_GET_SIZE(obj); + *start = ((PyUnicodeErrorObject *)exc)->start; + if (*start<0) + *start = 0; + if (*start>=size) + *start = size-1; + Py_DECREF(obj); + return 0; } @@ -1305,61 +1273,62 @@ int PyUnicodeEncodeError_SetStart(PyObject *exc, Py_ssize_t start) { - return set_ssize_t(&((PyUnicodeErrorObject *)exc)->start, start); + ((PyUnicodeErrorObject *)exc)->start = start; + return 0; } int PyUnicodeDecodeError_SetStart(PyObject *exc, Py_ssize_t start) { - return set_ssize_t(&((PyUnicodeErrorObject *)exc)->start, start); + ((PyUnicodeErrorObject *)exc)->start = start; + return 0; } int PyUnicodeTranslateError_SetStart(PyObject *exc, Py_ssize_t start) { - return set_ssize_t(&((PyUnicodeErrorObject *)exc)->start, start); + ((PyUnicodeErrorObject *)exc)->start = start; + return 0; } int PyUnicodeEncodeError_GetEnd(PyObject *exc, Py_ssize_t *end) { - if (!get_int(((PyUnicodeErrorObject *)exc)->end, end, "end")) { - Py_ssize_t size; - PyObject *obj = get_unicode(((PyUnicodeErrorObject *)exc)->object, - "object"); - if (!obj) return -1; - size = PyUnicode_GET_SIZE(obj); - if (*end<1) - *end = 1; - if (*end>size) - *end = size; - Py_DECREF(obj); - return 0; - } - return -1; + Py_ssize_t size; + PyObject *obj = get_unicode(((PyUnicodeErrorObject *)exc)->object, + "object"); + if (!obj) + return -1; + *end = ((PyUnicodeErrorObject *)exc)->end; + size = PyUnicode_GET_SIZE(obj); + if (*end<1) + *end = 1; + if (*end>size) + *end = size; + Py_DECREF(obj); + return 0; } int PyUnicodeDecodeError_GetEnd(PyObject *exc, Py_ssize_t *end) { - if (!get_int(((PyUnicodeErrorObject *)exc)->end, end, "end")) { - Py_ssize_t size; - PyObject *obj = get_string(((PyUnicodeErrorObject *)exc)->object, - "object"); - if (!obj) return -1; - size = PyString_GET_SIZE(obj); - if (*end<1) - *end = 1; - if (*end>size) - *end = size; - Py_DECREF(obj); - return 0; - } - return -1; + Py_ssize_t size; + PyObject *obj = get_string(((PyUnicodeErrorObject *)exc)->object, + "object"); + if (!obj) + return -1; + *end = ((PyUnicodeErrorObject *)exc)->end; + size = PyString_GET_SIZE(obj); + if (*end<1) + *end = 1; + if (*end>size) + *end = size; + Py_DECREF(obj); + return 0; } @@ -1373,21 +1342,24 @@ int PyUnicodeEncodeError_SetEnd(PyObject *exc, Py_ssize_t end) { - return set_ssize_t(&((PyUnicodeErrorObject *)exc)->end, end); + ((PyUnicodeErrorObject *)exc)->end = end; + return 0; } int PyUnicodeDecodeError_SetEnd(PyObject *exc, Py_ssize_t end) { - return set_ssize_t(&((PyUnicodeErrorObject *)exc)->end, end); + ((PyUnicodeErrorObject *)exc)->end = end; + return 0; } int PyUnicodeTranslateError_SetEnd(PyObject *exc, Py_ssize_t end) { - return set_ssize_t(&((PyUnicodeErrorObject *)exc)->end, end); + ((PyUnicodeErrorObject *)exc)->end = end; + return 0; } PyObject * @@ -1438,25 +1410,20 @@ { Py_CLEAR(self->encoding); Py_CLEAR(self->object); - Py_CLEAR(self->start); - Py_CLEAR(self->end); Py_CLEAR(self->reason); - if (!PyArg_ParseTuple(args, "O!O!O!O!O!", + if (!PyArg_ParseTuple(args, "O!O!nnO!", &PyString_Type, &self->encoding, objecttype, &self->object, - &PyLong_Type, &self->start, - &PyLong_Type, &self->end, + &self->start, + &self->end, &PyString_Type, &self->reason)) { - self->encoding = self->object = self->start = self->end = - self->reason = NULL; + self->encoding = self->object = self->reason = NULL; return -1; } Py_INCREF(self->encoding); Py_INCREF(self->object); - Py_INCREF(self->start); - Py_INCREF(self->end); Py_INCREF(self->reason); return 0; @@ -1467,8 +1434,6 @@ { Py_CLEAR(self->encoding); Py_CLEAR(self->object); - Py_CLEAR(self->start); - Py_CLEAR(self->end); Py_CLEAR(self->reason); return BaseException_clear((PyBaseExceptionObject *)self); } @@ -1486,8 +1451,6 @@ { Py_VISIT(self->encoding); Py_VISIT(self->object); - Py_VISIT(self->start); - Py_VISIT(self->end); Py_VISIT(self->reason); return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg); } @@ -1497,9 +1460,9 @@ PyDoc_STR("exception encoding")}, {"object", T_OBJECT, offsetof(PyUnicodeErrorObject, object), 0, PyDoc_STR("exception object")}, - {"start", T_OBJECT, offsetof(PyUnicodeErrorObject, start), 0, + {"start", T_PYSSIZET, offsetof(PyUnicodeErrorObject, start), 0, PyDoc_STR("exception start")}, - {"end", T_OBJECT, offsetof(PyUnicodeErrorObject, end), 0, + {"end", T_PYSSIZET, offsetof(PyUnicodeErrorObject, end), 0, PyDoc_STR("exception end")}, {"reason", T_OBJECT, offsetof(PyUnicodeErrorObject, reason), 0, PyDoc_STR("exception reason")}, @@ -1523,17 +1486,10 @@ static PyObject * UnicodeEncodeError_str(PyObject *self) { - Py_ssize_t start; - Py_ssize_t end; - - if (PyUnicodeEncodeError_GetStart(self, &start)) - return NULL; - - if (PyUnicodeEncodeError_GetEnd(self, &end)) - return NULL; + PyUnicodeErrorObject *uself = (PyUnicodeErrorObject *)self; - if (end==start+1) { - int badchar = (int)PyUnicode_AS_UNICODE(((PyUnicodeErrorObject *)self)->object)[start]; + if (uself->end==uself->start+1) { + int badchar = (int)PyUnicode_AS_UNICODE(uself->object)[uself->start]; char badchar_str[20]; if (badchar <= 0xff) PyOS_snprintf(badchar_str, sizeof(badchar_str), "x%02x", badchar); @@ -1543,18 +1499,18 @@ PyOS_snprintf(badchar_str, sizeof(badchar_str), "U%08x", badchar); return PyString_FromFormat( "'%.400s' codec can't encode character u'\\%s' in position %zd: %.400s", - PyString_AS_STRING(((PyUnicodeErrorObject *)self)->encoding), + PyString_AS_STRING(uself->encoding), badchar_str, - start, - PyString_AS_STRING(((PyUnicodeErrorObject *)self)->reason) + uself->start, + PyString_AS_STRING(uself->reason) ); } return PyString_FromFormat( "'%.400s' codec can't encode characters in position %zd-%zd: %.400s", - PyString_AS_STRING(((PyUnicodeErrorObject *)self)->encoding), - start, - (end-1), - PyString_AS_STRING(((PyUnicodeErrorObject *)self)->reason) + PyString_AS_STRING(uself->encoding), + uself->start, + uself->end-1, + PyString_AS_STRING(uself->reason) ); } @@ -1599,34 +1555,27 @@ static PyObject * UnicodeDecodeError_str(PyObject *self) { - Py_ssize_t start = 0; - Py_ssize_t end = 0; + PyUnicodeErrorObject *uself = (PyUnicodeErrorObject *)self; - if (PyUnicodeDecodeError_GetStart(self, &start)) - return NULL; - - if (PyUnicodeDecodeError_GetEnd(self, &end)) - return NULL; - - if (end==start+1) { + if (uself->end==uself->start+1) { /* FromFormat does not support %02x, so format that separately */ char byte[4]; PyOS_snprintf(byte, sizeof(byte), "%02x", - ((int)PyString_AS_STRING(((PyUnicodeErrorObject *)self)->object)[start])&0xff); + ((int)PyString_AS_STRING(uself->object)[uself->start])&0xff); return PyString_FromFormat( "'%.400s' codec can't decode byte 0x%s in position %zd: %.400s", - PyString_AS_STRING(((PyUnicodeErrorObject *)self)->encoding), + PyString_AS_STRING(uself->encoding), byte, - start, - PyString_AS_STRING(((PyUnicodeErrorObject *)self)->reason) + uself->start, + PyString_AS_STRING(uself->reason) ); } return PyString_FromFormat( "'%.400s' codec can't decode bytes in position %zd-%zd: %.400s", - PyString_AS_STRING(((PyUnicodeErrorObject *)self)->encoding), - start, - (end-1), - PyString_AS_STRING(((PyUnicodeErrorObject *)self)->reason) + PyString_AS_STRING(uself->encoding), + uself->start, + uself->end-1, + PyString_AS_STRING(uself->reason) ); } @@ -1670,22 +1619,18 @@ return -1; Py_CLEAR(self->object); - Py_CLEAR(self->start); - Py_CLEAR(self->end); Py_CLEAR(self->reason); - if (!PyArg_ParseTuple(args, "O!O!O!O!", + if (!PyArg_ParseTuple(args, "O!nnO!", &PyUnicode_Type, &self->object, - &PyLong_Type, &self->start, - &PyLong_Type, &self->end, + &self->start, + &self->end, &PyString_Type, &self->reason)) { - self->object = self->start = self->end = self->reason = NULL; + self->object = self->reason = NULL; return -1; } Py_INCREF(self->object); - Py_INCREF(self->start); - Py_INCREF(self->end); Py_INCREF(self->reason); return 0; @@ -1695,17 +1640,10 @@ static PyObject * UnicodeTranslateError_str(PyObject *self) { - Py_ssize_t start; - Py_ssize_t end; - - if (PyUnicodeTranslateError_GetStart(self, &start)) - return NULL; - - if (PyUnicodeTranslateError_GetEnd(self, &end)) - return NULL; + PyUnicodeErrorObject *uself = (PyUnicodeErrorObject *)self; - if (end==start+1) { - int badchar = (int)PyUnicode_AS_UNICODE(((PyUnicodeErrorObject *)self)->object)[start]; + if (uself->end==uself->start+1) { + int badchar = (int)PyUnicode_AS_UNICODE(uself->object)[uself->start]; char badchar_str[20]; if (badchar <= 0xff) PyOS_snprintf(badchar_str, sizeof(badchar_str), "x%02x", badchar); @@ -1716,15 +1654,15 @@ return PyString_FromFormat( "can't translate character u'\\%s' in position %zd: %.400s", badchar_str, - start, - PyString_AS_STRING(((PyUnicodeErrorObject *)self)->reason) + uself->start, + PyString_AS_STRING(uself->reason) ); } return PyString_FromFormat( "can't translate characters in position %zd-%zd: %.400s", - start, - (end-1), - PyString_AS_STRING(((PyUnicodeErrorObject *)self)->reason) + uself->start, + uself->end-1, + PyString_AS_STRING(uself->reason) ); } Modified: python/branches/p3yk/PC/pyconfig.h ============================================================================== --- python/branches/p3yk/PC/pyconfig.h (original) +++ python/branches/p3yk/PC/pyconfig.h Mon Jun 18 05:55:43 2007 @@ -275,9 +275,9 @@ #define HAVE_LONG_LONG 1 #ifndef PY_LONG_LONG # define PY_LONG_LONG __int64 -# define PY_LLONG_MAX LLONG_MAX -# define PY_LLONG_MIN LLONG_MIN -# define PY_ULLONG_MAX ULLONG_MAX +# define PY_LLONG_MAX _I64_MAX +# define PY_LLONG_MIN _I64_MIN +# define PY_ULLONG_MAX _UI64_MAX #endif /* For Windows the Python core is in a DLL by default. Test Modified: python/branches/p3yk/Python/structmember.c ============================================================================== --- python/branches/p3yk/Python/structmember.c (original) +++ python/branches/p3yk/Python/structmember.c Mon Jun 18 05:55:43 2007 @@ -81,6 +81,9 @@ case T_ULONG: v = PyLong_FromUnsignedLong(*(unsigned long*)addr); break; + case T_PYSSIZET: + v = PyInt_FromSsize_t(*(Py_ssize_t*)addr); + break; case T_FLOAT: v = PyFloat_FromDouble((double)*(float*)addr); break; @@ -259,6 +262,13 @@ } break; } + case T_PYSSIZET:{ + *(Py_ssize_t*)addr = PyInt_AsSsize_t(v); + if ((*(Py_ssize_t*)addr == (Py_ssize_t)-1) + && PyErr_Occurred()) + return -1; + break; + } case T_FLOAT:{ double double_val; double_val = PyFloat_AsDouble(v); Modified: python/branches/p3yk/Tools/buildbot/external-amd64.bat ============================================================================== --- python/branches/p3yk/Tools/buildbot/external-amd64.bat (original) +++ python/branches/p3yk/Tools/buildbot/external-amd64.bat Mon Jun 18 05:55:43 2007 @@ -7,23 +7,29 @@ call "%MSSdk%\SetEnv" /XP64 /RETAIL @rem Assume we start inside the Python source directory +for %%i in (.) do set CWD=%%~fi cd .. @rem sqlite if not exist sqlite-source-3.3.4 ( svn export http://svn.python.org/projects/external/sqlite-source-3.3.4 - if exist build\PCbuild\sqlite3.dll del build\PCbuild\sqlite3.dll + if exist %CWD%\PCbuild\sqlite3.dll del %CWD%\PCbuild\sqlite3.dll ) -if not exist build\PCbuild\sqlite3.dll ( +if not exist %CWD%\PCbuild\sqlite3.dll ( cd sqlite-source-3.3.4\amd64 cl ..\*.c link /def:..\sqlite3.def /dll *.obj /out:sqlite3.dll bufferoverflowU.lib cd ..\.. - copy sqlite-source-3.3.4\amd64\sqlite3.dll build\PCbuild + copy sqlite-source-3.3.4\amd64\sqlite3.dll %CWD%\PCbuild ) @rem bzip if not exist bzip2-1.0.3 svn export http://svn.python.org/projects/external/bzip2-1.0.3 +if not exist bzip2-1.0.3\libbz2.lib ( + cd bzip2-1.0.3 + nmake /f makefile.msc CFLAGS="-DWIN32 -MD -Ox -D_FILE_OFFSET_BITS=64 -nologo /GS-" + cd .. +) @rem Sleepycat db if not exist db-4.4.20 svn export http://svn.python.org/projects/external/db-4.4.20 From python-3000-checkins at python.org Mon Jun 18 19:59:01 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Mon, 18 Jun 2007 19:59:01 +0200 (CEST) Subject: [Python-3000-checkins] r56020 - in python/branches/py3k-struni: Doc/api/concrete.tex Doc/howto/unicode.rst Doc/lib/libsqlite3.tex Include/pyerrors.h Include/structmember.h Lib/_abcoll.py Lib/test/regrtest.py Misc/build.sh Misc/developers.txt Objects/exceptions.c Objects/longobject.c PC/_winreg.c PC/config.c PC/pyconfig.h PCbuild/pythoncore.vcproj Python/structmember.c Tools/buildbot/README.tcltk-AMD64 Tools/buildbot/external-amd64.bat Message-ID: <20070618175901.5769B1E4006@bag.python.org> Author: guido.van.rossum Date: Mon Jun 18 19:58:50 2007 New Revision: 56020 Added: python/branches/py3k-struni/Tools/buildbot/README.tcltk-AMD64 - copied unchanged from r56018, python/branches/p3yk/Tools/buildbot/README.tcltk-AMD64 Modified: python/branches/py3k-struni/ (props changed) python/branches/py3k-struni/Doc/api/concrete.tex python/branches/py3k-struni/Doc/howto/unicode.rst python/branches/py3k-struni/Doc/lib/libsqlite3.tex python/branches/py3k-struni/Include/pyerrors.h python/branches/py3k-struni/Include/structmember.h python/branches/py3k-struni/Lib/_abcoll.py python/branches/py3k-struni/Lib/test/regrtest.py python/branches/py3k-struni/Misc/build.sh python/branches/py3k-struni/Misc/developers.txt python/branches/py3k-struni/Objects/exceptions.c python/branches/py3k-struni/Objects/longobject.c python/branches/py3k-struni/PC/_winreg.c python/branches/py3k-struni/PC/config.c python/branches/py3k-struni/PC/pyconfig.h python/branches/py3k-struni/PCbuild/pythoncore.vcproj python/branches/py3k-struni/Python/structmember.c python/branches/py3k-struni/Tools/buildbot/external-amd64.bat Log: Merged revisions 55962-56019 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/p3yk ................ r55985 | neal.norwitz | 2007-06-14 20:14:38 -0700 (Thu, 14 Jun 2007) | 2 lines All these tests have been flaky wrt reporting leaks. Disable them. ................ r56003 | neal.norwitz | 2007-06-15 19:41:09 -0700 (Fri, 15 Jun 2007) | 1 line Fix typo (certain). ................ r56004 | neal.norwitz | 2007-06-15 20:54:18 -0700 (Fri, 15 Jun 2007) | 4 lines Fix it so test_os no longer reports ref leaks by clearing all the caches the ABCMeta stores on the class. Apply this to all the ABC collections as well as the class of os.environ which inherits from an ABC collection. ................ r56013 | neal.norwitz | 2007-06-17 19:56:31 -0700 (Sun, 17 Jun 2007) | 4 lines This should make it a little easier when adding new collections which use ABCs. The new subclass won't need to be listed in regrtest. It will be even better when Guido adds weakrefs. :-) ................ r56014 | martin.v.loewis | 2007-06-17 20:15:51 -0700 (Sun, 17 Jun 2007) | 1 line Drop inline, as it's not support by VS 2003. ................ r56015 | martin.v.loewis | 2007-06-17 20:17:19 -0700 (Sun, 17 Jun 2007) | 1 line Expect long objects for DWORD values. ................ r56016 | martin.v.loewis | 2007-06-17 20:18:01 -0700 (Sun, 17 Jun 2007) | 1 line Drop modules that have been deleted. ................ r56017 | martin.v.loewis | 2007-06-17 20:18:55 -0700 (Sun, 17 Jun 2007) | 1 line Bump DLL version number to 30. ................ r56018 | neal.norwitz | 2007-06-17 20:55:43 -0700 (Sun, 17 Jun 2007) | 62 lines Merged revisions 55951-56013 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r55956 | thomas.heller | 2007-06-13 00:07:03 -0700 (Wed, 13 Jun 2007) | 2 lines Do not hardcode the buildbot's directory name. ........ r55957 | thomas.heller | 2007-06-13 00:07:41 -0700 (Wed, 13 Jun 2007) | 2 lines Notes about building tcl/tk for windows/AMD64. ........ r55958 | thomas.heller | 2007-06-13 00:54:57 -0700 (Wed, 13 Jun 2007) | 2 lines Build bzip2. ........ r55962 | walter.doerwald | 2007-06-13 09:57:12 -0700 (Wed, 13 Jun 2007) | 8 lines Add T_PYSSIZET in structmember.h: This can be used for Py_ssize_t members. Simplify the implementation of UnicodeError objects: start and end attributes are now stored directly as Py_ssize_t members, which simplifies various get and set functions. ........ r55975 | martin.v.loewis | 2007-06-14 13:46:25 -0700 (Thu, 14 Jun 2007) | 3 lines Patch #1734014: Use _I64_MAX instead of LLONG_MAX. Will backport to 2.5. ........ r55984 | neal.norwitz | 2007-06-14 20:11:41 -0700 (Thu, 14 Jun 2007) | 4 lines urllib2_localnet says it leaks probably due to threads. So ignore it. popen2 is also complaining probably for similar reasons. make install always reports failure, so don't mail in this case. ........ r56001 | andrew.kuchling | 2007-06-15 15:43:03 -0700 (Fri, 15 Jun 2007) | 1 line Add a word ........ r56005 | martin.v.loewis | 2007-06-16 03:08:43 -0700 (Sat, 16 Jun 2007) | 2 lines Mention Senthil Kumaran. ........ r56006 | georg.brandl | 2007-06-16 10:10:12 -0700 (Sat, 16 Jun 2007) | 2 lines Add missing \versionadded. ........ r56009 | neal.norwitz | 2007-06-17 11:48:32 -0700 (Sun, 17 Jun 2007) | 1 line SF #1738670, make example in doc work ........ r56011 | neal.norwitz | 2007-06-17 19:46:36 -0700 (Sun, 17 Jun 2007) | 1 line SF #1738754, remove extra backslash in string ........ r56012 | neal.norwitz | 2007-06-17 19:50:15 -0700 (Sun, 17 Jun 2007) | 1 line Revert last change for SF #1738754, there's no print in there. ........ ................ Modified: python/branches/py3k-struni/Doc/api/concrete.tex ============================================================================== --- python/branches/py3k-struni/Doc/api/concrete.tex (original) +++ python/branches/py3k-struni/Doc/api/concrete.tex Mon Jun 18 19:58:50 2007 @@ -99,6 +99,7 @@ \begin{csimplemacrodesc}{Py_RETURN_NONE} Properly handle returning \cdata{Py_None} from within a C function. + \versionadded{2.4} \end{csimplemacrodesc} Modified: python/branches/py3k-struni/Doc/howto/unicode.rst ============================================================================== --- python/branches/py3k-struni/Doc/howto/unicode.rst (original) +++ python/branches/py3k-struni/Doc/howto/unicode.rst Mon Jun 18 19:58:50 2007 @@ -152,7 +152,7 @@ 4. Many Internet standards are defined in terms of textual data, and can't handle content with embedded zero bytes. -Generally people don't use this encoding, choosing other encodings +Generally people don't use this encoding, instead choosing other encodings that are more efficient and convenient. Encodings don't have to handle every possible Unicode character, and Modified: python/branches/py3k-struni/Doc/lib/libsqlite3.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libsqlite3.tex (original) +++ python/branches/py3k-struni/Doc/lib/libsqlite3.tex Mon Jun 18 19:58:50 2007 @@ -42,6 +42,12 @@ # Insert a row of data c.execute("""insert into stocks values ('2006-01-05','BUY','RHAT',100,35.14)""") + +# Save (commit) the changes +conn.commit() + +# We can also close the cursor if we are done with it +c.close() \end{verbatim} Usually your SQL operations will need to use values from Python Modified: python/branches/py3k-struni/Include/pyerrors.h ============================================================================== --- python/branches/py3k-struni/Include/pyerrors.h (original) +++ python/branches/py3k-struni/Include/pyerrors.h Mon Jun 18 19:58:50 2007 @@ -30,8 +30,8 @@ PyObject *args; PyObject *encoding; PyObject *object; - PyObject *start; - PyObject *end; + Py_ssize_t start; + Py_ssize_t end; PyObject *reason; } PyUnicodeErrorObject; Modified: python/branches/py3k-struni/Include/structmember.h ============================================================================== --- python/branches/py3k-struni/Include/structmember.h (original) +++ python/branches/py3k-struni/Include/structmember.h Mon Jun 18 19:58:50 2007 @@ -68,9 +68,10 @@ #ifdef HAVE_LONG_LONG #define T_LONGLONG 17 #define T_ULONGLONG 18 +#define T_PYSSIZET 19 /* Py_ssize_t */ #endif /* HAVE_LONG_LONG */ -#define T_NONE 19 /* Value is always None */ +#define T_NONE 20 /* Value is always None */ /* Flags */ #define READONLY 1 Modified: python/branches/py3k-struni/Lib/_abcoll.py ============================================================================== --- python/branches/py3k-struni/Lib/_abcoll.py (original) +++ python/branches/py3k-struni/Lib/_abcoll.py Mon Jun 18 19:58:50 2007 @@ -4,7 +4,7 @@ """Abstract Base Classes (ABCs) for collections, according to PEP 3119. DON'T USE THIS MODULE DIRECTLY! The classes here should be imported -via collections; they are defined here only to alleviate ceratin +via collections; they are defined here only to alleviate certain bootstrapping issues. Unit tests are in test_collections. """ Modified: python/branches/py3k-struni/Lib/test/regrtest.py ============================================================================== --- python/branches/py3k-struni/Lib/test/regrtest.py (original) +++ python/branches/py3k-struni/Lib/test/regrtest.py Mon Jun 18 19:58:50 2007 @@ -697,7 +697,7 @@ import gc, copy_reg import _strptime, linecache, dircache import urlparse, urllib, urllib2, mimetypes, doctest - import struct, filecmp, collections + import struct, filecmp, _abcoll from distutils.dir_util import _path_created # Restore some original values. @@ -708,8 +708,11 @@ sys.path_importer_cache.update(pic) # Clear ABC registries. - for obj in [collections.Hashable, collections.Iterable]: - obj._ABCMeta__registry.clear() + for abc in [getattr(_abcoll, a) for a in _abcoll.__all__]: + for obj in abc.__subclasses__() + [abc]: + obj._ABCMeta__registry.clear() + obj._ABCMeta__cache.clear() + obj._ABCMeta__negative_cache.clear() # Clear assorted module caches. _path_created.clear() Modified: python/branches/py3k-struni/Misc/build.sh ============================================================================== --- python/branches/py3k-struni/Misc/build.sh (original) +++ python/branches/py3k-struni/Misc/build.sh Mon Jun 18 19:58:50 2007 @@ -67,7 +67,7 @@ # Note: test_XXX (none currently) really leak, but are disabled # so we don't send spam. Any test which really leaks should only # be listed here if there are also test cases under Lib/test/leakers. -LEAKY_TESTS="test_(cmd_line|socket)" +LEAKY_TESTS="test_(cmd_line|popen2|socket|threading_local|urllib2_localnet)" # These tests always fail, so skip them so we don't get false positives. _ALWAYS_SKIP="" @@ -170,7 +170,6 @@ start=`current_time` make install >& build/$F update_status "Installing" "$F" $start - mail_on_failure "install" build/$F if [ ! -x $PYTHON ]; then ln -s ${PYTHON}3.* $PYTHON Modified: python/branches/py3k-struni/Misc/developers.txt ============================================================================== --- python/branches/py3k-struni/Misc/developers.txt (original) +++ python/branches/py3k-struni/Misc/developers.txt Mon Jun 18 19:58:50 2007 @@ -17,6 +17,10 @@ Permissions History ------------------- +- Senthil Kumaran was given SVN access on June 16 2007 + by MvL, for his Summer-of-Code project, mentored by + Skip Montanaro. + - Alexandre Vassalotti was given SVN access on May 21 2007 by MvL, for his Summer-of-Code project, mentored by Brett Cannon. Modified: python/branches/py3k-struni/Objects/exceptions.c ============================================================================== --- python/branches/py3k-struni/Objects/exceptions.c (original) +++ python/branches/py3k-struni/Objects/exceptions.c Mon Jun 18 19:58:50 2007 @@ -947,36 +947,6 @@ SimpleExtendsException(PyExc_ValueError, UnicodeError, "Unicode related error."); -static int -get_int(PyObject *attr, Py_ssize_t *value, const char *name) -{ - if (!attr) { - PyErr_Format(PyExc_TypeError, "%.200s attribute not set", name); - return -1; - } - - if (PyLong_Check(attr)) { - *value = PyLong_AsSsize_t(attr); - if (*value == -1 && PyErr_Occurred()) - return -1; - } else { - PyErr_Format(PyExc_TypeError, "%.200s attribute must be int", name); - return -1; - } - return 0; -} - -static int -set_ssize_t(PyObject **attr, Py_ssize_t value) -{ - PyObject *obj = PyInt_FromSsize_t(value); - if (!obj) - return -1; - Py_CLEAR(*attr); - *attr = obj; - return 0; -} - static PyObject * get_bytes(PyObject *attr, const char *name) { @@ -1054,40 +1024,37 @@ int PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start) { - if (!get_int(((PyUnicodeErrorObject *)exc)->start, start, "start")) { - Py_ssize_t size; - PyObject *obj = get_unicode(((PyUnicodeErrorObject *)exc)->object, - "object"); - if (!obj) return -1; - size = PyUnicode_GET_SIZE(obj); - if (*start<0) - *start = 0; /*XXX check for values <0*/ - if (*start>=size) - *start = size-1; - Py_DECREF(obj); - return 0; - } - return -1; + Py_ssize_t size; + PyObject *obj = get_unicode(((PyUnicodeErrorObject *)exc)->object, + "object"); + if (!obj) + return -1; + *start = ((PyUnicodeErrorObject *)exc)->start; + size = PyUnicode_GET_SIZE(obj); + if (*start<0) + *start = 0; /*XXX check for values <0*/ + if (*start>=size) + *start = size-1; + Py_DECREF(obj); + return 0; } int PyUnicodeDecodeError_GetStart(PyObject *exc, Py_ssize_t *start) { - if (!get_int(((PyUnicodeErrorObject *)exc)->start, start, "start")) { - Py_ssize_t size; - PyObject *obj = get_bytes(((PyUnicodeErrorObject *)exc)->object, - "object"); - if (!obj) return -1; - size = PyBytes_GET_SIZE(obj); - if (*start<0) - *start = 0; - if (*start>=size) - *start = size-1; - Py_DECREF(obj); - return 0; - } - return -1; + Py_ssize_t size; + PyObject *obj = get_bytes(((PyUnicodeErrorObject *)exc)->object, "object"); + if (!obj) + return -1; + size = PyBytes_GET_SIZE(obj); + *start = ((PyUnicodeErrorObject *)exc)->start; + if (*start<0) + *start = 0; + if (*start>=size) + *start = size-1; + Py_DECREF(obj); + return 0; } @@ -1101,61 +1068,61 @@ int PyUnicodeEncodeError_SetStart(PyObject *exc, Py_ssize_t start) { - return set_ssize_t(&((PyUnicodeErrorObject *)exc)->start, start); + ((PyUnicodeErrorObject *)exc)->start = start; + return 0; } int PyUnicodeDecodeError_SetStart(PyObject *exc, Py_ssize_t start) { - return set_ssize_t(&((PyUnicodeErrorObject *)exc)->start, start); + ((PyUnicodeErrorObject *)exc)->start = start; + return 0; } int PyUnicodeTranslateError_SetStart(PyObject *exc, Py_ssize_t start) { - return set_ssize_t(&((PyUnicodeErrorObject *)exc)->start, start); + ((PyUnicodeErrorObject *)exc)->start = start; + return 0; } int PyUnicodeEncodeError_GetEnd(PyObject *exc, Py_ssize_t *end) { - if (!get_int(((PyUnicodeErrorObject *)exc)->end, end, "end")) { - Py_ssize_t size; - PyObject *obj = get_unicode(((PyUnicodeErrorObject *)exc)->object, - "object"); - if (!obj) return -1; - size = PyUnicode_GET_SIZE(obj); - if (*end<1) - *end = 1; - if (*end>size) - *end = size; - Py_DECREF(obj); - return 0; - } - return -1; + Py_ssize_t size; + PyObject *obj = get_unicode(((PyUnicodeErrorObject *)exc)->object, + "object"); + if (!obj) + return -1; + *end = ((PyUnicodeErrorObject *)exc)->end; + size = PyUnicode_GET_SIZE(obj); + if (*end<1) + *end = 1; + if (*end>size) + *end = size; + Py_DECREF(obj); + return 0; } int PyUnicodeDecodeError_GetEnd(PyObject *exc, Py_ssize_t *end) { - if (!get_int(((PyUnicodeErrorObject *)exc)->end, end, "end")) { - Py_ssize_t size; - PyObject *obj = get_bytes(((PyUnicodeErrorObject *)exc)->object, - "object"); - if (!obj) return -1; - size = PyBytes_GET_SIZE(obj); - if (*end<1) - *end = 1; - if (*end>size) - *end = size; - Py_DECREF(obj); - return 0; - } - return -1; + Py_ssize_t size; + PyObject *obj = get_bytes(((PyUnicodeErrorObject *)exc)->object, "object"); + if (!obj) + return -1; + size = PyBytes_GET_SIZE(obj); + *end = ((PyUnicodeErrorObject *)exc)->end; + if (*end<1) + *end = 1; + if (*end>size) + *end = size; + Py_DECREF(obj); + return 0; } @@ -1169,21 +1136,24 @@ int PyUnicodeEncodeError_SetEnd(PyObject *exc, Py_ssize_t end) { - return set_ssize_t(&((PyUnicodeErrorObject *)exc)->end, end); + ((PyUnicodeErrorObject *)exc)->end = end; + return 0; } int PyUnicodeDecodeError_SetEnd(PyObject *exc, Py_ssize_t end) { - return set_ssize_t(&((PyUnicodeErrorObject *)exc)->end, end); + ((PyUnicodeErrorObject *)exc)->end = end; + return 0; } int PyUnicodeTranslateError_SetEnd(PyObject *exc, Py_ssize_t end) { - return set_ssize_t(&((PyUnicodeErrorObject *)exc)->end, end); + ((PyUnicodeErrorObject *)exc)->end = end; + return 0; } PyObject * @@ -1237,25 +1207,20 @@ { Py_CLEAR(self->encoding); Py_CLEAR(self->object); - Py_CLEAR(self->start); - Py_CLEAR(self->end); Py_CLEAR(self->reason); - if (!PyArg_ParseTuple(args, "O!O!O!O!O!", + if (!PyArg_ParseTuple(args, "O!O!nnO!", &PyUnicode_Type, &self->encoding, objecttype, &self->object, - &PyLong_Type, &self->start, - &PyLong_Type, &self->end, + &self->start, + &self->end, &PyUnicode_Type, &self->reason)) { - self->encoding = self->object = self->start = self->end = - self->reason = NULL; + self->encoding = self->object = self->reason = NULL; return -1; } Py_INCREF(self->encoding); Py_INCREF(self->object); - Py_INCREF(self->start); - Py_INCREF(self->end); Py_INCREF(self->reason); return 0; @@ -1266,8 +1231,6 @@ { Py_CLEAR(self->encoding); Py_CLEAR(self->object); - Py_CLEAR(self->start); - Py_CLEAR(self->end); Py_CLEAR(self->reason); return BaseException_clear((PyBaseExceptionObject *)self); } @@ -1285,8 +1248,6 @@ { Py_VISIT(self->encoding); Py_VISIT(self->object); - Py_VISIT(self->start); - Py_VISIT(self->end); Py_VISIT(self->reason); return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg); } @@ -1296,9 +1257,9 @@ PyDoc_STR("exception encoding")}, {"object", T_OBJECT, offsetof(PyUnicodeErrorObject, object), 0, PyDoc_STR("exception object")}, - {"start", T_OBJECT, offsetof(PyUnicodeErrorObject, start), 0, + {"start", T_PYSSIZET, offsetof(PyUnicodeErrorObject, start), 0, PyDoc_STR("exception start")}, - {"end", T_OBJECT, offsetof(PyUnicodeErrorObject, end), 0, + {"end", T_PYSSIZET, offsetof(PyUnicodeErrorObject, end), 0, PyDoc_STR("exception end")}, {"reason", T_OBJECT, offsetof(PyUnicodeErrorObject, reason), 0, PyDoc_STR("exception reason")}, @@ -1322,17 +1283,10 @@ static PyObject * UnicodeEncodeError_str(PyObject *self) { - Py_ssize_t start; - Py_ssize_t end; + PyUnicodeErrorObject *uself = (PyUnicodeErrorObject *)self; - if (PyUnicodeEncodeError_GetStart(self, &start)) - return NULL; - - if (PyUnicodeEncodeError_GetEnd(self, &end)) - return NULL; - - if (end==start+1) { - int badchar = (int)PyUnicode_AS_UNICODE(((PyUnicodeErrorObject *)self)->object)[start]; + if (uself->end==uself->start+1) { + int badchar = (int)PyUnicode_AS_UNICODE(uself->object)[uself->start]; const char *fmt; if (badchar <= 0xff) fmt = "'%U' codec can't encode character u'\\x%02x' in position %zd: %U"; @@ -1344,15 +1298,15 @@ fmt, ((PyUnicodeErrorObject *)self)->encoding, badchar, - start, + uself->start, ((PyUnicodeErrorObject *)self)->reason ); } return PyUnicode_FromFormat( "'%U' codec can't encode characters in position %zd-%zd: %U", ((PyUnicodeErrorObject *)self)->encoding, - start, - (end-1), + uself->start, + uself->end-1, ((PyUnicodeErrorObject *)self)->reason ); } @@ -1398,30 +1352,23 @@ static PyObject * UnicodeDecodeError_str(PyObject *self) { - Py_ssize_t start = 0; - Py_ssize_t end = 0; - - if (PyUnicodeDecodeError_GetStart(self, &start)) - return NULL; - - if (PyUnicodeDecodeError_GetEnd(self, &end)) - return NULL; + PyUnicodeErrorObject *uself = (PyUnicodeErrorObject *)self; - if (end==start+1) { - int byte = (int)(PyBytes_AS_STRING(((PyUnicodeErrorObject *)self)->object)[start]&0xff); + if (uself->end==uself->start+1) { + int byte = (int)(PyBytes_AS_STRING(((PyUnicodeErrorObject *)self)->object)[uself->start]&0xff); return PyUnicode_FromFormat( "'%U' codec can't decode byte 0x%02x in position %zd: %U", ((PyUnicodeErrorObject *)self)->encoding, byte, - start, + uself->start, ((PyUnicodeErrorObject *)self)->reason ); } return PyUnicode_FromFormat( "'%U' codec can't decode bytes in position %zd-%zd: %U", ((PyUnicodeErrorObject *)self)->encoding, - start, - (end-1), + uself->start, + uself->end-1, ((PyUnicodeErrorObject *)self)->reason ); } @@ -1466,22 +1413,18 @@ return -1; Py_CLEAR(self->object); - Py_CLEAR(self->start); - Py_CLEAR(self->end); Py_CLEAR(self->reason); - if (!PyArg_ParseTuple(args, "O!O!O!O!", + if (!PyArg_ParseTuple(args, "O!nnO!", &PyUnicode_Type, &self->object, - &PyLong_Type, &self->start, - &PyLong_Type, &self->end, + &self->start, + &self->end, &PyUnicode_Type, &self->reason)) { - self->object = self->start = self->end = self->reason = NULL; + self->object = self->reason = NULL; return -1; } Py_INCREF(self->object); - Py_INCREF(self->start); - Py_INCREF(self->end); Py_INCREF(self->reason); return 0; @@ -1491,17 +1434,10 @@ static PyObject * UnicodeTranslateError_str(PyObject *self) { - Py_ssize_t start; - Py_ssize_t end; - - if (PyUnicodeTranslateError_GetStart(self, &start)) - return NULL; + PyUnicodeErrorObject *uself = (PyUnicodeErrorObject *)self; - if (PyUnicodeTranslateError_GetEnd(self, &end)) - return NULL; - - if (end==start+1) { - int badchar = (int)PyUnicode_AS_UNICODE(((PyUnicodeErrorObject *)self)->object)[start]; + if (uself->end==uself->start+1) { + int badchar = (int)PyUnicode_AS_UNICODE(uself->object)[uself->start]; const char *fmt; if (badchar <= 0xff) fmt = "can't translate character u'\\x%02x' in position %zd: %U"; @@ -1512,15 +1448,15 @@ return PyUnicode_FromFormat( fmt, badchar, - start, - ((PyUnicodeErrorObject *)self)->reason + uself->start, + uself->reason ); } return PyUnicode_FromFormat( "can't translate characters in position %zd-%zd: %U", - start, - (end-1), - ((PyUnicodeErrorObject *)self)->reason + uself->start, + uself->end-1, + uself->reason ); } Modified: python/branches/py3k-struni/Objects/longobject.c ============================================================================== --- python/branches/py3k-struni/Objects/longobject.c (original) +++ python/branches/py3k-struni/Objects/longobject.c Mon Jun 18 19:58:50 2007 @@ -24,7 +24,7 @@ int quick_int_allocs, quick_neg_int_allocs; #endif -static inline PyObject * +static PyObject * get_small_int(int ival) { PyObject *v = (PyObject*)(small_ints + ival + NSMALLNEGINTS); Modified: python/branches/py3k-struni/PC/_winreg.c ============================================================================== --- python/branches/py3k-struni/PC/_winreg.c (original) +++ python/branches/py3k-struni/PC/_winreg.c Mon Jun 18 19:58:50 2007 @@ -693,9 +693,10 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize) { int i,j; + DWORD d; switch (typ) { case REG_DWORD: - if (value != Py_None && !PyInt_Check(value)) + if (value != Py_None && !PyLong_Check(value)) return FALSE; *retDataBuf = (BYTE *)PyMem_NEW(DWORD, 1); if (*retDataBuf==NULL){ @@ -707,10 +708,10 @@ DWORD zero = 0; memcpy(*retDataBuf, &zero, sizeof(DWORD)); } - else - memcpy(*retDataBuf, - &PyInt_AS_LONG((PyIntObject *)value), - sizeof(DWORD)); + else { + d = PyLong_AsLong(value); + memcpy(*retDataBuf, &d, sizeof(DWORD)); + } break; case REG_SZ: case REG_EXPAND_SZ: Modified: python/branches/py3k-struni/PC/config.c ============================================================================== --- python/branches/py3k-struni/PC/config.c (original) +++ python/branches/py3k-struni/PC/config.c Mon Jun 18 19:58:50 2007 @@ -14,11 +14,9 @@ extern void initerrno(void); extern void initgc(void); extern void initmath(void); -extern void init_md5(void); extern void initnt(void); extern void initoperator(void); extern void initsignal(void); -extern void init_sha(void); extern void init_sha256(void); extern void init_sha512(void); extern void inittime(void); @@ -61,7 +59,6 @@ extern void init_lsprof(void); extern void init_ast(void); extern void init_types(void); -extern void initatexit(void); /* tools/freeze/makeconfig.py marker for additional "extern" */ /* -- ADDMODULE MARKER 1 -- */ @@ -73,7 +70,6 @@ {"array", initarray}, {"_ast", init_ast}, - {"atexit", initatexit}, #ifdef MS_WINDOWS #ifndef MS_WINI64 {"audioop", initaudioop}, @@ -84,11 +80,9 @@ {"errno", initerrno}, {"gc", initgc}, {"math", initmath}, - {"_md5", init_md5}, {"nt", initnt}, /* Use the NT os functions, not posix */ {"operator", initoperator}, {"signal", initsignal}, - {"_sha", init_sha}, {"_sha256", init_sha256}, {"_sha512", init_sha512}, {"time", inittime}, Modified: python/branches/py3k-struni/PC/pyconfig.h ============================================================================== --- python/branches/py3k-struni/PC/pyconfig.h (original) +++ python/branches/py3k-struni/PC/pyconfig.h Mon Jun 18 19:58:50 2007 @@ -275,9 +275,9 @@ #define HAVE_LONG_LONG 1 #ifndef PY_LONG_LONG # define PY_LONG_LONG __int64 -# define PY_LLONG_MAX LLONG_MAX -# define PY_LLONG_MIN LLONG_MIN -# define PY_ULLONG_MAX ULLONG_MAX +# define PY_LLONG_MAX _I64_MAX +# define PY_LLONG_MIN _I64_MIN +# define PY_ULLONG_MAX _UI64_MAX #endif /* For Windows the Python core is in a DLL by default. Test @@ -303,9 +303,9 @@ their Makefile (other compilers are generally taken care of by distutils.) */ # ifdef _DEBUG -# pragma comment(lib,"python26_d.lib") +# pragma comment(lib,"python30_d.lib") # else -# pragma comment(lib,"python26.lib") +# pragma comment(lib,"python30.lib") # endif /* _DEBUG */ # endif /* _MSC_VER */ # endif /* Py_BUILD_CORE */ Modified: python/branches/py3k-struni/PCbuild/pythoncore.vcproj ============================================================================== --- python/branches/py3k-struni/PCbuild/pythoncore.vcproj (original) +++ python/branches/py3k-struni/PCbuild/pythoncore.vcproj Mon Jun 18 19:58:50 2007 @@ -39,15 +39,15 @@ @@ -99,15 +99,15 @@ @@ -166,15 +166,15 @@ Name="VCLinkerTool" AdditionalOptions=" /MACHINE:IA64 /USELINK:MS_SDK" AdditionalDependencies="getbuildinfo.o" - OutputFile="./python26.dll" + OutputFile="./python30.dll" LinkIncremental="1" SuppressStartupBanner="FALSE" IgnoreDefaultLibraryNames="libc" GenerateDebugInformation="TRUE" - ProgramDatabaseFile=".\./python26.pdb" + ProgramDatabaseFile=".\./python30.pdb" SubSystem="2" BaseAddress="0x1e000000" - ImportLibrary=".\./python26.lib" + ImportLibrary=".\./python30.lib" TargetMachine="0"/> @@ -233,15 +233,15 @@ Name="VCLinkerTool" AdditionalOptions=" /MACHINE:AMD64 /USELINK:MS_SDK" AdditionalDependencies="getbuildinfo.o" - OutputFile="./python26.dll" + OutputFile="./python30.dll" LinkIncremental="1" SuppressStartupBanner="TRUE" IgnoreDefaultLibraryNames="libc" GenerateDebugInformation="TRUE" - ProgramDatabaseFile=".\./python26.pdb" + ProgramDatabaseFile=".\./python30.pdb" SubSystem="2" BaseAddress="0x1e000000" - ImportLibrary=".\./python26.lib" + ImportLibrary=".\./python30.lib" TargetMachine="0"/> @@ -365,6 +365,9 @@ RelativePath="..\Modules\_codecsmodule.c"> + + - - Author: guido.van.rossum Date: Mon Jun 18 20:26:36 2007 New Revision: 56021 Modified: python/branches/py3k-struni/Lib/smtplib.py python/branches/py3k-struni/Lib/test/test_fileinput.py python/branches/py3k-struni/Lib/test/test_tokenize.py python/branches/py3k-struni/Modules/_fileio.c Log: Fix a buch of shallow test failures. Note: in test_fileinput.py, two tests are disabled until I figure out how to replace these. Modified: python/branches/py3k-struni/Lib/smtplib.py ============================================================================== --- python/branches/py3k-struni/Lib/smtplib.py (original) +++ python/branches/py3k-struni/Lib/smtplib.py Mon Jun 18 20:26:36 2007 @@ -348,7 +348,7 @@ self.close() raise SMTPServerDisconnected("Connection unexpectedly closed") if self.debuglevel > 0: print('reply:', repr(line), file=stderr) - resp.append(line[4:].strip()) + resp.append(line[4:].strip(b' \t\n')) code=line[:3] # Check that the error code is syntactically correct. # Don't attempt to read a continuation line if it is broken. @@ -361,7 +361,7 @@ if line[3:4]!="-": break - errmsg = "\n".join(resp) + errmsg = b"\n".join(resp) if self.debuglevel > 0: print('reply: retcode (%s); Msg: %s' % (errcode,errmsg), file=stderr) return errcode, errmsg Modified: python/branches/py3k-struni/Lib/test/test_fileinput.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_fileinput.py (original) +++ python/branches/py3k-struni/Lib/test/test_fileinput.py Mon Jun 18 20:26:36 2007 @@ -20,7 +20,8 @@ def writeTmp(i, lines, mode='w'): # opening in text mode is the default name = TESTFN + str(i) f = open(name, mode) - f.writelines(lines) + for line in lines: + f.write(line) f.close() return name @@ -154,17 +155,19 @@ finally: remove_tempfiles(t1, t2) - def test_unicode_filenames(self): - try: - t1 = writeTmp(1, ["A\nB"]) - encoding = sys.getfilesystemencoding() - if encoding is None: - encoding = 'ascii' - fi = FileInput(files=str(t1, encoding)) - lines = list(fi) - self.assertEqual(lines, ["A\n", "B"]) - finally: - remove_tempfiles(t1) +## def test_unicode_filenames(self): +## # XXX A unicode string is always returned by writeTmp. +## # So is this needed? +## try: +## t1 = writeTmp(1, ["A\nB"]) +## encoding = sys.getfilesystemencoding() +## if encoding is None: +## encoding = 'ascii' +## fi = FileInput(files=str(t1, encoding)) +## lines = list(fi) +## self.assertEqual(lines, ["A\n", "B"]) +## finally: +## remove_tempfiles(t1) def test_fileno(self): try: @@ -197,26 +200,28 @@ finally: remove_tempfiles(t1) - def test_file_opening_hook(self): - try: - # cannot use openhook and inplace mode - fi = FileInput(inplace=1, openhook=lambda f, m: None) - self.fail("FileInput should raise if both inplace " - "and openhook arguments are given") - except ValueError: - pass - try: - fi = FileInput(openhook=1) - self.fail("FileInput should check openhook for being callable") - except ValueError: - pass - try: - t1 = writeTmp(1, ["A\nB"], mode="wb") - fi = FileInput(files=t1, openhook=hook_encoded("rot13")) - lines = list(fi) - self.assertEqual(lines, ["N\n", "O"]) - finally: - remove_tempfiles(t1) +## def test_file_opening_hook(self): +## # XXX The rot13 codec was removed. +## # So this test needs to be changed to use something else. +## try: +## # cannot use openhook and inplace mode +## fi = FileInput(inplace=1, openhook=lambda f, m: None) +## self.fail("FileInput should raise if both inplace " +## "and openhook arguments are given") +## except ValueError: +## pass +## try: +## fi = FileInput(openhook=1) +## self.fail("FileInput should check openhook for being callable") +## except ValueError: +## pass +## try: +## t1 = writeTmp(1, ["A\nB"], mode="wb") +## fi = FileInput(files=t1, openhook=hook_encoded("rot13")) +## lines = list(fi) +## self.assertEqual(lines, ["N\n", "O"]) +## finally: +## remove_tempfiles(t1) def test_main(): run_unittest(BufferSizesTests, FileInputTests) Modified: python/branches/py3k-struni/Lib/test/test_tokenize.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_tokenize.py (original) +++ python/branches/py3k-struni/Lib/test/test_tokenize.py Mon Jun 18 20:26:36 2007 @@ -80,7 +80,7 @@ """ import os, glob, random, time, sys -from cStringIO import StringIO +from io import StringIO from test.test_support import (verbose, findfile, is_resource_enabled, TestFailed) from tokenize import (tokenize, generate_tokens, untokenize, tok_name, @@ -189,6 +189,8 @@ for f in testfiles: # Print still working message since this test can be really slow + if verbose: + print(' round trip: ', f, file=sys.__stdout__) if next_time <= time.time(): next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL print(' test_main still working, be patient...', file=sys.__stdout__) Modified: python/branches/py3k-struni/Modules/_fileio.c ============================================================================== --- python/branches/py3k-struni/Modules/_fileio.c (original) +++ python/branches/py3k-struni/Modules/_fileio.c Mon Jun 18 20:26:36 2007 @@ -705,7 +705,7 @@ static PyObject * get_mode(PyFileIOObject *self, void *closure) { - return PyString_FromString(mode_string(self)); + return PyUnicode_FromString(mode_string(self)); } static PyGetSetDef fileio_getsetlist[] = { From python-3000-checkins at python.org Mon Jun 18 20:44:33 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Mon, 18 Jun 2007 20:44:33 +0200 (CEST) Subject: [Python-3000-checkins] r56022 - in python/branches/py3k-struni: Lib/test/test_array.py Modules/arraymodule.c Message-ID: <20070618184433.8DC901E4006@bag.python.org> Author: guido.van.rossum Date: Mon Jun 18 20:44:28 2007 New Revision: 56022 Modified: python/branches/py3k-struni/Lib/test/test_array.py python/branches/py3k-struni/Modules/arraymodule.c Log: "Fix" the array module test -- by ripping out the 'c' typecode. (We already have 'b' for bytes and 'u' for unicode.) Modified: python/branches/py3k-struni/Lib/test/test_array.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_array.py (original) +++ python/branches/py3k-struni/Lib/test/test_array.py Mon Jun 18 20:44:28 2007 @@ -17,7 +17,7 @@ array.array.__init__(typecode) tests = [] # list to accumulate all tests -typecodes = "cubBhHiIlLfd" +typecodes = "ubBhHiIlLfd" class BadConstructorTest(unittest.TestCase): @@ -676,7 +676,7 @@ def test_buffer(self): a = array.array(self.typecode, self.example) - b = buffer(a) + b = bytes(buffer(a)) self.assertEqual(b[0], a.tostring()[0]) def test_weakref(self): @@ -708,44 +708,6 @@ a = array.array(self.typecode, self.example) self.assertRaises(TypeError, a.__setitem__, 0, self.example[:2]) -class CharacterTest(StringTest): - typecode = 'c' - example = '\x01azAZ\x00\xfe' - smallerexample = '\x01azAY\x00\xfe' - biggerexample = '\x01azAZ\x00\xff' - outside = '\x33' - minitemsize = 1 - - def test_subbclassing(self): - class EditableString(array.array): - def __new__(cls, s, *args, **kwargs): - return array.array.__new__(cls, 'c', s) - - def __init__(self, s, color='blue'): - self.color = color - - def strip(self): - self[:] = array.array('c', self.tostring().strip()) - - def __repr__(self): - return 'EditableString(%r)' % self.tostring() - - s = EditableString("\ttest\r\n") - s.strip() - self.assertEqual(s.tostring(), "test") - - self.assertEqual(s.color, "blue") - s.color = "red" - self.assertEqual(s.color, "red") - self.assertEqual(list(s.__dict__.keys()), ["color"]) - - def test_nounicode(self): - a = array.array(self.typecode, self.example) - self.assertRaises(ValueError, a.fromunicode, str('')) - self.assertRaises(ValueError, a.tounicode) - -tests.append(CharacterTest) - class UnicodeTest(StringTest): typecode = 'u' example = '\x01\u263a\x00\ufeff' Modified: python/branches/py3k-struni/Modules/arraymodule.c ============================================================================== --- python/branches/py3k-struni/Modules/arraymodule.c (original) +++ python/branches/py3k-struni/Modules/arraymodule.c Mon Jun 18 20:44:28 2007 @@ -102,25 +102,6 @@ ****************************************************************************/ static PyObject * -c_getitem(arrayobject *ap, Py_ssize_t i) -{ - Py_UNICODE buf[1]; - buf[0] = ((unsigned char *)ap->ob_item)[i]; - return PyUnicode_FromUnicode(buf, 1); -} - -static int -c_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v) -{ - char x; - if (!PyArg_Parse(v, "c;array item must be char", &x)) - return -1; - if (i >= 0) - ((char *)ap->ob_item)[i] = x; - return 0; -} - -static PyObject * b_getitem(arrayobject *ap, Py_ssize_t i) { long x = ((char *)ap->ob_item)[i]; @@ -391,7 +372,6 @@ /* Description of types */ static struct arraydescr descriptors[] = { - {'c', sizeof(char), c_getitem, c_setitem}, {'b', sizeof(char), b_getitem, b_setitem}, {'B', sizeof(char), BB_getitem, BB_setitem}, {'u', sizeof(Py_UNICODE), u_getitem, u_setitem}, @@ -1403,8 +1383,8 @@ static PyObject * array_tostring(arrayobject *self, PyObject *unused) { - return PyString_FromStringAndSize(self->ob_item, - self->ob_size * self->ob_descr->itemsize); + return PyBytes_FromStringAndSize(self->ob_item, + self->ob_size * self->ob_descr->itemsize); } PyDoc_STRVAR(tostring_doc, @@ -1562,9 +1542,7 @@ if (len == 0) { return PyUnicode_FromFormat("array('%c')", typecode); } - if (typecode == 'c') - v = array_tostring(a, NULL); - else if (typecode == 'u') + if (typecode == 'u') v = array_tounicode(a, NULL); else v = array_tolist(a, NULL); @@ -1899,7 +1877,7 @@ } } PyErr_SetString(PyExc_ValueError, - "bad typecode (must be c, b, B, u, h, H, i, I, l, L, f or d)"); + "bad typecode (must be b, B, u, h, H, i, I, l, L, f or d)"); return NULL; } @@ -1913,7 +1891,6 @@ is a single character. The following type codes are defined:\n\ \n\ Type code C Type Minimum size in bytes \n\ - 'c' character 1 \n\ 'b' signed integer 1 \n\ 'B' unsigned integer 1 \n\ 'u' Unicode character 2 \n\ From python-3000-checkins at python.org Tue Jun 19 14:33:23 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Tue, 19 Jun 2007 14:33:23 +0200 (CEST) Subject: [Python-3000-checkins] r56037 - python/branches/p3yk/Lib/pydoc.py Message-ID: <20070619123323.6F5CC1E401C@bag.python.org> Author: georg.brandl Date: Tue Jun 19 14:33:20 2007 New Revision: 56037 Modified: python/branches/p3yk/Lib/pydoc.py Log: Patch #1739659: don't slice dict.keys() in pydoc. Modified: python/branches/p3yk/Lib/pydoc.py ============================================================================== --- python/branches/p3yk/Lib/pydoc.py (original) +++ python/branches/p3yk/Lib/pydoc.py Tue Jun 19 14:33:20 2007 @@ -1750,17 +1750,16 @@ ''' % sys.version[:3]) def list(self, items, columns=4, width=80): - items = items[:] - items.sort() - colw = width / columns - rows = (len(items) + columns - 1) / columns + items = list(sorted(items)) + colw = width // columns + rows = (len(items) + columns - 1) // columns for row in range(rows): for col in range(columns): i = col * rows + row if i < len(items): self.output.write(items[i]) if col < columns - 1: - self.output.write(' ' + ' ' * (colw-1 - len(items[i]))) + self.output.write(' ' + ' ' * (colw - 1 - len(items[i]))) self.output.write('\n') def listkeywords(self): From nnorwitz at gmail.com Wed Jun 20 02:49:52 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Tue, 19 Jun 2007 20:49:52 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures basics (1) Message-ID: <20070620004952.GA3154@python.psfb.org> test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_unittest test_doctest test_doctest2 test_StringIO test___all__ test___future__ test__locale test_abc test_aepack test_aepack skipped -- No module named aepack test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat Exception in thread Thread-1: Traceback (most recent call last): File "/tmp/python-test-3.0/local/lib/python3.0/threading.py", line 464, in __bootstrap self.run() File "/tmp/python-test-3.0/local/lib/python3.0/test/test_asynchat.py", line 17, in run PORT = test_support.bind_port(sock, HOST, PORT) File "/tmp/python-test-3.0/local/lib/python3.0/test/test_support.py", line 109, in bind_port (err, msg) = e TypeError: 'error' object is not iterable test_atexit test_audioop test_augassign test_base64 test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_buffer test_bufio test_bytes test_bz2 test test_bz2 failed -- Traceback (most recent call last): File "/tmp/python-test-3.0/local/lib/python3.0/test/test_bz2.py", line 236, in testOpenDel o = BZ2File(self.filename) IOError: [Errno 2] No such file or directory: '@test' test_cProfile test_calendar test_call test_capi test_cfgparser test_cgi test_charmapcodec test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_cn skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_hk test_codecmaps_hk skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_jp test_codecmaps_jp skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_kr test_codecmaps_kr skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_tw test_codecmaps_tw skipped -- Use of the `urlfetch' resource not enabled test_codecs test_codeop test_coding test_collections test_colorsys test_commands test_compare test_compile test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test test_cpickle failed -- Traceback (most recent call last): File "/tmp/python-test-3.0/local/lib/python3.0/test/pickletester.py", line 946, in test_dump_closed_file os.remove(TESTFN) OSError: [Errno 2] No such file or directory: '@test' test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictviews test_difflib test_dircache test_dis test_distutils test_dl test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_ftplib test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imaplib test_imp test_import test_importhooks test_index test_inspect test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_keywordonlyarg test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_listcomps test_locale test_logging test_long test_long_future test_longexp test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_metaclass test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_normalization test_normalization skipped -- Use of the `urlfetch' resource not enabled test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [12922 refs] [12922 refs] [12922 refs] test_poplib test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [13806 refs] [13806 refs] test_random test_re test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sgmllib test_shelve test_shlex test_shutil test_signal test_site test_slice test_smtplib test_socket test_socket_ssl test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strptime test_struct test_structmembers test_structseq test_subprocess [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [16188 refs] [13132 refs] [12916 refs] [12917 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] . [12916 refs] [12916 refs] this bit of output is from a test of stdout in a different process ... [12916 refs] [12916 refs] [13132 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_super test_symtable test_syntax test_sys [12916 refs] [12916 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [12918 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_tuple test_typechecks test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_unpack test_unpack_ex test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmlrpc test_xpickle test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zlib 289 tests OK. 2 tests failed: test_bz2 test_cpickle 28 tests skipped: test_aepack test_applesingle test_bsddb3 test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_curses test_ioctl test_linuxaudiodev test_macostools test_normalization test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 2 skips unexpected on linux2: test_tcl test_ioctl [638103 refs] From nnorwitz at gmail.com Wed Jun 20 02:58:42 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Tue, 19 Jun 2007 20:58:42 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures opt (1) Message-ID: <20070620005842.GA3966@python.psfb.org> test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_unittest test_doctest test_doctest2 test_StringIO test___all__ test___future__ test__locale test_abc test_aepack test_aepack skipped -- No module named aepack test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_buffer test_bufio test_bytes test_bz2 test test_bz2 failed -- Traceback (most recent call last): File "/tmp/python-test-3.0/local/lib/python3.0/test/test_bz2.py", line 236, in testOpenDel o = BZ2File(self.filename) IOError: [Errno 2] No such file or directory: '@test' test_cProfile test_calendar test_call test_capi test_cfgparser test_cgi test_charmapcodec test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_cn skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_hk test_codecmaps_hk skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_jp test_codecmaps_jp skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_kr test_codecmaps_kr skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_tw test_codecmaps_tw skipped -- Use of the `urlfetch' resource not enabled test_codecs test_codeop test_coding test_collections test_colorsys test_commands test_compare test_compile test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictviews test_difflib test_dircache test_dis test_distutils [16353 refs] test_dl test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_ftplib test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imaplib test_imp test_import test_importhooks test_index test_inspect test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_keywordonlyarg test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_listcomps test_locale test_logging test_long test_long_future test_longexp test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_metaclass test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_normalization test_normalization skipped -- Use of the `urlfetch' resource not enabled test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [12922 refs] [12922 refs] [12922 refs] test_poplib test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [13806 refs] [13806 refs] test_random test_re test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sgmllib test_shelve test_shlex test_shutil test_signal test_site test_slice test_smtplib test_socket test_socket_ssl test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strptime test_struct test_structmembers test_structseq test_subprocess [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [16188 refs] [13132 refs] [12916 refs] [12917 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] . [12916 refs] [12916 refs] this bit of output is from a test of stdout in a different process ... [12916 refs] [12916 refs] [13132 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_super test_symtable test_syntax test_sys [12916 refs] [12916 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [12918 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_tuple test_typechecks test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_unpack test_unpack_ex test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmlrpc test_xpickle test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zlib 290 tests OK. 1 test failed: test_bz2 28 tests skipped: test_aepack test_applesingle test_bsddb3 test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_curses test_ioctl test_linuxaudiodev test_macostools test_normalization test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 2 skips unexpected on linux2: test_tcl test_ioctl [637294 refs] From python-3000-checkins at python.org Wed Jun 20 11:25:36 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Wed, 20 Jun 2007 11:25:36 +0200 (CEST) Subject: [Python-3000-checkins] r56043 - in python/branches/py3k-struni: Lib/test/test_codeccallbacks.py Lib/test/test_codecs.py Objects/exceptions.c Message-ID: <20070620092536.47AA81E4002@bag.python.org> Author: walter.doerwald Date: Wed Jun 20 11:25:34 2007 New Revision: 56043 Modified: python/branches/py3k-struni/Lib/test/test_codeccallbacks.py python/branches/py3k-struni/Lib/test/test_codecs.py python/branches/py3k-struni/Objects/exceptions.c Log: Patch by Ron Adam: Don't use u prefix in unicode error messages and remove u prefix from some comments in test_codecs.py. Modified: python/branches/py3k-struni/Lib/test/test_codeccallbacks.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_codeccallbacks.py (original) +++ python/branches/py3k-struni/Lib/test/test_codeccallbacks.py Wed Jun 20 11:25:34 2007 @@ -329,7 +329,7 @@ self.check_exceptionobjectargs( UnicodeEncodeError, ["ascii", "g\xfcrk", 1, 2, "ouch"], - "'ascii' codec can't encode character u'\\xfc' in position 1: ouch" + "'ascii' codec can't encode character '\\xfc' in position 1: ouch" ) self.check_exceptionobjectargs( UnicodeEncodeError, @@ -339,23 +339,23 @@ self.check_exceptionobjectargs( UnicodeEncodeError, ["ascii", "\xfcx", 0, 1, "ouch"], - "'ascii' codec can't encode character u'\\xfc' in position 0: ouch" + "'ascii' codec can't encode character '\\xfc' in position 0: ouch" ) self.check_exceptionobjectargs( UnicodeEncodeError, ["ascii", "\u0100x", 0, 1, "ouch"], - "'ascii' codec can't encode character u'\\u0100' in position 0: ouch" + "'ascii' codec can't encode character '\\u0100' in position 0: ouch" ) self.check_exceptionobjectargs( UnicodeEncodeError, ["ascii", "\uffffx", 0, 1, "ouch"], - "'ascii' codec can't encode character u'\\uffff' in position 0: ouch" + "'ascii' codec can't encode character '\\uffff' in position 0: ouch" ) if sys.maxunicode > 0xffff: self.check_exceptionobjectargs( UnicodeEncodeError, ["ascii", "\U00010000x", 0, 1, "ouch"], - "'ascii' codec can't encode character u'\\U00010000' in position 0: ouch" + "'ascii' codec can't encode character '\\U00010000' in position 0: ouch" ) def test_unicodedecodeerror(self): @@ -374,23 +374,23 @@ self.check_exceptionobjectargs( UnicodeTranslateError, ["g\xfcrk", 1, 2, "ouch"], - "can't translate character u'\\xfc' in position 1: ouch" + "can't translate character '\\xfc' in position 1: ouch" ) self.check_exceptionobjectargs( UnicodeTranslateError, ["g\u0100rk", 1, 2, "ouch"], - "can't translate character u'\\u0100' in position 1: ouch" + "can't translate character '\\u0100' in position 1: ouch" ) self.check_exceptionobjectargs( UnicodeTranslateError, ["g\uffffrk", 1, 2, "ouch"], - "can't translate character u'\\uffff' in position 1: ouch" + "can't translate character '\\uffff' in position 1: ouch" ) if sys.maxunicode > 0xffff: self.check_exceptionobjectargs( UnicodeTranslateError, ["g\U00010000rk", 1, 2, "ouch"], - "can't translate character u'\\U00010000' in position 1: ouch" + "can't translate character '\\U00010000' in position 1: ouch" ) self.check_exceptionobjectargs( UnicodeTranslateError, Modified: python/branches/py3k-struni/Lib/test/test_codecs.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_codecs.py (original) +++ python/branches/py3k-struni/Lib/test/test_codecs.py Wed Jun 20 11:25:34 2007 @@ -459,10 +459,10 @@ "", "\ufeff", # Second BOM has been read and emitted "\ufeff\x00", # "\x00" read and emitted - "\ufeff\x00", # First byte of encoded u"\xff" read - "\ufeff\x00\xff", # Second byte of encoded u"\xff" read - "\ufeff\x00\xff", # First byte of encoded u"\u07ff" read - "\ufeff\x00\xff\u07ff", # Second byte of encoded u"\u07ff" read + "\ufeff\x00", # First byte of encoded "\xff" read + "\ufeff\x00\xff", # Second byte of encoded "\xff" read + "\ufeff\x00\xff", # First byte of encoded "\u07ff" read + "\ufeff\x00\xff\u07ff", # Second byte of encoded "\u07ff" read "\ufeff\x00\xff\u07ff", "\ufeff\x00\xff\u07ff", "\ufeff\x00\xff\u07ff\u0800", Modified: python/branches/py3k-struni/Objects/exceptions.c ============================================================================== --- python/branches/py3k-struni/Objects/exceptions.c (original) +++ python/branches/py3k-struni/Objects/exceptions.c Wed Jun 20 11:25:34 2007 @@ -1289,11 +1289,11 @@ int badchar = (int)PyUnicode_AS_UNICODE(uself->object)[uself->start]; const char *fmt; if (badchar <= 0xff) - fmt = "'%U' codec can't encode character u'\\x%02x' in position %zd: %U"; + fmt = "'%U' codec can't encode character '\\x%02x' in position %zd: %U"; else if (badchar <= 0xffff) - fmt = "'%U' codec can't encode character u'\\u%04x' in position %zd: %U"; + fmt = "'%U' codec can't encode character '\\u%04x' in position %zd: %U"; else - fmt = "'%U' codec can't encode character u'\\U%08x' in position %zd: %U"; + fmt = "'%U' codec can't encode character '\\U%08x' in position %zd: %U"; return PyUnicode_FromFormat( fmt, ((PyUnicodeErrorObject *)self)->encoding, @@ -1440,11 +1440,11 @@ int badchar = (int)PyUnicode_AS_UNICODE(uself->object)[uself->start]; const char *fmt; if (badchar <= 0xff) - fmt = "can't translate character u'\\x%02x' in position %zd: %U"; + fmt = "can't translate character '\\x%02x' in position %zd: %U"; else if (badchar <= 0xffff) - fmt = "can't translate character u'\\u%04x' in position %zd: %U"; + fmt = "can't translate character '\\u%04x' in position %zd: %U"; else - fmt = "can't translate character u'\\U%08x' in position %zd: %U"; + fmt = "can't translate character '\\U%08x' in position %zd: %U"; return PyUnicode_FromFormat( fmt, badchar, From python-3000-checkins at python.org Wed Jun 20 13:02:47 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Wed, 20 Jun 2007 13:02:47 +0200 (CEST) Subject: [Python-3000-checkins] r56044 - in python/branches/py3k-struni: Lib/test/test_datetime.py Modules/datetimemodule.c Python/getargs.c Python/modsupport.c Message-ID: <20070620110247.4E6E31E400D@bag.python.org> Author: walter.doerwald Date: Wed Jun 20 13:02:38 2007 New Revision: 56044 Modified: python/branches/py3k-struni/Lib/test/test_datetime.py python/branches/py3k-struni/Modules/datetimemodule.c python/branches/py3k-struni/Python/getargs.c python/branches/py3k-struni/Python/modsupport.c Log: Change %c format specifier for PyArg_ParseTuple() so that it accepts a unicode character (an int * must be passed as the argument). Change %c format specifier for Py_BuildValue() so that it outputs a unicode object. Fix datetime.datetime.isoformat(), so that it works if sep is a unicode character > U+00FF. Modified: python/branches/py3k-struni/Lib/test/test_datetime.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_datetime.py (original) +++ python/branches/py3k-struni/Lib/test/test_datetime.py Wed Jun 20 13:02:38 2007 @@ -2749,6 +2749,7 @@ self.assertEqual(iso, datestr + 'T' + tailstr) self.assertEqual(iso, d.isoformat('T')) self.assertEqual(d.isoformat('k'), datestr + 'k' + tailstr) + self.assertEqual(d.isoformat('\u1234'), datestr + '\u1234' + tailstr) self.assertEqual(str(d), datestr + ' ' + tailstr) def test_replace(self): Modified: python/branches/py3k-struni/Modules/datetimemodule.c ============================================================================== --- python/branches/py3k-struni/Modules/datetimemodule.c (original) +++ python/branches/py3k-struni/Modules/datetimemodule.c Wed Jun 20 13:02:38 2007 @@ -4027,7 +4027,7 @@ static PyObject * datetime_isoformat(PyDateTime_DateTime *self, PyObject *args, PyObject *kw) { - char sep = 'T'; + int sep = 'T'; static char *keywords[] = {"sep", NULL}; char buffer[100]; PyObject *result; Modified: python/branches/py3k-struni/Python/getargs.c ============================================================================== --- python/branches/py3k-struni/Python/getargs.c (original) +++ python/branches/py3k-struni/Python/getargs.c Wed Jun 20 13:02:38 2007 @@ -761,15 +761,14 @@ #endif /* WITHOUT_COMPLEX */ case 'c': {/* char */ - char *p = va_arg(*p_va, char *); + int *p = va_arg(*p_va, int *); if (PyString_Check(arg) && PyString_Size(arg) == 1) *p = PyString_AS_STRING(arg)[0]; else if (PyUnicode_Check(arg) && - PyUnicode_GET_SIZE(arg) == 1 && - PyUnicode_AS_UNICODE(arg)[0] < 256) + PyUnicode_GET_SIZE(arg) == 1) *p = PyUnicode_AS_UNICODE(arg)[0]; else - return converterr("char < 256", arg, msgbuf, bufsize); + return converterr("char", arg, msgbuf, bufsize); break; } Modified: python/branches/py3k-struni/Python/modsupport.c ============================================================================== --- python/branches/py3k-struni/Python/modsupport.c (original) +++ python/branches/py3k-struni/Python/modsupport.c Wed Jun 20 13:02:38 2007 @@ -385,9 +385,22 @@ case 'c': { - char p[1]; - p[0] = (char)va_arg(*p_va, int); - return PyString_FromStringAndSize(p, 1); + int i = va_arg(*p_va, int); + Py_UNICODE c; + if (i < 0 || i > PyUnicode_GetMax()) { +#ifdef Py_UNICODE_WIDE + PyErr_SetString(PyExc_OverflowError, + "%c arg not in range(0x110000) " + "(wide Python build)"); +#else + PyErr_SetString(PyExc_OverflowError, + "%c arg not in range(0x10000) " + "(narrow Python build)"); +#endif + return NULL; + } + c = i; + return PyUnicode_FromUnicode(&c, 1); } case 's': From python-3000-checkins at python.org Wed Jun 20 14:37:02 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Wed, 20 Jun 2007 14:37:02 +0200 (CEST) Subject: [Python-3000-checkins] r56046 - python/branches/py3k-struni/Modules/cPickle.c Message-ID: <20070620123702.39ED11E4009@bag.python.org> Author: walter.doerwald Date: Wed Jun 20 14:37:01 2007 New Revision: 56046 Modified: python/branches/py3k-struni/Modules/cPickle.c Log: Make pickle errror message unicode objects. Modified: python/branches/py3k-struni/Modules/cPickle.c ============================================================================== --- python/branches/py3k-struni/Modules/cPickle.c (original) +++ python/branches/py3k-struni/Modules/cPickle.c Wed Jun 20 14:37:01 2007 @@ -393,13 +393,13 @@ if (format) args = Py_VaBuildValue(format, va); va_end(va); if (format && ! args) return NULL; - if (stringformat && !(retval=PyString_FromString(stringformat))) + if (stringformat && !(retval=PyUnicode_FromString(stringformat))) return NULL; if (retval) { if (args) { PyObject *v; - v=PyString_Format(retval, args); + v=PyUnicode_Format(retval, args); Py_DECREF(retval); Py_DECREF(args); if (! v) return NULL; From python-3000-checkins at python.org Wed Jun 20 14:46:34 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Wed, 20 Jun 2007 14:46:34 +0200 (CEST) Subject: [Python-3000-checkins] r56047 - python/branches/py3k-struni/Lib/test/pickletester.py Message-ID: <20070620124634.74F7B1E4018@bag.python.org> Author: walter.doerwald Date: Wed Jun 20 14:46:31 2007 New Revision: 56047 Modified: python/branches/py3k-struni/Lib/test/pickletester.py Log: Open files in binary mode. Modified: python/branches/py3k-struni/Lib/test/pickletester.py ============================================================================== --- python/branches/py3k-struni/Lib/test/pickletester.py (original) +++ python/branches/py3k-struni/Lib/test/pickletester.py Wed Jun 20 14:46:31 2007 @@ -936,7 +936,7 @@ def test_dump_closed_file(self): import os - f = open(TESTFN, "w") + f = open(TESTFN, "wb") try: f.close() self.assertRaises(ValueError, self.module.dump, 123, f) @@ -945,7 +945,7 @@ def test_load_closed_file(self): import os - f = open(TESTFN, "w") + f = open(TESTFN, "wb") try: f.close() self.assertRaises(ValueError, self.module.dump, 123, f) From python-3000-checkins at python.org Wed Jun 20 16:55:06 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Wed, 20 Jun 2007 16:55:06 +0200 (CEST) Subject: [Python-3000-checkins] r56048 - python/branches/py3k-struni/Modules/threadmodule.c Message-ID: <20070620145506.A178C1E400C@bag.python.org> Author: walter.doerwald Date: Wed Jun 20 16:55:01 2007 New Revision: 56048 Modified: python/branches/py3k-struni/Modules/threadmodule.c Log: Make "thread.local" key a unicode object. Modified: python/branches/py3k-struni/Modules/threadmodule.c ============================================================================== --- python/branches/py3k-struni/Modules/threadmodule.c (original) +++ python/branches/py3k-struni/Modules/threadmodule.c Wed Jun 20 16:55:01 2007 @@ -191,7 +191,7 @@ Py_XINCREF(kw); self->kw = kw; self->dict = NULL; /* making sure */ - self->key = PyString_FromFormat("thread.local.%p", self); + self->key = PyUnicode_FromFormat("thread.local.%p", self); if (self->key == NULL) goto err; From python-3000-checkins at python.org Wed Jun 20 17:11:17 2007 From: python-3000-checkins at python.org (walter.doerwald) Date: Wed, 20 Jun 2007 17:11:17 +0200 (CEST) Subject: [Python-3000-checkins] r56049 - python/branches/py3k-struni/Objects/unicodeobject.c Message-ID: <20070620151117.0A5C91E4002@bag.python.org> Author: walter.doerwald Date: Wed Jun 20 17:11:12 2007 New Revision: 56049 Modified: python/branches/py3k-struni/Objects/unicodeobject.c Log: Silence GCC warning about uninitialzed variable. Simplify formatlong() (by using PyUnicode_FromStringAndSize()). Modified: python/branches/py3k-struni/Objects/unicodeobject.c ============================================================================== --- python/branches/py3k-struni/Objects/unicodeobject.c (original) +++ python/branches/py3k-struni/Objects/unicodeobject.c Wed Jun 20 17:11:12 2007 @@ -540,7 +540,7 @@ va_list count; Py_ssize_t callcount = 0; PyObject **callresults = NULL; - PyObject **callresult; + PyObject **callresult = NULL; Py_ssize_t n = 0; int width = 0; int precision = 0; @@ -7955,23 +7955,16 @@ formatlong(PyObject *val, int flags, int prec, int type) { char *buf; - int i, len; + int len; PyObject *str; /* temporary string object. */ - PyUnicodeObject *result; + PyObject *result; str = _PyString_FormatLong(val, flags, prec, type, &buf, &len); if (!str) return NULL; - result = _PyUnicode_New(len); - if (!result) { - Py_DECREF(str); - return NULL; - } - for (i = 0; i < len; i++) - result->str[i] = buf[i]; - result->str[len] = 0; + result = PyUnicode_FromStringAndSize(buf, len); Py_DECREF(str); - return (PyObject*)result; + return result; } static int From nnorwitz at gmail.com Thu Jun 21 16:33:07 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 21 Jun 2007 10:33:07 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures refleak (1) Message-ID: <20070621143307.GA29210@python.psfb.org> test_sys leaked [-132, 132, -132] references, sum=-132 test_threading_local leaked [0, 0, -91] references, sum=-91 test_urllib2_localnet leaked [3, 3, 3] references, sum=9 From nnorwitz at gmail.com Fri Jun 22 02:53:00 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 21 Jun 2007 20:53:00 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures basics (1) Message-ID: <20070622005300.GA27766@python.psfb.org> test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_unittest test_doctest test_doctest2 test_StringIO test___all__ test___future__ test__locale test_abc test_aepack test_aepack skipped -- No module named aepack test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_buffer test_bufio test_bytes test_bz2 test_cProfile test_calendar test_call test_capi test_cfgparser test_cgi test_charmapcodec test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_cn skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_hk test_codecmaps_hk skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_jp test_codecmaps_jp skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_kr test_codecmaps_kr skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_tw test_codecmaps_tw skipped -- Use of the `urlfetch' resource not enabled test_codecs test_codeop test_coding test_collections test_colorsys test_commands test_compare test_compile test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictviews test_difflib test test_difflib failed -- Traceback (most recent call last): File "/tmp/python-test-3.0/local/lib/python3.0/doctest.py", line 2107, in runTest raise self.failureException(self.format_failure(new.getvalue())) AssertionError: Failed doctest test for difflib.get_close_matches File "/tmp/python-test-3.0/local/lib/python3.0/difflib.py", line 699, in get_close_matches ---------------------------------------------------------------------- File "/tmp/python-test-3.0/local/lib/python3.0/difflib.py", line 722, in difflib.get_close_matches Failed example: get_close_matches("apple", _keyword.kwlist) Expected: [] Got: ['False'] test_dircache test_dis test_distutils test_dl test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_ftplib test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imaplib test_imp test_import test_importhooks test_index test_inspect test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_keywordonlyarg test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_listcomps test_locale test_logging test_long test_long_future test_longexp test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_metaclass test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_normalization test_normalization skipped -- Use of the `urlfetch' resource not enabled test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [12922 refs] [12922 refs] [12922 refs] test_poplib test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [13806 refs] [13806 refs] test_random test_re test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sgmllib test_shelve test_shlex test_shutil test_signal test_site test_slice test_smtplib test_socket test_socket_ssl test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strptime test_struct test_structmembers test_structseq test_subprocess [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [16188 refs] [13132 refs] [12916 refs] [12917 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] . [12916 refs] [12916 refs] this bit of output is from a test of stdout in a different process ... [12916 refs] [12916 refs] [13132 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_super test_symtable test_syntax test_sys [12916 refs] [12916 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [12918 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_tuple test_typechecks test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_unpack test_unpack_ex test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmlrpc test_xpickle test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zlib 290 tests OK. 1 test failed: test_difflib 28 tests skipped: test_aepack test_applesingle test_bsddb3 test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_curses test_ioctl test_linuxaudiodev test_macostools test_normalization test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 2 skips unexpected on linux2: test_tcl test_ioctl [638104 refs] From nnorwitz at gmail.com Fri Jun 22 03:01:59 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 21 Jun 2007 21:01:59 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures opt (1) Message-ID: <20070622010159.GA28498@python.psfb.org> test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_unittest test_doctest test_doctest2 test_StringIO test___all__ test___future__ test__locale test_abc test_aepack test_aepack skipped -- No module named aepack test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_buffer test_bufio test_bytes test_bz2 test_cProfile test_calendar test_call test_capi test_cfgparser test_cgi test_charmapcodec test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_cn skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_hk test_codecmaps_hk skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_jp test_codecmaps_jp skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_kr test_codecmaps_kr skipped -- Use of the `urlfetch' resource not enabled test_codecmaps_tw test_codecmaps_tw skipped -- Use of the `urlfetch' resource not enabled test_codecs test_codeop test_coding test_collections test_colorsys test_commands test_compare test_compile test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictviews test_difflib test test_difflib failed -- Traceback (most recent call last): File "/tmp/python-test-3.0/local/lib/python3.0/doctest.py", line 2107, in runTest raise self.failureException(self.format_failure(new.getvalue())) AssertionError: Failed doctest test for difflib.get_close_matches File "/tmp/python-test-3.0/local/lib/python3.0/difflib.py", line 699, in get_close_matches ---------------------------------------------------------------------- File "/tmp/python-test-3.0/local/lib/python3.0/difflib.py", line 722, in difflib.get_close_matches Failed example: get_close_matches("apple", _keyword.kwlist) Expected: [] Got: ['False'] test_dircache test_dis test_distutils [16353 refs] test_dl test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_ftplib test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imaplib test_imp test_import test_importhooks test_index test_inspect test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_keywordonlyarg test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_listcomps test_locale test_logging test_long test_long_future test_longexp test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_metaclass test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_normalization test_normalization skipped -- Use of the `urlfetch' resource not enabled test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [12922 refs] [12922 refs] [12922 refs] test_poplib test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [13806 refs] [13806 refs] test_random test_re test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sgmllib test_shelve test_shlex test_shutil test_signal test_site test_slice test_smtplib test_socket test_socket_ssl test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strptime test_struct test_structmembers test_structseq test_subprocess [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [16188 refs] [13132 refs] [12916 refs] [12917 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] . [12916 refs] [12916 refs] this bit of output is from a test of stdout in a different process ... [12916 refs] [12916 refs] [13132 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_super test_symtable test_syntax test_sys [12916 refs] [12916 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [12918 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_tuple test_typechecks test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_unpack test_unpack_ex test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmlrpc test_xpickle test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zlib 290 tests OK. 1 test failed: test_difflib 28 tests skipped: test_aepack test_applesingle test_bsddb3 test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_curses test_ioctl test_linuxaudiodev test_macostools test_normalization test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 2 skips unexpected on linux2: test_tcl test_ioctl [637295 refs] From nnorwitz at gmail.com Fri Jun 22 04:48:03 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 21 Jun 2007 22:48:03 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures all (1) Message-ID: <20070622024803.GA3503@python.psfb.org> test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_unittest test_doctest test_doctest2 test_StringIO test___all__ test___future__ test__locale test_abc test_aepack test_aepack skipped -- No module named aepack test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb3 test_buffer test_bufio test_bytes test_bz2 test_cProfile test_calendar test_call test_capi test_cfgparser test_cgi test_charmapcodec test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_collections test_colorsys test_commands test_compare test_compile test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictviews test_difflib test test_difflib failed -- Traceback (most recent call last): File "/tmp/python-test-3.0/local/lib/python3.0/doctest.py", line 2107, in runTest raise self.failureException(self.format_failure(new.getvalue())) AssertionError: Failed doctest test for difflib.get_close_matches File "/tmp/python-test-3.0/local/lib/python3.0/difflib.py", line 699, in get_close_matches ---------------------------------------------------------------------- File "/tmp/python-test-3.0/local/lib/python3.0/difflib.py", line 722, in difflib.get_close_matches Failed example: get_close_matches("apple", _keyword.kwlist) Expected: [] Got: ['False'] test_dircache test_dis test_distutils test_dl test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_ftplib test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imaplib test_imp test_import test_importhooks test_index test_inspect test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_keywordonlyarg test_largefile test_list test_listcomps test_locale test_logging test_long test_long_future test_longexp test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_metaclass test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [12922 refs] [12922 refs] [12922 refs] test_poplib test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [13806 refs] [13806 refs] test_random test_re test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sgmllib test_shelve test_shlex test_shutil test_signal test_site test_slice test_smtplib test_socket test_socket_ssl test_socketserver test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strptime test_struct test_structmembers test_structseq test_subprocess [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [16188 refs] [13132 refs] [12916 refs] [12917 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] . [12916 refs] [12916 refs] this bit of output is from a test of stdout in a different process ... [12916 refs] [12916 refs] [13132 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_super test_symtable test_syntax test_sys [12916 refs] [12916 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [12918 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_tokenize test_trace test_traceback test_tuple test_typechecks test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_unpack test_unpack_ex test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllibnet test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmlrpc test_xpickle test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zlib 301 tests OK. 1 test failed: test_difflib 14 tests skipped: test_aepack test_applesingle test_ioctl test_macostools test_pep277 test_plistlib test_scriptpackages test_startfile test_sunaudiodev test_tcl test_unicode_file test_winreg test_winsound test_zipfile64 2 skips unexpected on linux2: test_tcl test_ioctl warning: DBTxn aborted in destructor. No prior commit() or abort(). [652080 refs] From nnorwitz at gmail.com Fri Jun 22 16:32:37 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Fri, 22 Jun 2007 10:32:37 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures refleak (1) Message-ID: <20070622143237.GA6730@python.psfb.org> test_sys leaked [0, 0, 132] references, sum=132 test_threading_local leaked [0, 0, -91] references, sum=-91 test_urllib2_localnet leaked [3, 3, 3] references, sum=9 From nnorwitz at gmail.com Fri Jun 22 16:49:13 2007 From: nnorwitz at gmail.com (Neal Norwitz) Date: Fri, 22 Jun 2007 10:49:13 -0400 Subject: [Python-3000-checkins] Python Regression Test Failures all (1) Message-ID: <20070622144913.GA8516@python.psfb.org> test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_unittest test_doctest test_doctest2 test_StringIO test___all__ test___future__ test__locale test_abc test_aepack test_aepack skipped -- No module named aepack test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb3 test_buffer test_bufio test_bytes test_bz2 test_cProfile test_calendar test_call test_capi test_cfgparser test_cgi test_charmapcodec test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_collections test_colorsys test_commands test_compare test_compile test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictviews test_difflib test_dircache test_dis test_distutils test_dl test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_ftplib test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imaplib test_imp test_import test_importhooks test_index test_inspect test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_keywordonlyarg test_largefile test_list test_listcomps test_locale test_logging test_long test_long_future test_longexp test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_metaclass test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [12922 refs] [12922 refs] [12922 refs] test_poplib test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [13806 refs] [13806 refs] test_random test_re test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sgmllib test_shelve test_shlex test_shutil test_signal test_site test_slice test_smtplib test_socket test_socket_ssl test test_socket_ssl failed -- Traceback (most recent call last): File "/tmp/python-test-3.0/local/lib/python3.0/test/test_socket_ssl.py", line 30, in testBasic f = urllib.urlopen('https://sf.net') File "/tmp/python-test-3.0/local/lib/python3.0/urllib.py", line 81, in urlopen return opener.open(url) File "/tmp/python-test-3.0/local/lib/python3.0/urllib.py", line 189, in open return getattr(self, name)(url) File "/tmp/python-test-3.0/local/lib/python3.0/urllib.py", line 425, in open_https 'got a bad status line', None) IOError: ('http protocol error', 0, 'got a bad status line', None) test_socketserver test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strptime test_struct test_structmembers test_structseq test_subprocess [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] [16188 refs] [13132 refs] [12916 refs] [12917 refs] [12916 refs] [12916 refs] [12916 refs] [12916 refs] . [12916 refs] [12916 refs] this bit of output is from a test of stdout in a different process ... [12916 refs] [12916 refs] [13132 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_super test_symtable test_syntax test_sys [12916 refs] [12916 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [12921 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_tokenize test_trace test_traceback test_tuple test_typechecks test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_unpack test_unpack_ex test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllibnet test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmlrpc test_xpickle test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zlib 301 tests OK. 1 test failed: test_socket_ssl 14 tests skipped: test_aepack test_applesingle test_ioctl test_macostools test_pep277 test_plistlib test_scriptpackages test_startfile test_sunaudiodev test_tcl test_unicode_file test_winreg test_winsound test_zipfile64 2 skips unexpected on linux2: test_tcl test_ioctl [652079 refs] From python-3000-checkins at python.org Sat Jun 30 03:04:32 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Sat, 30 Jun 2007 03:04:32 +0200 (CEST) Subject: [Python-3000-checkins] r56124 - in python/branches/p3yk: Doc/lib/libshlex.tex Doc/lib/libshutil.tex Doc/lib/libtarfile.tex Doc/lib/libwinreg.tex Lib/logging/__init__.py Lib/tarfile.py Lib/test/test_tarfile.py Message-ID: <20070630010432.415421E4009@bag.python.org> Author: guido.van.rossum Date: Sat Jun 30 03:04:31 2007 New Revision: 56124 Modified: python/branches/p3yk/ (props changed) python/branches/p3yk/Doc/lib/libshlex.tex python/branches/p3yk/Doc/lib/libshutil.tex python/branches/p3yk/Doc/lib/libtarfile.tex python/branches/p3yk/Doc/lib/libwinreg.tex python/branches/p3yk/Lib/logging/__init__.py python/branches/p3yk/Lib/tarfile.py python/branches/p3yk/Lib/test/test_tarfile.py Log: Merged revisions 56014-56123 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r56019 | lars.gustaebel | 2007-06-18 04:42:11 -0700 (Mon, 18 Jun 2007) | 2 lines Added exclude keyword argument to the TarFile.add() method. ........ r56023 | lars.gustaebel | 2007-06-18 13:05:55 -0700 (Mon, 18 Jun 2007) | 3 lines Added missing \versionchanged tag for the new exclude parameter. ........ r56038 | georg.brandl | 2007-06-19 05:36:00 -0700 (Tue, 19 Jun 2007) | 2 lines Bug #1737864: allow empty message in logging format routines. ........ r56040 | georg.brandl | 2007-06-19 05:38:20 -0700 (Tue, 19 Jun 2007) | 2 lines Bug #1739115: make shutil.rmtree docs clear wrt. file deletion. ........ r56084 | georg.brandl | 2007-06-25 08:21:23 -0700 (Mon, 25 Jun 2007) | 2 lines Bug #1742901: document None behavior of shlex.split. ........ r56091 | georg.brandl | 2007-06-27 07:09:56 -0700 (Wed, 27 Jun 2007) | 2 lines Fix a variable name in winreg docs. ........ Modified: python/branches/p3yk/Doc/lib/libshlex.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libshlex.tex (original) +++ python/branches/p3yk/Doc/lib/libshlex.tex Sat Jun 30 03:04:31 2007 @@ -28,6 +28,9 @@ \var{posix} argument is false. \versionadded{2.3} \versionchanged[Added the \var{posix} parameter]{2.6} +\note{Since the \function{split()} function instantiates a \class{shlex} + instance, passing \code{None} for \var{s} will read the string + to split from standard input.} \end{funcdesc} The \module{shlex} module defines the following class: Modified: python/branches/p3yk/Doc/lib/libshutil.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libshutil.tex (original) +++ python/branches/p3yk/Doc/lib/libshutil.tex Sat Jun 30 03:04:31 2007 @@ -91,11 +91,12 @@ \end{funcdesc} \begin{funcdesc}{rmtree}{path\optional{, ignore_errors\optional{, onerror}}} - Delete an entire directory tree.\index{directory!deleting} - If \var{ignore_errors} is true, - errors resulting from failed removals will be ignored; if false or - omitted, such errors are handled by calling a handler specified by - \var{onerror} or, if that is omitted, they raise an exception. + \index{directory!deleting} + Delete an entire directory tree (\var{path} must point to a directory). + If \var{ignore_errors} is true, errors resulting from failed removals + will be ignored; if false or omitted, such errors are handled by + calling a handler specified by \var{onerror} or, if that is omitted, + they raise an exception. If \var{onerror} is provided, it must be a callable that accepts three parameters: \var{function}, \var{path}, and \var{excinfo}. Modified: python/branches/p3yk/Doc/lib/libtarfile.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libtarfile.tex (original) +++ python/branches/p3yk/Doc/lib/libtarfile.tex Sat Jun 30 03:04:31 2007 @@ -314,13 +314,17 @@ \end{notice} \end{methoddesc} -\begin{methoddesc}{add}{name\optional{, arcname\optional{, recursive}}} +\begin{methoddesc}{add}{name\optional{, arcname\optional{, recursive\optional{, exclude}}}} Add the file \var{name} to the archive. \var{name} may be any type of file (directory, fifo, symbolic link, etc.). If given, \var{arcname} specifies an alternative name for the file in the archive. Directories are added recursively by default. - This can be avoided by setting \var{recursive} to \constant{False}; - the default is \constant{True}. + This can be avoided by setting \var{recursive} to \constant{False}. + If \var{exclude} is given it must be a function that takes one filename + argument and returns a boolean value. Depending on this value the + respective file is either excluded (\constant{True}) or added + (\constant{False}). + \versionchanged[Added the \var{exclude} parameter]{2.6} \end{methoddesc} \begin{methoddesc}{addfile}{tarinfo\optional{, fileobj}} Modified: python/branches/p3yk/Doc/lib/libwinreg.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libwinreg.tex (original) +++ python/branches/p3yk/Doc/lib/libwinreg.tex Sat Jun 30 03:04:31 2007 @@ -321,7 +321,7 @@ \var{key} is an already open key, or one of the predefined \constant{HKEY_*} constants. - \var{sub_key} is a string that names the subkey with which the + \var{value_name} is a string that names the subkey with which the value is associated. \var{type} is an integer that specifies the type of the data. Modified: python/branches/p3yk/Lib/logging/__init__.py ============================================================================== --- python/branches/p3yk/Lib/logging/__init__.py (original) +++ python/branches/p3yk/Lib/logging/__init__.py Sat Jun 30 03:04:31 2007 @@ -400,7 +400,7 @@ traceback.print_exception(ei[0], ei[1], ei[2], None, sio) s = sio.getvalue() sio.close() - if s[-1] == "\n": + if s[-1:] == "\n": s = s[:-1] return s @@ -427,7 +427,7 @@ if not record.exc_text: record.exc_text = self.formatException(record.exc_info) if record.exc_text: - if s[-1] != "\n": + if s[-1:] != "\n": s = s + "\n" s = s + record.exc_text return s Modified: python/branches/p3yk/Lib/tarfile.py ============================================================================== --- python/branches/p3yk/Lib/tarfile.py (original) +++ python/branches/p3yk/Lib/tarfile.py Sat Jun 30 03:04:31 2007 @@ -1925,18 +1925,24 @@ print("link to", tarinfo.linkname, end=' ') print() - def add(self, name, arcname=None, recursive=True): + def add(self, name, arcname=None, recursive=True, exclude=None): """Add the file `name' to the archive. `name' may be any type of file (directory, fifo, symbolic link, etc.). If given, `arcname' specifies an alternative name for the file in the archive. Directories are added recursively by default. This can be avoided by - setting `recursive' to False. + setting `recursive' to False. `exclude' is a function that should + return True for each filename to be excluded. """ self._check("aw") if arcname is None: arcname = name + # Exclude pathnames. + if exclude is not None and exclude(name): + self._dbg(2, "tarfile: Excluded %r" % name) + return + # Skip if somebody tries to archive the archive... if self.name is not None and os.path.abspath(name) == self.name: self._dbg(2, "tarfile: Skipped %r" % name) @@ -1949,7 +1955,7 @@ if arcname == ".": arcname = "" for f in os.listdir(name): - self.add(f, os.path.join(arcname, f)) + self.add(f, os.path.join(arcname, f), recursive, exclude) return self._dbg(1, name) @@ -1971,7 +1977,7 @@ self.addfile(tarinfo) if recursive: for f in os.listdir(name): - self.add(os.path.join(name, f), os.path.join(arcname, f)) + self.add(os.path.join(name, f), os.path.join(arcname, f), recursive, exclude) else: self.addfile(tarinfo) Modified: python/branches/p3yk/Lib/test/test_tarfile.py ============================================================================== --- python/branches/p3yk/Lib/test/test_tarfile.py (original) +++ python/branches/p3yk/Lib/test/test_tarfile.py Sat Jun 30 03:04:31 2007 @@ -558,6 +558,27 @@ os.chdir(cwd) self.assert_(tar.getnames() == [], "added the archive to itself") + def test_exclude(self): + tempdir = os.path.join(TEMPDIR, "exclude") + os.mkdir(tempdir) + try: + for name in ("foo", "bar", "baz"): + name = os.path.join(tempdir, name) + open(name, "wb").close() + + def exclude(name): + return os.path.isfile(name) + + tar = tarfile.open(tmpname, self.mode, encoding="iso8859-1") + tar.add(tempdir, arcname="empty_dir", exclude=exclude) + tar.close() + + tar = tarfile.open(tmpname, "r") + self.assertEqual(len(tar.getmembers()), 1) + self.assertEqual(tar.getnames()[0], "empty_dir") + finally: + shutil.rmtree(tempdir) + class StreamWriteTest(unittest.TestCase): From python-3000-checkins at python.org Sat Jun 30 03:14:34 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Sat, 30 Jun 2007 03:14:34 +0200 (CEST) Subject: [Python-3000-checkins] r56125 - python/branches/py3k-struni/runtests.sh Message-ID: <20070630011434.0A2331E4009@bag.python.org> Author: guido.van.rossum Date: Sat Jun 30 03:14:33 2007 New Revision: 56125 Modified: python/branches/py3k-struni/runtests.sh Log: Don't retest failing tests -- it takes too long. Modified: python/branches/py3k-struni/runtests.sh ============================================================================== --- python/branches/py3k-struni/runtests.sh (original) +++ python/branches/py3k-struni/runtests.sh Sat Jun 30 03:14:33 2007 @@ -54,7 +54,7 @@ else echo " BAD" echo $T >>BAD - echo "--------- Re-running test in verbose mode ---------" >>OUT/$T.out - $PYTHON Lib/test/regrtest.py -v $UFLAG $T >>OUT/$T.out 2>&1 + ##echo "--------- Re-running test in verbose mode ---------" >>OUT/$T.out + ##$PYTHON Lib/test/regrtest.py -v $UFLAG $T >>OUT/$T.out 2>&1 fi done From python-3000-checkins at python.org Sat Jun 30 07:01:59 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Sat, 30 Jun 2007 07:01:59 +0200 (CEST) Subject: [Python-3000-checkins] r56126 - in python/branches/py3k-struni: Doc/lib/libshlex.tex Doc/lib/libshutil.tex Doc/lib/libtarfile.tex Doc/lib/libwinreg.tex Lib/difflib.py Lib/distutils/dir_util.py Lib/keyword.py Lib/logging/__init__.py Lib/pydoc.py Lib/tarfile.py Lib/test/test_tarfile.py Python/ceval.c Tools/pybench/CommandLine.py Tools/pybench/Lists.py Tools/pybench/Strings.py Tools/pybench/Unicode.py Tools/pybench/clockres.py Tools/pybench/pybench.py Tools/pybench/systimes.py runtests.sh Message-ID: <20070630050159.B0C621E400A@bag.python.org> Author: guido.van.rossum Date: Sat Jun 30 07:01:58 2007 New Revision: 56126 Modified: python/branches/py3k-struni/ (props changed) python/branches/py3k-struni/Doc/lib/libshlex.tex python/branches/py3k-struni/Doc/lib/libshutil.tex python/branches/py3k-struni/Doc/lib/libtarfile.tex python/branches/py3k-struni/Doc/lib/libwinreg.tex python/branches/py3k-struni/Lib/difflib.py python/branches/py3k-struni/Lib/distutils/dir_util.py python/branches/py3k-struni/Lib/keyword.py python/branches/py3k-struni/Lib/logging/__init__.py python/branches/py3k-struni/Lib/pydoc.py python/branches/py3k-struni/Lib/tarfile.py python/branches/py3k-struni/Lib/test/test_tarfile.py python/branches/py3k-struni/Python/ceval.c python/branches/py3k-struni/Tools/pybench/CommandLine.py python/branches/py3k-struni/Tools/pybench/Lists.py python/branches/py3k-struni/Tools/pybench/Strings.py python/branches/py3k-struni/Tools/pybench/Unicode.py python/branches/py3k-struni/Tools/pybench/clockres.py python/branches/py3k-struni/Tools/pybench/pybench.py python/branches/py3k-struni/Tools/pybench/systimes.py python/branches/py3k-struni/runtests.sh Log: Merged revisions 56020-56124 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/p3yk ................ r56037 | georg.brandl | 2007-06-19 05:33:20 -0700 (Tue, 19 Jun 2007) | 2 lines Patch #1739659: don't slice dict.keys() in pydoc. ................ r56060 | martin.v.loewis | 2007-06-21 13:00:02 -0700 (Thu, 21 Jun 2007) | 2 lines Regenerate to add True, False, None. ................ r56069 | neal.norwitz | 2007-06-21 22:31:56 -0700 (Thu, 21 Jun 2007) | 1 line Get the doctest working again after adding None, True, and False as kewyords. ................ r56070 | neal.norwitz | 2007-06-21 23:25:33 -0700 (Thu, 21 Jun 2007) | 1 line Add space to error message. ................ r56071 | neal.norwitz | 2007-06-21 23:40:04 -0700 (Thu, 21 Jun 2007) | 6 lines Get pybench working, primarily * Use print function * Stop using string module * Use sorted instead of assuming dict methods return lists * Convert range result to a list ................ r56089 | collin.winter | 2007-06-26 10:31:48 -0700 (Tue, 26 Jun 2007) | 1 line Fix AttributeError in distutils/dir_util.py. ................ r56124 | guido.van.rossum | 2007-06-29 18:04:31 -0700 (Fri, 29 Jun 2007) | 30 lines Merged revisions 56014-56123 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r56019 | lars.gustaebel | 2007-06-18 04:42:11 -0700 (Mon, 18 Jun 2007) | 2 lines Added exclude keyword argument to the TarFile.add() method. ........ r56023 | lars.gustaebel | 2007-06-18 13:05:55 -0700 (Mon, 18 Jun 2007) | 3 lines Added missing \versionchanged tag for the new exclude parameter. ........ r56038 | georg.brandl | 2007-06-19 05:36:00 -0700 (Tue, 19 Jun 2007) | 2 lines Bug #1737864: allow empty message in logging format routines. ........ r56040 | georg.brandl | 2007-06-19 05:38:20 -0700 (Tue, 19 Jun 2007) | 2 lines Bug #1739115: make shutil.rmtree docs clear wrt. file deletion. ........ r56084 | georg.brandl | 2007-06-25 08:21:23 -0700 (Mon, 25 Jun 2007) | 2 lines Bug #1742901: document None behavior of shlex.split. ........ r56091 | georg.brandl | 2007-06-27 07:09:56 -0700 (Wed, 27 Jun 2007) | 2 lines Fix a variable name in winreg docs. ........ ................ Modified: python/branches/py3k-struni/Doc/lib/libshlex.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libshlex.tex (original) +++ python/branches/py3k-struni/Doc/lib/libshlex.tex Sat Jun 30 07:01:58 2007 @@ -28,6 +28,9 @@ \var{posix} argument is false. \versionadded{2.3} \versionchanged[Added the \var{posix} parameter]{2.6} +\note{Since the \function{split()} function instantiates a \class{shlex} + instance, passing \code{None} for \var{s} will read the string + to split from standard input.} \end{funcdesc} The \module{shlex} module defines the following class: Modified: python/branches/py3k-struni/Doc/lib/libshutil.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libshutil.tex (original) +++ python/branches/py3k-struni/Doc/lib/libshutil.tex Sat Jun 30 07:01:58 2007 @@ -91,11 +91,12 @@ \end{funcdesc} \begin{funcdesc}{rmtree}{path\optional{, ignore_errors\optional{, onerror}}} - Delete an entire directory tree.\index{directory!deleting} - If \var{ignore_errors} is true, - errors resulting from failed removals will be ignored; if false or - omitted, such errors are handled by calling a handler specified by - \var{onerror} or, if that is omitted, they raise an exception. + \index{directory!deleting} + Delete an entire directory tree (\var{path} must point to a directory). + If \var{ignore_errors} is true, errors resulting from failed removals + will be ignored; if false or omitted, such errors are handled by + calling a handler specified by \var{onerror} or, if that is omitted, + they raise an exception. If \var{onerror} is provided, it must be a callable that accepts three parameters: \var{function}, \var{path}, and \var{excinfo}. Modified: python/branches/py3k-struni/Doc/lib/libtarfile.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libtarfile.tex (original) +++ python/branches/py3k-struni/Doc/lib/libtarfile.tex Sat Jun 30 07:01:58 2007 @@ -314,13 +314,17 @@ \end{notice} \end{methoddesc} -\begin{methoddesc}{add}{name\optional{, arcname\optional{, recursive}}} +\begin{methoddesc}{add}{name\optional{, arcname\optional{, recursive\optional{, exclude}}}} Add the file \var{name} to the archive. \var{name} may be any type of file (directory, fifo, symbolic link, etc.). If given, \var{arcname} specifies an alternative name for the file in the archive. Directories are added recursively by default. - This can be avoided by setting \var{recursive} to \constant{False}; - the default is \constant{True}. + This can be avoided by setting \var{recursive} to \constant{False}. + If \var{exclude} is given it must be a function that takes one filename + argument and returns a boolean value. Depending on this value the + respective file is either excluded (\constant{True}) or added + (\constant{False}). + \versionchanged[Added the \var{exclude} parameter]{2.6} \end{methoddesc} \begin{methoddesc}{addfile}{tarinfo\optional{, fileobj}} Modified: python/branches/py3k-struni/Doc/lib/libwinreg.tex ============================================================================== --- python/branches/py3k-struni/Doc/lib/libwinreg.tex (original) +++ python/branches/py3k-struni/Doc/lib/libwinreg.tex Sat Jun 30 07:01:58 2007 @@ -321,7 +321,7 @@ \var{key} is an already open key, or one of the predefined \constant{HKEY_*} constants. - \var{sub_key} is a string that names the subkey with which the + \var{value_name} is a string that names the subkey with which the value is associated. \var{type} is an integer that specifies the type of the data. Modified: python/branches/py3k-struni/Lib/difflib.py ============================================================================== --- python/branches/py3k-struni/Lib/difflib.py (original) +++ python/branches/py3k-struni/Lib/difflib.py Sat Jun 30 07:01:58 2007 @@ -719,7 +719,7 @@ >>> import keyword as _keyword >>> get_close_matches("wheel", _keyword.kwlist) ['while'] - >>> get_close_matches("apple", _keyword.kwlist) + >>> get_close_matches("Apple", _keyword.kwlist) [] >>> get_close_matches("accept", _keyword.kwlist) ['except'] Modified: python/branches/py3k-struni/Lib/distutils/dir_util.py ============================================================================== --- python/branches/py3k-struni/Lib/distutils/dir_util.py (original) +++ python/branches/py3k-struni/Lib/distutils/dir_util.py Sat Jun 30 07:01:58 2007 @@ -96,14 +96,12 @@ for 'mkpath()'.""" # First get the list of directories to create - need_dir = {} + need_dir = set() for file in files: - need_dir[os.path.join(base_dir, os.path.dirname(file))] = 1 - need_dirs = need_dir.keys() - need_dirs.sort() + need_dir.add(os.path.join(base_dir, os.path.dirname(file))) # Now create them - for dir in need_dirs: + for dir in sorted(need_dir): mkpath(dir, mode, dry_run=dry_run) # create_tree () Modified: python/branches/py3k-struni/Lib/keyword.py ============================================================================== --- python/branches/py3k-struni/Lib/keyword.py (original) +++ python/branches/py3k-struni/Lib/keyword.py Sat Jun 30 07:01:58 2007 @@ -14,6 +14,9 @@ kwlist = [ #--start keywords-- + 'False', + 'None', + 'True', 'and', 'as', 'assert', Modified: python/branches/py3k-struni/Lib/logging/__init__.py ============================================================================== --- python/branches/py3k-struni/Lib/logging/__init__.py (original) +++ python/branches/py3k-struni/Lib/logging/__init__.py Sat Jun 30 07:01:58 2007 @@ -400,7 +400,7 @@ traceback.print_exception(ei[0], ei[1], ei[2], None, sio) s = sio.getvalue() sio.close() - if s[-1] == "\n": + if s[-1:] == "\n": s = s[:-1] return s @@ -427,7 +427,7 @@ if not record.exc_text: record.exc_text = self.formatException(record.exc_info) if record.exc_text: - if s[-1] != "\n": + if s[-1:] != "\n": s = s + "\n" s = s + record.exc_text return s Modified: python/branches/py3k-struni/Lib/pydoc.py ============================================================================== --- python/branches/py3k-struni/Lib/pydoc.py (original) +++ python/branches/py3k-struni/Lib/pydoc.py Sat Jun 30 07:01:58 2007 @@ -1748,17 +1748,16 @@ ''' % sys.version[:3]) def list(self, items, columns=4, width=80): - items = items[:] - items.sort() - colw = width / columns - rows = (len(items) + columns - 1) / columns + items = list(sorted(items)) + colw = width // columns + rows = (len(items) + columns - 1) // columns for row in range(rows): for col in range(columns): i = col * rows + row if i < len(items): self.output.write(items[i]) if col < columns - 1: - self.output.write(' ' + ' ' * (colw-1 - len(items[i]))) + self.output.write(' ' + ' ' * (colw - 1 - len(items[i]))) self.output.write('\n') def listkeywords(self): Modified: python/branches/py3k-struni/Lib/tarfile.py ============================================================================== --- python/branches/py3k-struni/Lib/tarfile.py (original) +++ python/branches/py3k-struni/Lib/tarfile.py Sat Jun 30 07:01:58 2007 @@ -1925,18 +1925,24 @@ print("link to", tarinfo.linkname, end=' ') print() - def add(self, name, arcname=None, recursive=True): + def add(self, name, arcname=None, recursive=True, exclude=None): """Add the file `name' to the archive. `name' may be any type of file (directory, fifo, symbolic link, etc.). If given, `arcname' specifies an alternative name for the file in the archive. Directories are added recursively by default. This can be avoided by - setting `recursive' to False. + setting `recursive' to False. `exclude' is a function that should + return True for each filename to be excluded. """ self._check("aw") if arcname is None: arcname = name + # Exclude pathnames. + if exclude is not None and exclude(name): + self._dbg(2, "tarfile: Excluded %r" % name) + return + # Skip if somebody tries to archive the archive... if self.name is not None and os.path.abspath(name) == self.name: self._dbg(2, "tarfile: Skipped %r" % name) @@ -1949,7 +1955,7 @@ if arcname == ".": arcname = "" for f in os.listdir(name): - self.add(f, os.path.join(arcname, f)) + self.add(f, os.path.join(arcname, f), recursive, exclude) return self._dbg(1, name) @@ -1971,7 +1977,7 @@ self.addfile(tarinfo) if recursive: for f in os.listdir(name): - self.add(os.path.join(name, f), os.path.join(arcname, f)) + self.add(os.path.join(name, f), os.path.join(arcname, f), recursive, exclude) else: self.addfile(tarinfo) Modified: python/branches/py3k-struni/Lib/test/test_tarfile.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_tarfile.py (original) +++ python/branches/py3k-struni/Lib/test/test_tarfile.py Sat Jun 30 07:01:58 2007 @@ -558,6 +558,27 @@ os.chdir(cwd) self.assert_(tar.getnames() == [], "added the archive to itself") + def test_exclude(self): + tempdir = os.path.join(TEMPDIR, "exclude") + os.mkdir(tempdir) + try: + for name in ("foo", "bar", "baz"): + name = os.path.join(tempdir, name) + open(name, "wb").close() + + def exclude(name): + return os.path.isfile(name) + + tar = tarfile.open(tmpname, self.mode, encoding="iso8859-1") + tar.add(tempdir, arcname="empty_dir", exclude=exclude) + tar.close() + + tar = tarfile.open(tmpname, "r") + self.assertEqual(len(tar.getmembers()), 1) + self.assertEqual(tar.getnames()[0], "empty_dir") + finally: + shutil.rmtree(tempdir) + class StreamWriteTest(unittest.TestCase): Modified: python/branches/py3k-struni/Python/ceval.c ============================================================================== --- python/branches/py3k-struni/Python/ceval.c (original) +++ python/branches/py3k-struni/Python/ceval.c Sat Jun 30 07:01:58 2007 @@ -3959,7 +3959,7 @@ } } -#define CANNOT_CATCH_MSG "catching classes that do not inherit from"\ +#define CANNOT_CATCH_MSG "catching classes that do not inherit from "\ "BaseException is not allowed" static PyObject * Modified: python/branches/py3k-struni/Tools/pybench/CommandLine.py ============================================================================== --- python/branches/py3k-struni/Tools/pybench/CommandLine.py (original) +++ python/branches/py3k-struni/Tools/pybench/CommandLine.py Sat Jun 30 07:01:58 2007 @@ -20,7 +20,7 @@ __version__ = '1.2' -import sys, getopt, string, glob, os, re, exceptions, traceback +import sys, getopt, glob, os, re, traceback ### Helpers @@ -44,7 +44,7 @@ l.append(o.name+'=') else: l.append(o.name) - return string.join(s,''),l + return ''.join(s), l def invisible_input(prompt='>>> '): @@ -102,7 +102,7 @@ def srange(s, - split=string.split,integer=_integerRE, + integer=_integerRE, integerRange=_integerRangeRE): """ Converts a textual representation of integer numbers and ranges @@ -116,7 +116,7 @@ """ l = [] append = l.append - for entry in split(s,','): + for entry in s.split(','): m = integer.match(entry) if m: append(int(m.groups()[0])) @@ -293,7 +293,7 @@ verbose = 0 # Internal errors to catch - InternalError = exceptions.Exception + InternalError = BaseException # Instance variables: values = None # Dictionary of passed options (or default values) @@ -353,20 +353,20 @@ pass except KeyboardInterrupt: - print - print '* User Break' - print + print() + print('* User Break') + print() rc = 1 except self.InternalError: - print - print '* Internal Error (use --debug to display the traceback)' + print() + print('* Internal Error (use --debug to display the traceback)') if self.debug: - print + print() traceback.print_exc(20, sys.stdout) elif self.verbose: - print ' %s: %s' % sys.exc_info()[:2] - print + print(' %s: %s' % sys.exc_info()[:2]) + print() rc = 1 raise SystemExit(rc) @@ -449,13 +449,13 @@ # Try to convert value to integer try: - value = string.atoi(value) + value = int(value) except ValueError: pass # Find handler and call it (or count the number of option # instances on the command line) - handlername = 'handle' + string.replace(optionname, '-', '_') + handlername = 'handle' + optionname.replace('-', '_') try: handler = getattr(self, handlername) except AttributeError: @@ -494,54 +494,55 @@ self.print_header() if self.synopsis: - print 'Synopsis:' + print('Synopsis:') # To remain backward compatible: try: synopsis = self.synopsis % self.name except (NameError, KeyError, TypeError): synopsis = self.synopsis % self.__dict__ - print ' ' + synopsis - print + print(' ' + synopsis) + print() self.print_options() if self.version: - print 'Version:' - print ' %s' % self.version - print + print('Version:') + print(' %s' % self.version) + print() if self.about: - print string.strip(self.about % self.__dict__) - print + about = self.about % self.__dict__ + print(about.strip()) + print() if note: - print '-'*72 - print 'Note:',note - print + print('-'*72) + print('Note:',note) + print() def notice(self,note): - print '-'*72 - print 'Note:',note - print '-'*72 - print + print('-'*72) + print('Note:',note) + print('-'*72) + print() def print_header(self): - print '-'*72 - print self.header % self.__dict__ - print '-'*72 - print + print('-'*72) + print(self.header % self.__dict__) + print('-'*72) + print() def print_options(self): options = self.options - print 'Options and default settings:' + print('Options and default settings:') if not options: - print ' None' + print(' None') return long = filter(lambda x: x.prefix == '--', options) short = filter(lambda x: x.prefix == '-', options) items = short + long for o in options: - print ' ',o - print + print(' ',o) + print() # # Example handlers: @@ -579,26 +580,29 @@ self.debug = 1 # We don't want to catch internal errors: - self.InternalError = None + class NoErrorToCatch(Exception): pass + self.InternalError = NoErrorToCatch def handle__copyright(self,arg): self.print_header() - print string.strip(self.copyright % self.__dict__) - print + copyright = self.copyright % self.__dict__ + print(copyright.strip()) + print() return 0 def handle__examples(self,arg): self.print_header() if self.examples: - print 'Examples:' - print - print string.strip(self.examples % self.__dict__) - print + print('Examples:') + print() + examples = self.examples % self.__dict__ + print(examples.strip()) + print() else: - print 'No examples available.' - print + print('No examples available.') + print() return 0 def main(self): @@ -624,13 +628,13 @@ options = [Option('-v','verbose')] def handle_v(self,arg): - print 'VERBOSE, Yeah !' + print('VERBOSE, Yeah !') cmd = MyApplication() if not cmd.values['-h']: cmd.help() - print 'files:',cmd.files - print 'Bye...' + print('files:',cmd.files) + print('Bye...') if __name__ == '__main__': _test() Modified: python/branches/py3k-struni/Tools/pybench/Lists.py ============================================================================== --- python/branches/py3k-struni/Tools/pybench/Lists.py (original) +++ python/branches/py3k-struni/Tools/pybench/Lists.py Sat Jun 30 07:01:58 2007 @@ -138,8 +138,8 @@ def test(self): - n = range(100) - r = range(25) + n = list(range(100)) + r = list(range(25)) for i in range(self.rounds): Modified: python/branches/py3k-struni/Tools/pybench/Strings.py ============================================================================== --- python/branches/py3k-struni/Tools/pybench/Strings.py (original) +++ python/branches/py3k-struni/Tools/pybench/Strings.py Sat Jun 30 07:01:58 2007 @@ -1,5 +1,4 @@ from pybench import Test -from string import join import sys class ConcatStrings(Test): @@ -11,8 +10,8 @@ def test(self): # Make sure the strings are *not* interned - s = join(map(str,range(100))) - t = join(map(str,range(1,101))) + s = ''.join(map(str,range(100))) + t = ''.join(map(str,range(1,101))) for i in range(self.rounds): t + s @@ -77,8 +76,8 @@ def calibrate(self): - s = join(map(str,range(100))) - t = join(map(str,range(1,101))) + s = ''.join(map(str,range(100))) + t = ''.join(map(str,range(1,101))) for i in range(self.rounds): pass @@ -93,8 +92,8 @@ def test(self): # Make sure the strings are *not* interned - s = join(map(str,range(10))) - t = join(map(str,range(10))) + "abc" + s = ''.join(map(str,range(10))) + t = ''.join(map(str,range(10))) + "abc" for i in range(self.rounds): t < s @@ -159,8 +158,8 @@ def calibrate(self): - s = join(map(str,range(10))) - t = join(map(str,range(10))) + "abc" + s = ''.join(map(str,range(10))) + t = ''.join(map(str,range(10))) + "abc" for i in range(self.rounds): pass @@ -175,7 +174,7 @@ def test(self): # Make sure the strings *are* interned - s = sys.intern(join(map(str,range(10)))) + s = sys.intern(''.join(map(str,range(10)))) t = s for i in range(self.rounds): @@ -241,7 +240,7 @@ def calibrate(self): - s = sys.intern(join(map(str,range(10)))) + s = sys.intern(''.join(map(str,range(10)))) t = s for i in range(self.rounds): @@ -331,7 +330,7 @@ def test(self): - s = join(map(str,range(100))) + s = ''.join(map(str,range(100))) for i in range(self.rounds): @@ -377,7 +376,7 @@ def calibrate(self): - s = join(map(str,range(100))) + s = ''.join(map(str,range(100))) for i in range(self.rounds): pass @@ -394,10 +393,10 @@ def test(self): - s = join(map(chr,range(20)),'') - t = join(map(chr,range(50)),'') - u = join(map(chr,range(100)),'') - v = join(map(chr,range(256)),'') + s = ''.join(map(chr,range(20))) + t = ''.join(map(chr,range(50))) + u = ''.join(map(chr,range(100))) + v = ''.join(map(chr,range(256))) for i in range(self.rounds): @@ -451,10 +450,10 @@ def calibrate(self): - s = join(map(chr,range(20)),'') - t = join(map(chr,range(50)),'') - u = join(map(chr,range(100)),'') - v = join(map(chr,range(256)),'') + s = ''.join(map(chr,range(20))) + t = ''.join(map(chr,range(50))) + u = ''.join(map(chr,range(100))) + v = ''.join(map(chr,range(256))) for i in range(self.rounds): pass Modified: python/branches/py3k-struni/Tools/pybench/Unicode.py ============================================================================== --- python/branches/py3k-struni/Tools/pybench/Unicode.py (original) +++ python/branches/py3k-struni/Tools/pybench/Unicode.py Sat Jun 30 07:01:58 2007 @@ -4,7 +4,6 @@ raise ImportError from pybench import Test -from string import join class ConcatUnicode(Test): @@ -15,8 +14,8 @@ def test(self): # Make sure the strings are *not* interned - s = unicode(join(map(str,range(100)))) - t = unicode(join(map(str,range(1,101)))) + s = unicode(u''.join(map(str,range(100)))) + t = unicode(u''.join(map(str,range(1,101)))) for i in range(self.rounds): t + s @@ -81,8 +80,8 @@ def calibrate(self): - s = unicode(join(map(str,range(100)))) - t = unicode(join(map(str,range(1,101)))) + s = unicode(u''.join(map(str,range(100)))) + t = unicode(u''.join(map(str,range(1,101)))) for i in range(self.rounds): pass @@ -97,8 +96,8 @@ def test(self): # Make sure the strings are *not* interned - s = unicode(join(map(str,range(10)))) - t = unicode(join(map(str,range(10))) + "abc") + s = unicode(u''.join(map(str,range(10)))) + t = unicode(u''.join(map(str,range(10))) + "abc") for i in range(self.rounds): t < s @@ -163,8 +162,8 @@ def calibrate(self): - s = unicode(join(map(str,range(10)))) - t = unicode(join(map(str,range(10))) + "abc") + s = unicode(u''.join(map(str,range(10)))) + t = unicode(u''.join(map(str,range(10))) + "abc") for i in range(self.rounds): pass @@ -253,7 +252,7 @@ def test(self): - s = unicode(join(map(str,range(100)))) + s = unicode(u''.join(map(str,range(100)))) for i in range(self.rounds): @@ -299,7 +298,7 @@ def calibrate(self): - s = unicode(join(map(str,range(100)))) + s = unicode(u''.join(map(str,range(100)))) for i in range(self.rounds): pass @@ -314,10 +313,10 @@ def test(self): - s = join(map(unichr,range(20)),'') - t = join(map(unichr,range(100)),'') - u = join(map(unichr,range(500)),'') - v = join(map(unichr,range(1000)),'') + s = u''.join(map(unichr,range(20))) + t = u''.join(map(unichr,range(100))) + u = u''.join(map(unichr,range(500))) + v = u''.join(map(unichr,range(1000))) for i in range(self.rounds): @@ -371,10 +370,10 @@ def calibrate(self): - s = join(map(unichr,range(20)),'') - t = join(map(unichr,range(100)),'') - u = join(map(unichr,range(500)),'') - v = join(map(unichr,range(1000)),'') + s = u''.join(map(unichr,range(20))) + t = u''.join(map(unichr,range(100))) + u = u''.join(map(unichr,range(500))) + v = u''.join(map(unichr,range(1000))) for i in range(self.rounds): pass Modified: python/branches/py3k-struni/Tools/pybench/clockres.py ============================================================================== --- python/branches/py3k-struni/Tools/pybench/clockres.py (original) +++ python/branches/py3k-struni/Tools/pybench/clockres.py Sat Jun 30 07:01:58 2007 @@ -33,11 +33,11 @@ return min_diff if __name__ == '__main__': - print 'Clock resolution of various timer implementations:' - print 'time.clock: %10.3fus' % (clockres(time.clock) * 1e6) - print 'time.time: %10.3fus' % (clockres(time.time) * 1e6) + print('Clock resolution of various timer implementations:') + print('time.clock: %10.3fus' % (clockres(time.clock) * 1e6)) + print('time.time: %10.3fus' % (clockres(time.time) * 1e6)) try: import systimes - print 'systimes.processtime: %10.3fus' % (clockres(systimes.processtime) * 1e6) + print('systimes.processtime: %10.3fus' % (clockres(systimes.processtime) * 1e6)) except ImportError: pass Modified: python/branches/py3k-struni/Tools/pybench/pybench.py ============================================================================== --- python/branches/py3k-struni/Tools/pybench/pybench.py (original) +++ python/branches/py3k-struni/Tools/pybench/pybench.py Sat Jun 30 07:01:58 2007 @@ -34,7 +34,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE ! """ -import sys, time, operator, string, platform +import sys, time, operator, platform from CommandLine import * try: @@ -103,7 +103,7 @@ def get_machine_details(): if _debug: - print 'Getting machine details...' + print('Getting machine details...') buildno, builddate = platform.python_build() python = platform.python_version() try: @@ -146,7 +146,8 @@ d.get('buildno', 'n/a')), ' Unicode: %s' % d.get('unicode', 'n/a'), ] - print indent + string.join(l, '\n' + indent) + '\n' + joiner = '\n' + indent + print(indent + joiner.join(l) + '\n') ### Test baseclass @@ -280,9 +281,9 @@ prep_times.append(t) min_prep_time = min(prep_times) if _debug: - print - print 'Calib. prep time = %.6fms' % ( - min_prep_time * MILLI_SECONDS) + print() + print('Calib. prep time = %.6fms' % ( + min_prep_time * MILLI_SECONDS)) # Time the calibration runs (doing CALIBRATION_LOOPS loops of # .calibrate() method calls each) @@ -298,8 +299,8 @@ min_overhead = min(self.overhead_times) max_overhead = max(self.overhead_times) if _debug: - print 'Calib. overhead time = %.6fms' % ( - min_overhead * MILLI_SECONDS) + print('Calib. overhead time = %.6fms' % ( + min_overhead * MILLI_SECONDS)) if min_overhead < 0.0: raise ValueError('calibration setup did not work') if max_overhead - min_overhead > 0.1: @@ -436,7 +437,7 @@ # Init vars self.tests = {} if _debug: - print 'Getting machine details...' + print('Getting machine details...') self.machine_details = get_machine_details() # Make .version an instance attribute to have it saved in the @@ -473,8 +474,8 @@ # Add tests if self.verbose: - print 'Searching for tests ...' - print '--------------------------------------' + print('Searching for tests ...') + print('--------------------------------------') for testclass in setupmod.__dict__.values(): if not hasattr(testclass, 'is_a_test'): continue @@ -488,77 +489,74 @@ warp=self.warp, calibration_runs=self.calibration_runs, timer=self.timer) - l = self.tests.keys() - l.sort() + l = sorted(self.tests) if self.verbose: for name in l: - print ' %s' % name - print '--------------------------------------' - print ' %i tests found' % len(l) - print + print(' %s' % name) + print('--------------------------------------') + print(' %i tests found' % len(l)) + print() def calibrate(self): - print 'Calibrating tests. Please wait...', + print('Calibrating tests. Please wait...', end=' ') if self.verbose: - print - print - print 'Test min max' - print '-' * LINE - tests = self.tests.items() - tests.sort() + print() + print() + print('Test min max') + print('-' * LINE) + tests = sorted(self.tests.items()) for i in range(len(tests)): name, test = tests[i] test.calibrate_test() if self.verbose: - print '%30s: %6.3fms %6.3fms' % \ + print('%30s: %6.3fms %6.3fms' % \ (name, min(test.overhead_times) * MILLI_SECONDS, - max(test.overhead_times) * MILLI_SECONDS) + max(test.overhead_times) * MILLI_SECONDS)) if self.verbose: - print - print 'Done with the calibration.' + print() + print('Done with the calibration.') else: - print 'done.' - print + print('done.') + print() def run(self): - tests = self.tests.items() - tests.sort() + tests = sorted(self.tests.items()) timer = self.get_timer() - print 'Running %i round(s) of the suite at warp factor %i:' % \ - (self.rounds, self.warp) - print + print('Running %i round(s) of the suite at warp factor %i:' % \ + (self.rounds, self.warp)) + print() self.roundtimes = [] for i in range(self.rounds): if self.verbose: - print ' Round %-25i effective absolute overhead' % (i+1) + print(' Round %-25i effective absolute overhead' % (i+1)) total_eff_time = 0.0 for j in range(len(tests)): name, test = tests[j] if self.verbose: - print '%30s:' % name, + print('%30s:' % name, end=' ') test.run() (eff_time, abs_time, min_overhead) = test.last_timing total_eff_time = total_eff_time + eff_time if self.verbose: - print ' %5.0fms %5.0fms %7.3fms' % \ + print(' %5.0fms %5.0fms %7.3fms' % \ (eff_time * MILLI_SECONDS, abs_time * MILLI_SECONDS, - min_overhead * MILLI_SECONDS) + min_overhead * MILLI_SECONDS)) self.roundtimes.append(total_eff_time) if self.verbose: - print (' ' - ' ------------------------------') - print (' ' + print((' ' + ' ------------------------------')) + print((' ' ' Totals: %6.0fms' % - (total_eff_time * MILLI_SECONDS)) - print + (total_eff_time * MILLI_SECONDS))) + print() else: - print '* Round %i done in %.3f seconds.' % (i+1, - total_eff_time) - print + print('* Round %i done in %.3f seconds.' % (i+1, + total_eff_time)) + print() def stat(self): @@ -583,25 +581,24 @@ def print_header(self, title='Benchmark'): - print '-' * LINE - print '%s: %s' % (title, self.name) - print '-' * LINE - print - print ' Rounds: %s' % self.rounds - print ' Warp: %s' % self.warp - print ' Timer: %s' % self.timer - print + print('-' * LINE) + print('%s: %s' % (title, self.name)) + print('-' * LINE) + print() + print(' Rounds: %s' % self.rounds) + print(' Warp: %s' % self.warp) + print(' Timer: %s' % self.timer) + print() if self.machine_details: print_machine_details(self.machine_details, indent=' ') - print + print() def print_benchmark(self, hidenoise=0, limitnames=None): - print ('Test ' - ' minimum average operation overhead') - print '-' * LINE - tests = self.tests.items() - tests.sort() + print(('Test ' + ' minimum average operation overhead')) + print('-' * LINE) + tests = sorted(self.tests.items()) total_min_time = 0.0 total_avg_time = 0.0 for name, test in tests: @@ -615,43 +612,42 @@ min_overhead) = test.stat() total_min_time = total_min_time + min_time total_avg_time = total_avg_time + avg_time - print '%30s: %5.0fms %5.0fms %6.2fus %7.3fms' % \ + print('%30s: %5.0fms %5.0fms %6.2fus %7.3fms' % \ (name, min_time * MILLI_SECONDS, avg_time * MILLI_SECONDS, op_avg * MICRO_SECONDS, - min_overhead *MILLI_SECONDS) - print '-' * LINE - print ('Totals: ' + min_overhead *MILLI_SECONDS)) + print('-' * LINE) + print(('Totals: ' ' %6.0fms %6.0fms' % (total_min_time * MILLI_SECONDS, total_avg_time * MILLI_SECONDS, - )) - print + ))) + print() def print_comparison(self, compare_to, hidenoise=0, limitnames=None): # Check benchmark versions if compare_to.version != self.version: - print ('* Benchmark versions differ: ' + print(('* Benchmark versions differ: ' 'cannot compare this benchmark to "%s" !' % - compare_to.name) - print + compare_to.name)) + print() self.print_benchmark(hidenoise=hidenoise, limitnames=limitnames) return # Print header compare_to.print_header('Comparing with') - print ('Test ' - ' minimum run-time average run-time') - print (' ' - ' this other diff this other diff') - print '-' * LINE + print(('Test ' + ' minimum run-time average run-time')) + print((' ' + ' this other diff this other diff')) + print('-' * LINE) # Print test comparisons - tests = self.tests.items() - tests.sort() + tests = sorted(self.tests.items()) total_min_time = other_total_min_time = 0.0 total_avg_time = other_total_avg_time = 0.0 benchmarks_compatible = self.compatible(compare_to) @@ -704,15 +700,15 @@ # Benchmark or tests are not comparible min_diff, avg_diff = 'n/a', 'n/a' tests_compatible = 0 - print '%30s: %5.0fms %5.0fms %7s %5.0fms %5.0fms %7s' % \ + print('%30s: %5.0fms %5.0fms %7s %5.0fms %5.0fms %7s' % \ (name, min_time * MILLI_SECONDS, other_min_time * MILLI_SECONDS * compare_to.warp / self.warp, min_diff, avg_time * MILLI_SECONDS, other_avg_time * MILLI_SECONDS * compare_to.warp / self.warp, - avg_diff) - print '-' * LINE + avg_diff)) + print('-' * LINE) # Summarise test results if not benchmarks_compatible or not tests_compatible: @@ -730,7 +726,7 @@ (other_total_avg_time * compare_to.warp) - 1.0) * PERCENT) else: avg_diff = 'n/a' - print ('Totals: ' + print(('Totals: ' ' %5.0fms %5.0fms %7s %5.0fms %5.0fms %7s' % (total_min_time * MILLI_SECONDS, (other_total_min_time * compare_to.warp/self.warp @@ -740,11 +736,11 @@ (other_total_avg_time * compare_to.warp/self.warp * MILLI_SECONDS), avg_diff - )) - print - print '(this=%s, other=%s)' % (self.name, - compare_to.name) - print + ))) + print() + print('(this=%s, other=%s)' % (self.name, + compare_to.name)) + print() class PyBenchCmdline(Application): @@ -823,8 +819,8 @@ limitnames = self.values['-t'] if limitnames: if _debug: - print '* limiting test names to one with substring "%s"' % \ - limitnames + print('* limiting test names to one with substring "%s"' % \ + limitnames) limitnames = re.compile(limitnames, re.I) else: limitnames = None @@ -833,26 +829,26 @@ calibration_runs = self.values['-C'] timer = self.values['--timer'] - print '-' * LINE - print 'PYBENCH %s' % __version__ - print '-' * LINE - print '* using %s %s' % ( + print('-' * LINE) + print('PYBENCH %s' % __version__) + print('-' * LINE) + print('* using %s %s' % ( platform.python_implementation(), - string.join(string.split(sys.version), ' ')) + ' '.join(sys.version.split()))) # Switch off garbage collection if not withgc: try: import gc except ImportError: - print '* Python version doesn\'t support garbage collection' + print('* Python version doesn\'t support garbage collection') else: try: gc.disable() except NotImplementedError: - print '* Python version doesn\'t support gc.disable' + print('* Python version doesn\'t support gc.disable') else: - print '* disabled garbage collection' + print('* disabled garbage collection') # "Disable" sys check interval if not withsyscheck: @@ -861,18 +857,18 @@ try: sys.setcheckinterval(value) except (AttributeError, NotImplementedError): - print '* Python version doesn\'t support sys.setcheckinterval' + print('* Python version doesn\'t support sys.setcheckinterval') else: - print '* system check interval set to maximum: %s' % value + print('* system check interval set to maximum: %s' % value) if timer == TIMER_SYSTIMES_PROCESSTIME: import systimes - print '* using timer: systimes.processtime (%s)' % \ - systimes.SYSTIMES_IMPLEMENTATION + print('* using timer: systimes.processtime (%s)' % \ + systimes.SYSTIMES_IMPLEMENTATION) else: - print '* using timer: %s' % timer + print('* using timer: %s' % timer) - print + print() if compare_to: try: @@ -882,9 +878,9 @@ f.close() compare_to = bench except IOError as reason: - print '* Error opening/reading file %s: %s' % ( + print('* Error opening/reading file %s: %s' % ( repr(compare_to), - reason) + reason)) compare_to = None if show_bench: @@ -902,16 +898,16 @@ bench.print_benchmark(hidenoise=hidenoise, limitnames=limitnames) except IOError as reason: - print '* Error opening/reading file %s: %s' % ( + print('* Error opening/reading file %s: %s' % ( repr(show_bench), - reason) - print + reason)) + print() return if reportfile: - print 'Creating benchmark: %s (rounds=%i, warp=%i)' % \ - (reportfile, rounds, warp) - print + print('Creating benchmark: %s (rounds=%i, warp=%i)' % \ + (reportfile, rounds, warp)) + print() # Create benchmark object bench = Benchmark(reportfile, @@ -925,9 +921,9 @@ bench.calibrate() bench.run() except KeyboardInterrupt: - print - print '*** KeyboardInterrupt -- Aborting' - print + print() + print('*** KeyboardInterrupt -- Aborting') + print() return bench.print_header() if compare_to: @@ -948,12 +944,12 @@ pickle.dump(bench,f) f.close() except IOError as reason: - print '* Error opening/writing reportfile' + print('* Error opening/writing reportfile') except IOError as reason: - print '* Error opening/writing reportfile %s: %s' % ( + print('* Error opening/writing reportfile %s: %s' % ( reportfile, - reason) - print + reason)) + print() if __name__ == '__main__': PyBenchCmdline() Modified: python/branches/py3k-struni/Tools/pybench/systimes.py ============================================================================== --- python/branches/py3k-struni/Tools/pybench/systimes.py (original) +++ python/branches/py3k-struni/Tools/pybench/systimes.py Sat Jun 30 07:01:58 2007 @@ -185,27 +185,27 @@ x = x + 1 def test_workload(): - print 'Testing systimes() under load conditions' + print('Testing systimes() under load conditions') t0 = systimes() some_workload() t1 = systimes() - print 'before:', t0 - print 'after:', t1 - print 'differences:', (t1[0] - t0[0], t1[1] - t0[1]) - print + print('before:', t0) + print('after:', t1) + print('differences:', (t1[0] - t0[0], t1[1] - t0[1])) + print() def test_idle(): - print 'Testing systimes() under idle conditions' + print('Testing systimes() under idle conditions') t0 = systimes() time.sleep(1) t1 = systimes() - print 'before:', t0 - print 'after:', t1 - print 'differences:', (t1[0] - t0[0], t1[1] - t0[1]) - print + print('before:', t0) + print('after:', t1) + print('differences:', (t1[0] - t0[0], t1[1] - t0[1])) + print() if __name__ == '__main__': - print 'Using %s as timer' % SYSTIMES_IMPLEMENTATION - print + print('Using %s as timer' % SYSTIMES_IMPLEMENTATION) + print() test_workload() test_idle() Modified: python/branches/py3k-struni/runtests.sh ============================================================================== --- python/branches/py3k-struni/runtests.sh (original) +++ python/branches/py3k-struni/runtests.sh Sat Jun 30 07:01:58 2007 @@ -25,7 +25,7 @@ >SKIPPED # The -u flag (edit this file to change). -UFLAG="-unetwork" +UFLAG="" # Compute the list of tests to run. case $# in From python-3000-checkins at python.org Sat Jun 30 09:32:49 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Sat, 30 Jun 2007 09:32:49 +0200 (CEST) Subject: [Python-3000-checkins] r56127 - python/branches/p3yk/Lib/pydoc.py Message-ID: <20070630073249.D64131E400A@bag.python.org> Author: georg.brandl Date: Sat Jun 30 09:32:49 2007 New Revision: 56127 Modified: python/branches/p3yk/Lib/pydoc.py Log: Fix a place where floor division would be in order. Modified: python/branches/p3yk/Lib/pydoc.py ============================================================================== --- python/branches/p3yk/Lib/pydoc.py (original) +++ python/branches/p3yk/Lib/pydoc.py Sat Jun 30 09:32:49 2007 @@ -470,9 +470,9 @@ def multicolumn(self, list, format, cols=4): """Format a list of items into a multi-column list.""" result = '' - rows = (len(list)+cols-1)/cols + rows = (len(list)+cols-1)//cols for col in range(cols): - result = result + '' % (100/cols) + result = result + '' % (100//cols) for i in range(rows*col, rows*col+rows): if i < len(list): result = result + format(list[i]) + '
\n' From python-3000-checkins at python.org Sat Jun 30 11:22:09 2007 From: python-3000-checkins at python.org (martin.v.loewis) Date: Sat, 30 Jun 2007 11:22:09 +0200 (CEST) Subject: [Python-3000-checkins] r56128 - in python/branches/py3k-struni/Lib: httplib.py test/test_httplib.py Message-ID: <20070630092209.CA8921E400A@bag.python.org> Author: martin.v.loewis Date: Sat Jun 30 11:22:09 2007 New Revision: 56128 Modified: python/branches/py3k-struni/Lib/httplib.py python/branches/py3k-struni/Lib/test/test_httplib.py Log: Fix test_httplib. Modified: python/branches/py3k-struni/Lib/httplib.py ============================================================================== --- python/branches/py3k-struni/Lib/httplib.py (original) +++ python/branches/py3k-struni/Lib/httplib.py Sat Jun 30 11:22:09 2007 @@ -711,8 +711,8 @@ Appends an extra \\r\\n to the buffer. """ - self._buffer.extend(("", "")) - msg = "\r\n".join(self._buffer) + self._buffer.extend((b"", b"")) + msg = b"\r\n".join(self._buffer) del self._buffer[:] self.send(msg) @@ -758,9 +758,10 @@ self._method = method if not url: url = '/' - str = '%s %s %s' % (method, url, self._http_vsn_str) + request = '%s %s %s' % (method, url, self._http_vsn_str) - self._output(str) + # Non-ASCII characters should have been eliminated earlier + self._output(request.encode('ascii')) if self._http_vsn == 11: # Issue some standard headers for better HTTP/1.1 compliance @@ -831,8 +832,8 @@ if self.__state != _CS_REQ_STARTED: raise CannotSendHeader() - str = '%s: %s' % (header, value) - self._output(str) + header = '%s: %s' % (header, value) + self._output(header.encode('ascii')) def endheaders(self): """Indicate that the last header line has been sent to the server.""" @@ -846,7 +847,6 @@ def request(self, method, url, body=None, headers={}): """Send a complete request to the server.""" - try: self._send_request(method, url, body, headers) except socket.error as v: @@ -888,6 +888,7 @@ self.endheaders() if body: + if isinstance(body, str): body = body.encode('ascii') self.send(body) def getresponse(self): Modified: python/branches/py3k-struni/Lib/test/test_httplib.py ============================================================================== --- python/branches/py3k-struni/Lib/test/test_httplib.py (original) +++ python/branches/py3k-struni/Lib/test/test_httplib.py Sat Jun 30 11:22:09 2007 @@ -11,7 +11,7 @@ def __init__(self, text, fileclass=StringIO.StringIO): self.text = text self.fileclass = fileclass - self.data = '' + self.data = b'' def sendall(self, data): self.data += data @@ -54,7 +54,7 @@ kv = item.split(':') if len(kv) > 1: # item is a 'Key: Value' header string - lcKey = kv[0].lower() + lcKey = kv[0].decode('ascii').lower() self.count.setdefault(lcKey, 0) self.count[lcKey] += 1 list.append(self, item)