Mercurial > cpython-lru_cache-weakref
view Modules/_cryptmodule.c @ 73323:dad02a080bbc
Improve byte-compilation in packaging to be independent of -O or -B.
The code I fixed to comply with PEP 3147 still had one bug: When run
under python -O, some paths for pyc files would be pyo, because I called
imp.cache_from_source without explicit debug_override argument in some
places, and under -O that would return .pyo (this is well explained in
the imp docs). Now all code (util.byte_compile, build_py, install_lib)
can create .pyo files according to options given by users,
without interference from the calling Python’s own optimize mode.
On a related topic, I also removed the code that prevented byte
compilation under python -B. The rationale is that packaging gives
control over the creation of pyc files to the user with its own explicit
option, and the behavior should not be changed if the calling Python
happens to run with -B for whatever reason. I will argue that this is a
bug fix and ask to be allowed to backport this change to distutils.
Finally, I moved one nugget of information about the --compile and
--optimize options from the source into the doc. It clears up a
misunderstanding that I (and maybe other people) had.
| author | Éric Araujo <merwok@netwok.org> |
|---|---|
| date | Thu, 03 Nov 2011 05:08:28 +0100 |
| parents | 372b2ef0ff37 |
| children |
line wrap: on
line source
/* cryptmodule.c - by Steve Majewski */ #include "Python.h" #include <sys/types.h> #ifdef __VMS #include <openssl/des.h> #endif /* Module crypt */ static PyObject *crypt_crypt(PyObject *self, PyObject *args) { char *word, *salt; #ifndef __VMS extern char * crypt(const char *, const char *); #endif if (!PyArg_ParseTuple(args, "ss:crypt", &word, &salt)) { return NULL; } /* On some platforms (AtheOS) crypt returns NULL for an invalid salt. Return None in that case. XXX Maybe raise an exception? */ return Py_BuildValue("s", crypt(word, salt)); } PyDoc_STRVAR(crypt_crypt__doc__, "crypt(word, salt) -> string\n\ word will usually be a user's password. salt is a 2-character string\n\ which will be used to select one of 4096 variations of DES. The characters\n\ in salt must be either \".\", \"/\", or an alphanumeric character. Returns\n\ the hashed password as a string, which will be composed of characters from\n\ the same alphabet as the salt."); static PyMethodDef crypt_methods[] = { {"crypt", crypt_crypt, METH_VARARGS, crypt_crypt__doc__}, {NULL, NULL} /* sentinel */ }; static struct PyModuleDef cryptmodule = { PyModuleDef_HEAD_INIT, "_crypt", NULL, -1, crypt_methods, NULL, NULL, NULL, NULL }; PyMODINIT_FUNC PyInit__crypt(void) { return PyModule_Create(&cryptmodule); }
