larry avatar larry committed f7396e1

Touched up the experimental extension / alternate file writing support.

Comments (0)

Files changed (5)

Modules/posixmodule.c

    of the compiler used.  Different compilers define their own feature
    test macro, e.g. '__BORLANDC__' or '_MSC_VER'. */
 
-/*[python]
-
-clinic.write_clinic_file()
-
-[python]*/
-
-/*[python end:adc83b19e793491b1c6ea0fd8b46cd9f32e592fc]*/
-
 
 
 #ifdef __APPLE__
 
     type = "path_t"
 
-    format_unit_map = {
-        frozenset() : "O&",
-        }
-
     def __init__(self, name, default=unspecified):
         super().__init__(name, default)
         self.flags['converter'] = "path_converter"
 
     def default(self, s):
         assert s is unspecified
-        allow_fd = str(int(bool(self.flags.get('allow_fd'))))
-        nullable = str(int(bool(self.flags.get('nullable'))))
+
+        def get(s):
+            return str(int(bool(self.flags.get(s))))
 
         return "".join([
             "PATH_T_INITIALIZE(",
             '"',
             clinic.name,
             '", ',
-            nullable,
+            get('nullable'),
             ", ",
-            allow_fd,
+            get('allow_fd'),
             ")"
             ])
 
   an open file descriptor.
 
 [clinic]*/
+
+PyDoc_STRVAR(os_stat__doc__,
+"os.stat(path, *[, dir_fd=None[, follow_symlinks=True]]) -> stat result\n"
+"\n"
+"Perform a stat system call on the given path.\n"
+"\n"
+"path\n"
+"    Path to be examined; can be string, bytes, or open-file-descriptor int.\n"
+"\n"
+"dir_fd\n"
+"    If not None, it should be a file descriptor open to a directory,\n"
+"    and path should be a relative string; path will then be relative to\n"
+"    that directory.\n"
+"\n"
+"follow_symlinks\n"
+"    If False, and the last element of the path is a symbolic link,\n"
+"    stat will examine the symbolic link itself instead of the file\n"
+"    the link points to.\n"
+"\n"
+"dir_fd and follow_symlinks may not be implemented\n"
+"  on your platform.  If they are unavailable, using them will raise a\n"
+"  NotImplementedError.\n"
+"\n"
+"It's an error to use dir_fd or follow_symlinks when specifying path as\n"
+"  an open file descriptor.\n"
+"\n");
+
+#define OS_STAT_METHODDEF    \
+    {"stat", (PyCFunction)os_stat, METH_VARARGS | METH_KEYWORDS, os_stat__doc__}
+
+static PyObject *
+os_stat_impl(PyObject *self, path_t path, int dir_fd, int follow_symlinks);
+
+static PyObject *
+os_stat(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+    PyObject *_return_value;
+    path_t path = PATH_T_INITIALIZE("stat", 0, 1);
+    int dir_fd = DEFAULT_DIR_FD;
+    int follow_symlinks = 1;
+    static char *_keywords[] = {"path", "dir_fd", "follow_symlinks", NULL};
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+        "O&|$O&p:stat", _keywords,
+        path_converter, &path, OS_STAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks))
+        return NULL;
+
+    _return_value = os_stat_impl(self, path, dir_fd, follow_symlinks);
+    path_cleanup(&path);
+    return _return_value;
+}
+
 static PyObject *
 os_stat_impl(PyObject *self, path_t path, int dir_fd, int follow_symlinks)
