diff options
author | Georg Brandl <georg@python.org> | 2008-06-04 11:41:32 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2008-06-04 11:41:32 (GMT) |
commit | f954c4b9fb8529cc13a2e24c58137c66ac836b28 (patch) | |
tree | 91575068c14eec261bc4e2c44da9c881eda4efe1 /Python | |
parent | e5d68aceb529934e75d505bbfaf867e02493a1bc (diff) | |
download | cpython-f954c4b9fb8529cc13a2e24c58137c66ac836b28.zip cpython-f954c4b9fb8529cc13a2e24c58137c66ac836b28.tar.gz cpython-f954c4b9fb8529cc13a2e24c58137c66ac836b28.tar.bz2 |
Remove meaning of -ttt, but still accept -t option on cmdline for compatibility.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bltinmodule.c | 33 | ||||
-rw-r--r-- | Python/sysmodule.c | 6 |
2 files changed, 35 insertions, 4 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 3dc6a00..6b14003 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -265,6 +265,38 @@ PyDoc_STRVAR(any_doc, \n\ Return True if bool(x) is True for any x in the iterable."); +static PyObject * +builtin_ascii(PyObject *self, PyObject *v) +{ + PyObject *repr, *bytes, *ascii; + repr = PyObject_Repr(v); + if (!repr) + return NULL; + + bytes = PyUnicode_EncodeASCII( + PyUnicode_AS_UNICODE(repr), + PyUnicode_GET_SIZE(repr), + "backslashreplace"); + + Py_DECREF(repr); + if (bytes == NULL) + return NULL; + + ascii = PyUnicode_FromEncodedObject(bytes, + "ASCII", NULL); + Py_DECREF(bytes); + if (ascii == NULL) + return NULL; + + return ascii; +} + +PyDoc_STRVAR(ascii_doc, +"ascii(object) -> string\n\ +\n\ +Return the canonical string representation of the object as repr(),\n\ +but non-ASCII characters in the string are hex-escaped"); + static PyObject * builtin_bin(PyObject *self, PyObject *v) @@ -2188,6 +2220,7 @@ static PyMethodDef builtin_methods[] = { {"abs", builtin_abs, METH_O, abs_doc}, {"all", builtin_all, METH_O, all_doc}, {"any", builtin_any, METH_O, any_doc}, + {"ascii", builtin_ascii, METH_O, ascii_doc}, {"bin", builtin_bin, METH_O, bin_doc}, {"chr", builtin_chr, METH_VARARGS, chr_doc}, {"cmp", builtin_cmp, METH_VARARGS, cmp_doc}, diff --git a/Python/sysmodule.c b/Python/sysmodule.c index c33457f..dee4965 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1100,7 +1100,6 @@ static PyStructSequence_Field flags_fields[] = { {"no_user_site", "-s"}, {"no_site", "-S"}, {"ignore_environment", "-E"}, - {"tabcheck", "-t or -tt"}, {"verbose", "-v"}, #ifdef RISCOS {"riscos_wimp", "???"}, @@ -1116,9 +1115,9 @@ static PyStructSequence_Desc flags_desc = { flags__doc__, /* doc */ flags_fields, /* fields */ #ifdef RISCOS - 12 -#else 11 +#else + 10 #endif }; @@ -1144,7 +1143,6 @@ make_flags(void) SetFlag(Py_NoUserSiteDirectory); SetFlag(Py_NoSiteFlag); SetFlag(Py_IgnoreEnvironmentFlag); - SetFlag(Py_TabcheckFlag); SetFlag(Py_VerboseFlag); #ifdef RISCOS SetFlag(Py_RISCOSWimpFlag); |