cpython: d7aff4423172 (original) (raw)

Mercurial > cpython

changeset 77072:d7aff4423172 2.7

Issue #8767: Restore building with --disable-unicode. Original patch by Stefano Taschini. [#8767]

Martin v. Löwis martin@v.loewis.de
date Sun, 20 May 2012 10:42:17 +0200
parents e31597b3bd15
children 235ee0a32ab5 f457419552e3
files Lib/glob.py Lib/locale.py Lib/posixpath.py Lib/test/script_helper.py Lib/test/test_support.py Lib/textwrap.py Lib/unittest/case.py Misc/ACKS Misc/NEWS Objects/object.c Python/bltinmodule.c Python/peephole.c configure configure.ac
diffstat 14 files changed, 63 insertions(+), 9 deletions(-)[+] [-] Lib/glob.py 10 Lib/locale.py 10 Lib/posixpath.py 12 Lib/test/script_helper.py 8 Lib/test/test_support.py 2 Lib/textwrap.py 12 Lib/unittest/case.py 6 Misc/ACKS 1 Misc/NEWS 3 Objects/object.c 2 Python/bltinmodule.c 2 Python/peephole.c 2 configure 1 configure.ac 1

line wrap: on

line diff

--- a/Lib/glob.py +++ b/Lib/glob.py @@ -5,6 +5,14 @@ import os import re import fnmatch +try:

+except NameError:

+ all = ["glob", "iglob"] def glob(pathname): @@ -49,7 +57,7 @@ def iglob(pathname): def glob1(dirname, pattern): if not dirname: dirname = os.curdir

--- a/Lib/locale.py +++ b/Lib/locale.py @@ -18,6 +18,14 @@ import re import operator import functools +try:

+except NameError:

+

Try importing the _locale module.

#

If this fails, fall back on a basic 'C' locale emulation.

@@ -353,7 +361,7 @@ def normalize(localename): """ # Normalize the locale name and extract the encoding

--- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -17,6 +17,14 @@ import genericpath import warnings from genericpath import * +try:

+except NameError:

+ all = ["normcase","isabs","join","splitdrive","split","splitext", "basename","dirname","commonprefix","getsize","getmtime", "getatime","getctime","islink","exists","lexists","isdir","isfile", @@ -312,7 +320,7 @@ def expandvars(path): def normpath(path): """Normalize path, eliminating double slashes, etc.""" # Preserve unicode (if path is unicode)

--- a/Lib/test/script_helper.py +++ b/Lib/test/script_helper.py @@ -10,7 +10,13 @@ import subprocess import py_compile import contextlib import shutil -import zipfile +try:

+except ImportError:

from test.test_support import strip_python_stderr

--- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -405,7 +405,7 @@ def temp_cwd(name='tempcwd', quiet=False the CWD, an error is raised. If it's True, only a warning is raised and the original CWD is used. """

--- a/Lib/textwrap.py +++ b/Lib/textwrap.py @@ -9,6 +9,14 @@ import string, re +try:

+except NameError:

+

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) by uncommenting the block of code below.

@@ -147,7 +155,7 @@ class TextWrapper: if self.replace_whitespace: if isinstance(text, str): text = text.translate(self.whitespace_trans)

@@ -167,7 +175,7 @@ class TextWrapper: 'use', ' ', 'the', ' ', '-b', ' ', option!' otherwise. """

--- a/Lib/unittest/case.py +++ b/Lib/unittest/case.py @@ -202,7 +202,11 @@ class TestCase(object): self.addTypeEqualityFunc(tuple, 'assertTupleEqual') self.addTypeEqualityFunc(set, 'assertSetEqual') self.addTypeEqualityFunc(frozenset, 'assertSetEqual')

def addTypeEqualityFunc(self, typeobj, function): """Add a type specific assertEqual style function to compare a type.

--- a/Misc/ACKS +++ b/Misc/ACKS @@ -839,6 +839,7 @@ Arfrever Frehtes Taifersar Arahesis Geoff Talvola William Tanksley Christian Tanzer +Stefano Taschini Steven Taschuk Monty Taylor Amy Taylor

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -191,6 +191,9 @@ Tests Build ----- +- Issue #8767: Restore building with --disable-unicode.

--- a/Objects/object.c +++ b/Objects/object.c @@ -2111,8 +2111,10 @@ void if (PyType_Ready(&PySet_Type) < 0) Py_FatalError("Can't initialize set type"); +#ifdef Py_USING_UNICODE if (PyType_Ready(&PyUnicode_Type) < 0) Py_FatalError("Can't initialize unicode type"); +#endif if (PyType_Ready(&PySlice_Type) < 0) Py_FatalError("Can't initialize slice type");

--- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1578,6 +1578,7 @@ builtin_print(PyObject *self, PyObject * Py_CLEAR(str_newline); return NULL; } +#ifdef Py_USING_UNICODE unicode_newline = PyUnicode_FromString("\n"); if (unicode_newline == NULL) { Py_CLEAR(str_newline); @@ -1591,6 +1592,7 @@ builtin_print(PyObject *self, PyObject * Py_CLEAR(unicode_space); return NULL; } +#endif } if (!PyArg_ParseTupleAndKeywords(dummy_args, kwds, "|OOO:print", kwlist, &sep, &end, &file))

--- a/Python/peephole.c +++ b/Python/peephole.c @@ -135,6 +135,7 @@ fold_binops_on_constants(unsigned char * will return a surrogate. In both the cases skip the optimization in order to produce compatible pycs. */ +#ifdef Py_USING_UNICODE if (newconst != NULL && PyUnicode_Check(v) && PyUnicode_Check(newconst)) { Py_UNICODE ch = PyUnicode_AS_UNICODE(newconst)[0]; @@ -147,6 +148,7 @@ fold_binops_on_constants(unsigned char * return 0; } } +#endif break; case BINARY_LSHIFT: newconst = PyNumber_Lshift(v, w);

--- a/configure +++ b/configure @@ -12522,6 +12522,7 @@ ucs4) unicode_size="4" $as_echo "#define Py_UNICODE_SIZE 4" >>confdefs.h ;; +no) ;; # To allow --disable-unicode *) as_fn_error ?"invalidvaluefor−−enable−unicode.Useeitherucs2orucs4(lowercase).""? "invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase)." "?"invalidvalueforenableunicode.Useeitherucs2orucs4(lowercase).""LINENO" 5 ;; esac

--- a/configure.ac +++ b/configure.ac @@ -3776,6 +3776,7 @@ ucs2) unicode_size="2" ucs4) unicode_size="4" AC_DEFINE(Py_UNICODE_SIZE,4) ;; +no) ;; # To allow --disable-unicode *) AC_MSG_ERROR([invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase).]) ;; esac