-/*[clinic end:d83faeb41d0a05738c16c49643d41a1dce830a53]*/
+/*[clinic end:80f49f64e690056b1c1103ff331ad3e59366239f]*/
 {
     PyObject *return_value = posix_do_stat("stat", &path, dir_fd, follow_symlinks);
     return return_value;
   has the specified access to the path.
 
 [clinic]*/
+
+PyDoc_STRVAR(os_access__doc__,
+"os.access(path, mode, *[, dir_fd=None[, effective_ids=False[, follow_symlinks=True]]])\n"
+"\n"
+"Use the real uid/gid to test for access to a path.\n"
+"Returns True if granted, False otherwise.\n"
+"\n"
+"path\n"
+"    Path to be tested; can be string, bytes, or open-file-descriptor int.\n"
+"\n"
+"mode\n"
+"    Operating-system mode bitfield.  Can be F_OK to test existence,\n"
+"    or the inclusive-OR of R_OK, W_OK, and X_OK.\n"
+"\n"
+"dir_fd\n"
+"    If not None, it should be a file descriptor open to a directory,\n"
+"    and path should be relative; path will then be relative to that\n"
+"    directory.\n"
+"\n"
+"effective_ids\n"
+"    If True, access will use the effective uid/gid instead of\n"
+"    the real uid/gid.\n"
+"\n"
+"follow_symlinks\n"
+"    If False, and the last element of the path is a symbolic link,\n"
+"    access will examine the symbolic link itself instead of the file\n"
+"    the link points to.\n"
+"\n"
+"dir_fd, effective_ids, and follow_symlinks may not be implemented\n"
+"  on your platform.  If they are unavailable, using them will raise a\n"
+"  NotImplementedError.\n"
+"\n"
+"Note that most operations will use the effective uid/gid, therefore this\n"
+"  routine can be used in a suid/sgid environment to test if the invoking user\n"
+"  has the specified access to the path.\n"
+"\n");
+
+#define OS_ACCESS_METHODDEF    \
+    {"access", (PyCFunction)os_access, METH_VARARGS | METH_KEYWORDS, os_access__doc__}
+
+static PyObject *
+os_access_impl(PyObject *self, path_t path, int mode, int dir_fd, int effective_ids, int follow_symlinks);
+
+static PyObject *
+os_access(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+    PyObject *_return_value;
+    path_t path = PATH_T_INITIALIZE("access", 0, 1);
+    int mode;
+    int dir_fd = DEFAULT_DIR_FD;
+    int effective_ids = 0;
+    int follow_symlinks = 1;
+    static char *_keywords[] = {"path", "mode", "dir_fd", "effective_ids", "follow_symlinks", NULL};
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+        "O&i|$O&pp:access", _keywords,
+        path_converter, &path, &mode, OS_ACCESS_DIR_FD_CONVERTER, &dir_fd, &effective_ids, &follow_symlinks))
+        return NULL;
+
+    _return_value = os_access_impl(self, path, mode, dir_fd, effective_ids, follow_symlinks);
+    path_cleanup(&path);
+    return _return_value;
+}
+
 static PyObject *
 os_access_impl(PyObject *self, path_t path, int mode, int dir_fd, int effective_ids, int follow_symlinks)
