[Python-checkins] r55013 - in python/branches/py3k-struni: Include/pydebug.h Lib/distutils/ccompiler.py Lib/distutils/cmd.py Lib/distutils/command/build_clib.py Lib/distutils/command/build_ext.py Lib/distutils/command/build_py.py Lib/distutils/command/config.py Lib/distutils/command/install.py Lib/distutils/command/install_data.py Lib/distutils/dir_util.py Lib/distutils/dist.py Lib/distutils/extension.py Lib/distutils/fancy_getopt.py Lib/distutils/filelist.py Lib/distutils/unixccompiler.py Lib/locale.py Lib/os.py Lib/sre_compile.py Lib/test/test_builtin.py Modules/posixmodule.c Objects/moduleobject.c Objects/unicodeobject.c Python/ast.c Python/bltinmodule.c Python/ceval.c Python/getargs.c Python/import.c Python/pythonrun.c (original) (raw)

guido.van.rossum python-checkins at python.org
Sat Apr 28 01:54:18 CEST 2007


Author: guido.van.rossum Date: Sat Apr 28 01:53:51 2007 New Revision: 55013

Modified: python/branches/py3k-struni/Include/pydebug.h python/branches/py3k-struni/Lib/distutils/ccompiler.py python/branches/py3k-struni/Lib/distutils/cmd.py python/branches/py3k-struni/Lib/distutils/command/build_clib.py python/branches/py3k-struni/Lib/distutils/command/build_ext.py python/branches/py3k-struni/Lib/distutils/command/build_py.py python/branches/py3k-struni/Lib/distutils/command/config.py python/branches/py3k-struni/Lib/distutils/command/install.py python/branches/py3k-struni/Lib/distutils/command/install_data.py python/branches/py3k-struni/Lib/distutils/dir_util.py python/branches/py3k-struni/Lib/distutils/dist.py python/branches/py3k-struni/Lib/distutils/extension.py python/branches/py3k-struni/Lib/distutils/fancy_getopt.py python/branches/py3k-struni/Lib/distutils/filelist.py python/branches/py3k-struni/Lib/distutils/unixccompiler.py python/branches/py3k-struni/Lib/locale.py python/branches/py3k-struni/Lib/os.py python/branches/py3k-struni/Lib/sre_compile.py python/branches/py3k-struni/Lib/test/test_builtin.py python/branches/py3k-struni/Modules/posixmodule.c python/branches/py3k-struni/Objects/moduleobject.c python/branches/py3k-struni/Objects/unicodeobject.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/getargs.c python/branches/py3k-struni/Python/import.c python/branches/py3k-struni/Python/pythonrun.c Log: Checkpoint. Manipulated things so that string literals are always unicode, and a few other compensating changes, e.g. str <- unicode, chr <- unichr, and repr() of a unicode string no longer starts with 'u'. Lots of unit tests are broken, but some basic things work, in particular distutils works so the extensions can be built, and test_builtin.py works.

Modified: python/branches/py3k-struni/Include/pydebug.h

--- python/branches/py3k-struni/Include/pydebug.h (original) +++ python/branches/py3k-struni/Include/pydebug.h Sat Apr 28 01:53:51 2007 @@ -14,7 +14,6 @@ PyAPI_DATA(int) Py_UseClassExceptionsFlag; PyAPI_DATA(int) Py_FrozenFlag; PyAPI_DATA(int) Py_TabcheckFlag; -PyAPI_DATA(int) Py_UnicodeFlag; PyAPI_DATA(int) Py_IgnoreEnvironmentFlag; PyAPI_DATA(int) Py_DivisionWarningFlag;

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 Sat Apr 28 01:53:51 2007 @@ -168,7 +168,7 @@ # set_executables ()

 def set_executable(self, key, value):

