]> granicus.if.org Git - python/commitdiff
Get rid of builtin_open() entirely (the C code and docstring, not the
authorTim Peters <tim.peters@gmail.com>
Thu, 13 Sep 2001 21:49:44 +0000 (21:49 +0000)
committerTim Peters <tim.peters@gmail.com>
Thu, 13 Sep 2001 21:49:44 +0000 (21:49 +0000)
builtin function); Guido pointed out that it could be just another
name in the __builtin__ dict for the file constructor now.

Objects/fileobject.c
Python/bltinmodule.c

index b37302421caa9d0fa7e1365af9b0179532315a4e..578b6f0c3c3372040264f16d3903cbd493850b74 100644 (file)
@@ -1359,7 +1359,6 @@ file_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
        return f;
 }
 
-/* XXX Keep this in synch with open_doc in bltinmodule.c. */
 static char file_doc[] =
 "file(name[, mode[, buffering]]) -> file object\n"
 "\n"
@@ -1369,7 +1368,8 @@ static char file_doc[] =
 "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.";
+"buffered, and larger numbers specify the buffer size.\n"
+"Note:  open() is an alias for file().\n";
 
 PyTypeObject PyFile_Type = {
        PyObject_HEAD_INIT(&PyType_Type)
index 0c285f69d2938fdda57eab3e27d43b26fb764bf9..64afb1ba22620b69a468fe72ecf26d310d80b009 100644 (file)
@@ -1189,25 +1189,6 @@ static char oct_doc[] =
 Return the octal representation of an integer or long integer.";
 
 
-static PyObject *
-builtin_open(PyObject *self, PyObject *args)
-{
-       return PyFile_Type.tp_new(&PyFile_Type, args, NULL);
-}
-
-/* XXX Keep this in synch with file_doc in fileobject.c. */
-static char open_doc[] =
-"open(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.";
-
-
 static PyObject *
 builtin_ord(PyObject *self, PyObject* obj)
 {
@@ -1802,7 +1783,6 @@ static PyMethodDef builtin_methods[] = {
        {"max",         builtin_max,        METH_VARARGS, max_doc},
        {"min",         builtin_min,        METH_VARARGS, min_doc},
        {"oct",         builtin_oct,        METH_O, oct_doc},
-       {"open",        builtin_open,       METH_VARARGS, open_doc},
        {"ord",         builtin_ord,        METH_O, ord_doc},
        {"pow",         builtin_pow,        METH_VARARGS, pow_doc},
        {"range",       builtin_range,      METH_VARARGS, range_doc},
@@ -1861,6 +1841,9 @@ _PyBuiltin_Init(void)
        SETBUILTIN("super",             &PySuper_Type);
        SETBUILTIN("tuple",             &PyTuple_Type);
        SETBUILTIN("type",              &PyType_Type);
+
+       /* Note that open() is just an alias of file(). */
+       SETBUILTIN("open",              &PyFile_Type);
        SETBUILTIN("file",              &PyFile_Type);
 #ifdef Py_USING_UNICODE
        SETBUILTIN("unicode",           &PyUnicode_Type);