-/*[clinic end:c1938d0c04fd5ecbf9aa03a3da48bc88b5691670]*/
+/*[clinic end:69aac9fd37cfaa7dc4910c8e47acfceec8e06eaf]*/
 {
     PyObject *return_value = NULL;
 
 #endif /* defined(TERMSIZE_USE_CONIO) || defined(TERMSIZE_USE_IOCTL) */
 
 
-/*[python]
-
-clinic.include_clinic_file()
-
-[python]*/
-#include "posixmodule_clinic.c"
-/*[python end:6188ef38e05af33d91ae4c558a2e1ce999f94a3f]*/
-
 
 static PyMethodDef posix_methods[] = {
 

Modules/posixmodule_clinic.c

-
-PyDoc_STRVAR(os_stat__doc__,
-"os.stat(path, *[, dir_fd=None[, follow_symlinks=True]]) -> stat result\n"
-"\n"
-"Perform a stat system call on the given path.\n"
-"\n"
-"path\n"
-"    Path to be examined; can be string, bytes, or open-file-descriptor int.\n"
-"\n"
-"dir_fd\n"
-"    If not None, it should be a file descriptor open to a directory,\n"
-"    and path should be a relative string; path will then be relative to\n"
-"    that directory.\n"
-"\n"
-"follow_symlinks\n"
-"    If False, and the last element of the path is a symbolic link,\n"
-"    stat will examine the symbolic link itself instead of the file\n"
-"    the link points to.\n"
-"\n"
-"dir_fd and follow_symlinks may not be implemented\n"
-"  on your platform.  If they are unavailable, using them will raise a\n"
-"  NotImplementedError.\n"
-"\n"
-"It's an error to use dir_fd or follow_symlinks when specifying path as\n"
-"  an open file descriptor.\n"
-"\n");
-
-#define OS_STAT_METHODDEF    \
-    {"stat", (PyCFunction)os_stat, METH_VARARGS | METH_KEYWORDS, os_stat__doc__}
-
-static PyObject *
-os_stat_impl(PyObject *self, path_t path, int dir_fd, int follow_symlinks);
-
-static PyObject *
-os_stat(PyObject *self, PyObject *args, PyObject *kwargs)
-{
-    PyObject *_return_value;
-    path_t path = PATH_T_INITIALIZE("stat", 0, 1);
-    int dir_fd = DEFAULT_DIR_FD;
-    int follow_symlinks = 1;
-    static char *_keywords[] = {"path", "dir_fd", "follow_symlinks", NULL};
-
-    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
-        "O&|$O&p:stat", _keywords,
-        path_converter, &path, OS_STAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks))
-        return NULL;
-
-    _return_value = os_stat_impl(self, path, dir_fd, follow_symlinks);
-    path_cleanup(&path);
-    return _return_value;
-}
-
-
-
-PyDoc_STRVAR(os_access__doc__,
-"os.access(path, mode, *[, dir_fd=None[, effective_ids=False[, follow_symlinks=True]]])\n"
-"\n"
-"Use the real uid/gid to test for access to a path.\n"
-"Returns True if granted, False otherwise.\n"
-"\n"
-"path\n"
-"    Path to be tested; can be string, bytes, or open-file-descriptor int.\n"
-"\n"
-"mode\n"
-"    Operating-system mode bitfield.  Can be F_OK to test existence,\n"
-"    or the inclusive-OR of R_OK, W_OK, and X_OK.\n"
-"\n"
-"dir_fd\n"
-"    If not None, it should be a file descriptor open to a directory,\n"
-"    and path should be relative; path will then be relative to that\n"
-"    directory.\n"
-"\n"
-"effective_ids\n"
-"    If True, access will use the effective uid/gid instead of\n"
-"    the real uid/gid.\n"
-"\n"
-"follow_symlinks\n"
-"    If False, and the last element of the path is a symbolic link,\n"
-"    access will examine the symbolic link itself instead of the file\n"
-"    the link points to.\n"
-"\n"
-"dir_fd, effective_ids, and follow_symlinks may not be implemented\n"
-"  on your platform.  If they are unavailable, using them will raise a\n"
-"  NotImplementedError.\n"
-"\n"
-"Note that most operations will use the effective uid/gid, therefore this\n"
-"  routine can be used in a suid/sgid environment to test if the invoking user\n"
-"  has the specified access to the path.\n"
-"\n");
-
-#define OS_ACCESS_METHODDEF    \
-    {"access", (PyCFunction)os_access, METH_VARARGS | METH_KEYWORDS, os_access__doc__}
-
-static PyObject *
-os_access_impl(PyObject *self, path_t path, int mode, int dir_fd, int effective_ids, int follow_symlinks);
-
-static PyObject *
-os_access(PyObject *self, PyObject *args, PyObject *kwargs)
-{
-    PyObject *_return_value;
-    path_t path = PATH_T_INITIALIZE("access", 0, 1);
-    int mode;
-    int dir_fd = DEFAULT_DIR_FD;
-    int effective_ids = 0;
-    int follow_symlinks = 1;
-    static char *_keywords[] = {"path", "mode", "dir_fd", "effective_ids", "follow_symlinks", NULL};
-
-    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
-        "O&i|$O&pp:access", _keywords,
-        path_converter, &path, &mode, OS_ACCESS_DIR_FD_CONVERTER, &dir_fd, &effective_ids, &follow_symlinks))
-        return NULL;
-
-    _return_value = os_access_impl(self, path, mode, dir_fd, effective_ids, follow_symlinks);
-    path_cleanup(&path);
-    return _return_value;
-}
-
-

Modules/zlibmodule.c

 #include "structmember.h"
 #include "zlib.h"
 
+/*[python]
+
+clinic.write_clinic_file()
+
+[python]*/
+
+/*[python end:adc83b19e793491b1c6ea0fd8b46cd9f32e592fc]*/
+
 #ifdef WITH_THREAD
     #include "pythread.h"
     #define ENTER_ZLIB(obj) \
 internal buffers for later processing.
 Call the flush() method to clear these buffers.
 [clinic]*/