@@ -193,8 +193,8 @@ if not (type (defn) is TupleType and (len (defn) == 1 or (len (defn) == 2 and

@@ -344,7 +344,7 @@ """ if outdir is None: outdir = self.output_dir

@@ -442,7 +442,7 @@ """ if output_dir is None: output_dir = self.output_dir

@@ -527,7 +527,7 @@

     if output_dir is None:
         output_dir = self.output_dir

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 Sat Apr 28 01:53:51 2007 @@ -222,7 +222,7 @@ if val is None: setattr(self, option, default) return default

@@ -242,12 +242,11 @@ val = getattr(self, option) if val is None: return

@@ -421,7 +420,7 @@

     # Allow 'infiles' to be a single string

Modified: python/branches/py3k-struni/Lib/distutils/command/build_clib.py

--- python/branches/py3k-struni/Lib/distutils/command/build_clib.py (original) +++ python/branches/py3k-struni/Lib/distutils/command/build_clib.py Sat Apr 28 01:53:51 2007 @@ -92,7 +92,7 @@

     if self.include_dirs is None:
         self.include_dirs = self.distribution.include_dirs or []

@@ -147,7 +147,7 @@ raise DistutilsSetupError,
"each element of 'libraries' must a 2-tuple"

Modified: python/branches/py3k-struni/Lib/distutils/command/build_ext.py

--- python/branches/py3k-struni/Lib/distutils/command/build_ext.py (original) +++ python/branches/py3k-struni/Lib/distutils/command/build_ext.py Sat Apr 28 01:53:51 2007 @@ -137,7 +137,7 @@ plat_py_include = sysconfig.get_python_inc(plat_specific=1) if self.include_dirs is None: self.include_dirs = self.distribution.include_dirs or []

@@ -146,7 +146,7 @@ if plat_py_include != py_include: self.include_dirs.append(plat_py_include)

@@ -155,12 +155,12 @@ self.libraries = [] if self.library_dirs is None: self.library_dirs = []

@@ -321,7 +321,7 @@ ("each element of 'ext_modules' option must be an " "Extension instance or 2-tuple")

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 Sat Apr 28 01:53:51 2007 @@ -361,7 +361,7 @@

 def build_module (self, module, module_file, package):

Modified: python/branches/py3k-struni/Lib/distutils/command/config.py

--- python/branches/py3k-struni/Lib/distutils/command/config.py (original) +++ python/branches/py3k-struni/Lib/distutils/command/config.py Sat Apr 28 01:53:51 2007 @@ -73,17 +73,17 @@ def finalize_options (self): if self.include_dirs is None: self.include_dirs = self.distribution.include_dirs or []

@@ -212,7 +212,7 @@ self._check_compiler() (src, out) = self._preprocess(body, headers, include_dirs, lang)

Modified: python/branches/py3k-struni/Lib/distutils/command/install.py

--- python/branches/py3k-struni/Lib/distutils/command/install.py (original) +++ python/branches/py3k-struni/Lib/distutils/command/install.py Sat Apr 28 01:53:51 2007 @@ -463,7 +463,7 @@ self.extra_path = self.distribution.extra_path

     if self.extra_path is not None:

Modified: python/branches/py3k-struni/Lib/distutils/command/install_data.py

--- python/branches/py3k-struni/Lib/distutils/command/install_data.py (original) +++ python/branches/py3k-struni/Lib/distutils/command/install_data.py Sat Apr 28 01:53:51 2007 @@ -10,7 +10,6 @@ revision = "$Id$"

import os -from types import StringType from distutils.core import Command from distutils.util import change_root, convert_path

@@ -48,7 +47,7 @@ def run (self): self.mkpath(self.install_dir) for f in self.data_files:

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 Apr 28 01:53:51 2007 @@ -31,7 +31,7 @@ global _path_created

 # Detect a common bug -- name is None

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 Sat Apr 28 01:53:51 2007 @@ -598,13 +598,13 @@

     keywords = self.metadata.keywords
     if keywords is not None:

@@ -906,7 +906,7 @@ neg_opt = {}

         try:

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 Sat Apr 28 01:53:51 2007 @@ -103,9 +103,9 @@ language=None, **kw # To catch unknown keywords ):

Modified: python/branches/py3k-struni/Lib/distutils/fancy_getopt.py

--- python/branches/py3k-struni/Lib/distutils/fancy_getopt.py (original) +++ python/branches/py3k-struni/Lib/distutils/fancy_getopt.py Sat Apr 28 01:53:51 2007 @@ -166,13 +166,13 @@ raise ValueError, "invalid option tuple: %r" % (option,)

         # Type- and value-check the option names

Modified: python/branches/py3k-struni/Lib/distutils/filelist.py

--- python/branches/py3k-struni/Lib/distutils/filelist.py (original) +++ python/branches/py3k-struni/Lib/distutils/filelist.py Sat Apr 28 01:53:51 2007 @@ -333,7 +333,7 @@ or just returned as-is (assumes it's a regex object). """ if is_regex:

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 Sat Apr 28 01:53:51 2007 @@ -16,7 +16,7 @@ revision = "$Id$"

import os, sys -from types import StringType, NoneType +from types import NoneType from copy import copy

from distutils import sysconfig @@ -212,7 +212,7 @@

     lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,
                                libraries)

Modified: python/branches/py3k-struni/Lib/locale.py

--- python/branches/py3k-struni/Lib/locale.py (original) +++ python/branches/py3k-struni/Lib/locale.py Sat Apr 28 01:53:51 2007 @@ -470,7 +470,7 @@ category may be given as one of the LC_* values.

 """

Modified: python/branches/py3k-struni/Lib/os.py

--- python/branches/py3k-struni/Lib/os.py (original) +++ python/branches/py3k-struni/Lib/os.py Sat Apr 28 01:53:51 2007 @@ -733,8 +733,8 @@ _urandomfd = open("/dev/urandom", O_RDONLY) except (OSError, IOError): raise NotImplementedError("/dev/urandom (or equivalent) not found")

Modified: python/branches/py3k-struni/Lib/sre_compile.py

--- python/branches/py3k-struni/Lib/sre_compile.py (original) +++ python/branches/py3k-struni/Lib/sre_compile.py Sat Apr 28 01:53:51 2007 @@ -470,18 +470,8 @@ _compile_charset(charset, flags, code) code[skip] = len(code) - skip -try: - unicode -except NameError: - STRING_TYPES = (type(""),) -else: - STRING_TYPES = (type(""), type(unicode("")))

def isstring(obj):

def _code(p, flags):

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 Sat Apr 28 01:53:51 2007 @@ -82,7 +82,7 @@ (unicode('100'), 100), (unicode('314'), 314), (unicode(' 314'), 314),

@@ -185,7 +185,7 @@ self.assertEqual(chr(65), 'A') self.assertEqual(chr(97), 'a') self.assertEqual(chr(0xff), '\xff')

@@ -209,7 +209,7 @@ def test_compile(self): compile('print(1)\n', '', 'exec') bom = '\xef\xbb\xbf'

@@ -220,7 +220,7 @@ self.assertRaises(TypeError, compile, 'pass', '?', 'exec', mode='eval', source='0', filename='tmp') if have_unicode:

@@ -339,9 +339,9 @@ self.assertEqual(eval(unicode('b'), globals, locals), 200) self.assertEqual(eval(unicode('c'), globals, locals), 300) bom = '\xef\xbb\xbf'

@@ -608,7 +608,7 @@ self.assertRaises(ValueError, float, " -0x3.p-1 ") if have_unicode: self.assertEqual(float(unicode(" 3.14 ")), 3.14)

@@ -1673,7 +1673,7 @@ self.assertEqual(unichr(97), unicode('a')) self.assertEqual( unichr(sys.maxunicode),

Modified: python/branches/py3k-struni/Modules/posixmodule.c

--- python/branches/py3k-struni/Modules/posixmodule.c (original) +++ python/branches/py3k-struni/Modules/posixmodule.c Sat Apr 28 01:53:51 2007 @@ -6163,7 +6163,8 @@ static PyObject * posix_read(PyObject *self, PyObject *args) { - int fd, size, n; + int fd, size; + Py_ssize_t n; PyObject *buffer; if (!PyArg_ParseTuple(args, "ii:read", &fd, &size)) return NULL; @@ -6171,18 +6172,18 @@ errno = EINVAL; return posix_error(); } - buffer = PyString_FromStringAndSize((char *)NULL, size); + buffer = PyBytes_FromStringAndSize((char *)NULL, size); if (buffer == NULL) return NULL; Py_BEGIN_ALLOW_THREADS - n = read(fd, PyString_AsString(buffer), size); + n = read(fd, PyBytes_AsString(buffer), size); Py_END_ALLOW_THREADS if (n < 0) { Py_DECREF(buffer); return posix_error(); } if (n != size) - _PyString_Resize(&buffer, n); + PyBytes_Resize(buffer, n); return buffer; } @@ -8841,5 +8842,3 @@ #ifdef __cplusplus } #endif

Modified: python/branches/py3k-struni/Objects/moduleobject.c

--- python/branches/py3k-struni/Objects/moduleobject.c (original) +++ python/branches/py3k-struni/Objects/moduleobject.c Sat Apr 28 01:53:51 2007 @@ -59,6 +59,7 @@ { PyObject *d; PyObject *nameobj; + char *s; if (!PyModule_Check(m)) { PyErr_BadArgument(); return NULL; @@ -66,11 +67,13 @@ d = ((PyModuleObject *)m)->md_dict; if (d == NULL || (nameobj = PyDict_GetItemString(d, "name")) == NULL || - !PyString_Check(nameobj)) + !(PyString_Check(nameobj) || PyUnicode_Check(nameobj))) { PyErr_SetString(PyExc_SystemError, "nameless module"); 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 Sat Apr 28 01:53:51 2007 @@ -2072,7 +2072,6 @@ p = PyString_AS_STRING(repr);

 if (quotes) {

@@ -2167,7 +2166,7 @@ *p++ = (char) ch; } if (quotes)

Modified: python/branches/py3k-struni/Python/ast.c

--- python/branches/py3k-struni/Python/ast.c (original) +++ python/branches/py3k-struni/Python/ast.c Sat Apr 28 01:53:51 2007 @@ -3187,7 +3187,7 @@ } } #ifdef Py_USING_UNICODE

#endif

Modified: python/branches/py3k-struni/Python/bltinmodule.c

--- python/branches/py3k-struni/Python/bltinmodule.c (original) +++ python/branches/py3k-struni/Python/bltinmodule.c Sat Apr 28 01:53:51 2007 @@ -2270,7 +2270,7 @@ {"all", builtin_all, METH_O, all_doc}, {"any", builtin_any, METH_O, any_doc}, {"callable", builtin_callable, METH_O, callable_doc},

@@ -2375,7 +2375,7 @@ SETBUILTIN("set", &PySet_Type); SETBUILTIN("slice", &PySlice_Type); SETBUILTIN("staticmethod", &PyStaticMethod_Type); - SETBUILTIN("str", &PyString_Type); + SETBUILTIN("str", &PyUnicode_Type); SETBUILTIN("super", &PySuper_Type); SETBUILTIN("tuple", &PyTuple_Type); SETBUILTIN("type", &PyType_Type);

Modified: python/branches/py3k-struni/Python/ceval.c

--- python/branches/py3k-struni/Python/ceval.c (original) +++ python/branches/py3k-struni/Python/ceval.c Sat Apr 28 01:53:51 2007 @@ -2633,7 +2633,7 @@ PyObject keyword = kws[2i]; PyObject value = kws[2i + 1]; int j; - if (keyword == NULL || !PyString_Check(keyword)) { + if (keyword == NULL || !(PyString_Check(keyword) || PyUnicode_Check(keyword))) { PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", PyString_AsString(co->co_name));

Modified: python/branches/py3k-struni/Python/getargs.c

--- python/branches/py3k-struni/Python/getargs.c (original) +++ python/branches/py3k-struni/Python/getargs.c Sat Apr 28 01:53:51 2007 @@ -1081,7 +1081,7 @@

 case 'S': { /* string object */
     PyObject **p = va_arg(*p_va, PyObject **);

@@ -1531,7 +1531,7 @@ while (PyDict_Next(keywords, &pos, &key, &value)) { int match = 0; char *ks; - if (!PyString_Check(key)) { + if (!PyString_Check(key) && !PyUnicode_Check(key)) { PyErr_SetString(PyExc_TypeError, "keywords must be strings"); return cleanreturn(0, freelist);

Modified: python/branches/py3k-struni/Python/import.c

--- python/branches/py3k-struni/Python/import.c (original) +++ python/branches/py3k-struni/Python/import.c Sat Apr 28 01:53:51 2007 @@ -154,7 +154,7 @@ } }

Modified: python/branches/py3k-struni/Python/pythonrun.c

--- python/branches/py3k-struni/Python/pythonrun.c (original) +++ python/branches/py3k-struni/Python/pythonrun.c Sat Apr 28 01:53:51 2007 @@ -76,7 +76,6 @@ int Py_NoSiteFlag; /* Suppress 'import site' / int Py_UseClassExceptionsFlag = 1; / Needed by bltinmodule.c: deprecated / int Py_FrozenFlag; / Needed by getpath.c / -int Py_UnicodeFlag = 0; / Needed by compile.c / int Py_IgnoreEnvironmentFlag; / e.g. PYTHONPATH, PYTHONHOME */

/* Reference to 'warnings' module, to avoid importing it



More information about the Python-checkins mailing list