-
-PyDoc_STRVAR(zlib_decompress__doc__,
-"zlib.decompress(data[, max_length=0])\n"
-"\n"
-"  data\n"
-"        The binary data to decompress.\n"
-"  max_length\n"
-"        The maximum allowable length of the decompressed data.\n"
-"        Unconsumed input data will be stored in\n"
-"        the unconsumed_tail attribute.\n"
-"\n"
-"Return a string containing the decompressed version of the data.\n"
-"\n"
-"After calling this function, some of the input data may still be stored in\n"
-"internal buffers for later processing.\n"
-"Call the flush() method to clear these buffers.\n");
-
-#define ZLIB_DECOMPRESS_METHODDEF    \
-    {"decompress", (PyCFunction)zlib_decompress, METH_VARARGS | METH_KEYWORDS, zlib_decompress__doc__}
-
-static PyObject *
-zlib_decompress_impl(PyObject *self, Py_buffer data, int max_length);
-
-static PyObject *
-zlib_decompress(PyObject *self, PyObject *args, PyObject *kwargs)
-{
-    Py_buffer data;
-    int max_length = 0;
-    static char *_keywords[] = {"data", "max_length", NULL};
-
-    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
-        "y*|i:decompress", _keywords,
-        &data, &max_length))
-        return NULL;
-
-    return zlib_decompress_impl(self, data, max_length);
-}
-
 static PyObject *
 zlib_decompress_impl(PyObject *self, Py_buffer data, int max_length)
-/*[clinic end:34d5ee75a33ac2c40a8c72f44fdfa5cc13bfd010]*/
+/*[clinic end:6108b2a7cb884537c6169d04456df6dbc527ec8b]*/
 {
     compobject *zself = (compobject *)self;
     int err;
     return PyLong_FromUnsignedLong(signed_val & 0xffffffffU);
 }
 
+/*[python]
+
+clinic.include_clinic_file()
+
+[python]*/
+#include "zlibmodule_clinic.c"
+/*[python end:1ddca76f444ebefd62e7a5445655681098e02362]*/
+
 
 static PyMethodDef zlib_methods[] =
 {

Modules/zlibmodule_clinic.c

+
+PyDoc_STRVAR(zlib_decompress__doc__,
+"zlib.decompress(data[, max_length=0])\n"
+"\n"
+"  data\n"
+"      The binary data to decompress.\n"
+"  max_length\n"
+"      The maximum allowable length of the decompressed data.\n"
+"      Unconsumed input data will be stored in\n"
+"      the unconsumed_tail attribute.\n"
+"\n"
+"Return a string containing the decompressed version of the data.\n"
+"\n"
+"After calling this function, some of the input data may still be stored in\n"
+"internal buffers for later processing.\n"
+"Call the flush() method to clear these buffers.\n");
+
+#define ZLIB_DECOMPRESS_METHODDEF    \
+    {"decompress", (PyCFunction)zlib_decompress, METH_VARARGS | METH_KEYWORDS, zlib_decompress__doc__}
+
+static PyObject *
+zlib_decompress_impl(PyObject *self, Py_buffer data, int max_length);
+
+static PyObject *
+zlib_decompress(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+    PyObject *_return_value;
+    Py_buffer data;
+    int max_length = 0;
+    static char *_keywords[] = {"data", "max_length", NULL};
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+        "y*|i:decompress", _keywords,
+        &data, &max_length))
+        return NULL;
+
+    _return_value = zlib_decompress_impl(self, data, max_length);
+    return _return_value;
+}
+
+
 
 	@property
 	def format_unit(self):
+		if 'converter' in self.flags:
+			return "O&"
+
 		flags = dict(self.flags)
 		if 'types' in flags:
 			types = frozenset(flags['types'].split())
 		return format_unit
 
 
-class CVariable_converter(CVariable):
-
-	format_unit_map = {
-		frozenset() : "O&",
-		}
-
-
 @type_map_register
 class CVariable_PyObject_star(CVariable):
 	"""
 	def __init__(self, c_type, name, flags, line, default=unspecified):
 		self.variables = []
 
-		if 'converter' in flags:
-			type = CVariable_converter
-		else:
-			type = type_map.get(c_type)
+		type = type_map.get(c_type)
 		if not type:
 			sys.exit("Could not create variable of type " + repr(c_type))
 		self.variable = type(name, default)
 	def write_clinic_file(self, filename=None):
 		filename = filename or (self.filename.partition('.c')[0] + "_clinic.c")
 		self.clinic_filename = filename
-		sys.stdout.write("filename " + repr(filename) + "\n")
-		sys.stdout.flush()
 		if os.path.isfile(filename):
 			os.unlink(filename)
 		self.impl_file = open(filename, "wt")
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.