mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Improve Libc by making Python work even better
Actually Portable Python is now outperforming the Python binaries that come bundled with Linux distros, at things like HTTP serving. You can now have a fully featured Python install in just one .com file that runs on six operating systems and is about 10mb in size. With tuning, the tiniest is ~1mb. We've got most of the libraries working, including pysqlite, and the repl now feels very pleasant. The things you can't do quite yet are: threads and shared objects but that can happen in the future, if the community falls in love with this project and wants to see it developed further. Changes: - Add siginterrupt() - Add sqlite3 to Python - Add issymlink() helper - Make GetZipCdir() faster - Add tgamma() and finite() - Add legacy function lutimes() - Add readlink() and realpath() - Use heap allocations when appropriate - Reorganize Python into two-stage build - Save Lua / Python shell history to dotfile - Integrate Python Lib embedding into linkage - Make isregularfile() and isdirectory() go faster - Make Python shell auto-completion work perfectly - Make crash reports work better if changed directory - Fix Python+NT open() / access() flag overflow error - Disable Python tests relating to \N{LONG NAME} syntax - Have Python REPL copyright() show all notice embeddings The biggest technical challenge at the moment is working around when Python tries to be too clever about filenames.
This commit is contained in:
parent
98ccbf44b1
commit
8af197560e
179 changed files with 6728 additions and 10430 deletions
60
third_party/python/Modules/_sqlite/cache.c
vendored
60
third_party/python/Modules/_sqlite/cache.c
vendored
|
@ -1,29 +1,35 @@
|
|||
/* clang-format off */
|
||||
/* cache .c - a LRU cache
|
||||
*
|
||||
* Copyright (C) 2004-2010 Gerhard Häring <gh@ghaering.de>
|
||||
*
|
||||
* This file is part of pysqlite.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ │
|
||||
│ Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de> │
|
||||
│ │
|
||||
│ This file is part of pysqlite. │
|
||||
│ │
|
||||
│ This software is provided 'as-is', without any express or implied │
|
||||
│ warranty. In no event will the authors be held liable for any damages │
|
||||
│ arising from the use of this software. │
|
||||
│ │
|
||||
│ Permission is granted to anyone to use this software for any purpose, │
|
||||
│ including commercial applications, and to alter it and redistribute it │
|
||||
│ freely, subject to the following restrictions: │
|
||||
│ │
|
||||
│ 1. The origin of this software must not be misrepresented; you must not │
|
||||
│ claim that you wrote the original software. If you use this software │
|
||||
│ in a product, an acknowledgment in the product documentation would be │
|
||||
│ appreciated but is not required. │
|
||||
│ 2. Altered source versions must be plainly marked as such, and must not be │
|
||||
│ misrepresented as being the original software. │
|
||||
│ 3. This notice may not be removed or altered from any source distribution. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/python/Modules/_sqlite/cache.h"
|
||||
|
||||
#include "cache.h"
|
||||
#include <limits.h>
|
||||
asm(".ident\t\"\\n\\n\
|
||||
pysqlite (zlib license)\\n\
|
||||
Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de>\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
/* clang-format off */
|
||||
|
||||
/* only used internally */
|
||||
pysqlite_Node* pysqlite_new_node(PyObject* key, PyObject* data)
|
||||
|
@ -258,7 +264,7 @@ static PyMethodDef cache_methods[] = {
|
|||
|
||||
PyTypeObject pysqlite_NodeType = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
MODULE_NAME "Node", /* tp_name */
|
||||
"sqlite3Node", /* tp_name */
|
||||
sizeof(pysqlite_Node), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
(destructor)pysqlite_node_dealloc, /* tp_dealloc */
|
||||
|
@ -300,7 +306,7 @@ PyTypeObject pysqlite_NodeType = {
|
|||
|
||||
PyTypeObject pysqlite_CacheType = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
MODULE_NAME ".Cache", /* tp_name */
|
||||
"sqlite3.Cache", /* tp_name */
|
||||
sizeof(pysqlite_Cache), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
(destructor)pysqlite_cache_dealloc, /* tp_dealloc */
|
||||
|
|
83
third_party/python/Modules/_sqlite/connection.c
vendored
83
third_party/python/Modules/_sqlite/connection.c
vendored
|
@ -1,46 +1,47 @@
|
|||
/* clang-format off */
|
||||
/* connection.c - the connection type
|
||||
*
|
||||
* Copyright (C) 2004-2010 Gerhard Häring <gh@ghaering.de>
|
||||
*
|
||||
* This file is part of pysqlite.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "third_party/python/Modules/_sqlite/cache.h"
|
||||
#include "third_party/python/Modules/_sqlite/module.h"
|
||||
#include "third_party/python/Include/structmember.h"
|
||||
#include "third_party/python/Modules/_sqlite/connection.h"
|
||||
#include "third_party/python/Modules/_sqlite/statement.h"
|
||||
#include "third_party/python/Modules/_sqlite/cursor.h"
|
||||
#include "third_party/python/Modules/_sqlite/prepare_protocol.h"
|
||||
#include "third_party/python/Modules/_sqlite/util.h"
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ │
|
||||
│ Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de> │
|
||||
│ │
|
||||
│ This file is part of pysqlite. │
|
||||
│ │
|
||||
│ This software is provided 'as-is', without any express or implied │
|
||||
│ warranty. In no event will the authors be held liable for any damages │
|
||||
│ arising from the use of this software. │
|
||||
│ │
|
||||
│ Permission is granted to anyone to use this software for any purpose, │
|
||||
│ including commercial applications, and to alter it and redistribute it │
|
||||
│ freely, subject to the following restrictions: │
|
||||
│ │
|
||||
│ 1. The origin of this software must not be misrepresented; you must not │
|
||||
│ claim that you wrote the original software. If you use this software │
|
||||
│ in a product, an acknowledgment in the product documentation would be │
|
||||
│ appreciated but is not required. │
|
||||
│ 2. Altered source versions must be plainly marked as such, and must not be │
|
||||
│ misrepresented as being the original software. │
|
||||
│ 3. This notice may not be removed or altered from any source distribution. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/python/Include/pythread.h"
|
||||
#include "third_party/python/Include/structmember.h"
|
||||
#include "third_party/python/Modules/_sqlite/cache.h"
|
||||
#include "third_party/python/Modules/_sqlite/connection.h"
|
||||
#include "third_party/python/Modules/_sqlite/cursor.h"
|
||||
#include "third_party/python/Modules/_sqlite/module.h"
|
||||
#include "third_party/python/Modules/_sqlite/prepare_protocol.h"
|
||||
#include "third_party/python/Modules/_sqlite/statement.h"
|
||||
#include "third_party/python/Modules/_sqlite/util.h"
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
pysqlite (zlib license)\\n\
|
||||
Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de>\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
/* clang-format off */
|
||||
|
||||
#define ACTION_FINALIZE 1
|
||||
#define ACTION_RESET 2
|
||||
|
||||
#if SQLITE_VERSION_NUMBER >= 3003008
|
||||
#ifndef SQLITE_OMIT_LOAD_EXTENSION
|
||||
#define HAVE_LOAD_EXTENSION
|
||||
#endif
|
||||
#endif
|
||||
|
||||
_Py_IDENTIFIER(cursor);
|
||||
|
||||
static const char * const begin_statements[] = {
|
||||
|
@ -1216,7 +1217,7 @@ PyObject* pysqlite_connection_call(pysqlite_Connection* self, PyObject* args, Py
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (!_PyArg_NoKeywords(MODULE_NAME ".Connection()", kwargs))
|
||||
if (!_PyArg_NoKeywords("sqlite3.Connection()", kwargs))
|
||||
return NULL;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O", &sql))
|
||||
|
@ -1447,7 +1448,7 @@ pysqlite_connection_iterdump(pysqlite_Connection* self, PyObject* args)
|
|||
goto finally;
|
||||
}
|
||||
|
||||
module = PyImport_ImportModule(MODULE_NAME ".dump");
|
||||
module = PyImport_ImportModule("sqlite3.dump");
|
||||
if (!module) {
|
||||
goto finally;
|
||||
}
|
||||
|
@ -1675,7 +1676,7 @@ static struct PyMemberDef connection_members[] =
|
|||
|
||||
PyTypeObject pysqlite_ConnectionType = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
MODULE_NAME ".Connection", /* tp_name */
|
||||
"sqlite3.Connection", /* tp_name */
|
||||
sizeof(pysqlite_Connection), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
(destructor)pysqlite_connection_dealloc, /* tp_dealloc */
|
||||
|
|
61
third_party/python/Modules/_sqlite/cursor.c
vendored
61
third_party/python/Modules/_sqlite/cursor.c
vendored
|
@ -1,30 +1,37 @@
|
|||
/* clang-format off */
|
||||
/* cursor.c - the cursor type
|
||||
*
|
||||
* Copyright (C) 2004-2010 Gerhard Häring <gh@ghaering.de>
|
||||
*
|
||||
* This file is part of pysqlite.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ │
|
||||
│ Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de> │
|
||||
│ │
|
||||
│ This file is part of pysqlite. │
|
||||
│ │
|
||||
│ This software is provided 'as-is', without any express or implied │
|
||||
│ warranty. In no event will the authors be held liable for any damages │
|
||||
│ arising from the use of this software. │
|
||||
│ │
|
||||
│ Permission is granted to anyone to use this software for any purpose, │
|
||||
│ including commercial applications, and to alter it and redistribute it │
|
||||
│ freely, subject to the following restrictions: │
|
||||
│ │
|
||||
│ 1. The origin of this software must not be misrepresented; you must not │
|
||||
│ claim that you wrote the original software. If you use this software │
|
||||
│ in a product, an acknowledgment in the product documentation would be │
|
||||
│ appreciated but is not required. │
|
||||
│ 2. Altered source versions must be plainly marked as such, and must not be │
|
||||
│ misrepresented as being the original software. │
|
||||
│ 3. This notice may not be removed or altered from any source distribution. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/python/Modules/_sqlite/cursor.h"
|
||||
#include "third_party/python/Modules/_sqlite/module.h"
|
||||
#include "third_party/python/Modules/_sqlite/util.h"
|
||||
|
||||
#include "cursor.h"
|
||||
#include "module.h"
|
||||
#include "util.h"
|
||||
asm(".ident\t\"\\n\\n\
|
||||
pysqlite (zlib license)\\n\
|
||||
Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de>\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
/* clang-format off */
|
||||
|
||||
PyObject* pysqlite_cursor_iternext(pysqlite_Cursor* self);
|
||||
|
||||
|
@ -974,7 +981,7 @@ PyDoc_STR("SQLite database cursor class.");
|
|||
|
||||
PyTypeObject pysqlite_CursorType = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
MODULE_NAME ".Cursor", /* tp_name */
|
||||
"sqlite3.Cursor", /* tp_name */
|
||||
sizeof(pysqlite_Cursor), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
(destructor)pysqlite_cursor_dealloc, /* tp_dealloc */
|
||||
|
|
|
@ -1,36 +1,37 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ │
|
||||
│ Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de> │
|
||||
│ │
|
||||
│ This file is part of pysqlite. │
|
||||
│ │
|
||||
│ This software is provided 'as-is', without any express or implied │
|
||||
│ warranty. In no event will the authors be held liable for any damages │
|
||||
│ arising from the use of this software. │
|
||||
│ │
|
||||
│ Permission is granted to anyone to use this software for any purpose, │
|
||||
│ including commercial applications, and to alter it and redistribute it │
|
||||
│ freely, subject to the following restrictions: │
|
||||
│ │
|
||||
│ 1. The origin of this software must not be misrepresented; you must not │
|
||||
│ claim that you wrote the original software. If you use this software │
|
||||
│ in a product, an acknowledgment in the product documentation would be │
|
||||
│ appreciated but is not required. │
|
||||
│ 2. Altered source versions must be plainly marked as such, and must not be │
|
||||
│ misrepresented as being the original software. │
|
||||
│ 3. This notice may not be removed or altered from any source distribution. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/python/Modules/_sqlite/cursor.h"
|
||||
#include "third_party/python/Modules/_sqlite/microprotocols.h"
|
||||
#include "third_party/python/Modules/_sqlite/prepare_protocol.h"
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
pysqlite (zlib license)\\n\
|
||||
Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de>\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
/* clang-format off */
|
||||
/* microprotocols.c - minimalist and non-validating protocols implementation
|
||||
*
|
||||
* Copyright (C) 2003-2004 Federico Di Gregorio <fog@debian.org>
|
||||
*
|
||||
* This file is part of psycopg and was adapted for pysqlite. Federico Di
|
||||
* Gregorio gave the permission to use it within pysqlite under the following
|
||||
* license:
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include <Python.h>
|
||||
#include <structmember.h>
|
||||
|
||||
#include "cursor.h"
|
||||
#include "microprotocols.h"
|
||||
#include "prepare_protocol.h"
|
||||
|
||||
|
||||
/** the adapters registry **/
|
||||
|
||||
|
|
95
third_party/python/Modules/_sqlite/module.c
vendored
95
third_party/python/Modules/_sqlite/module.c
vendored
|
@ -1,38 +1,45 @@
|
|||
/* clang-format off */
|
||||
/* module.c - the module itself
|
||||
*
|
||||
* Copyright (C) 2004-2010 Gerhard Häring <gh@ghaering.de>
|
||||
*
|
||||
* This file is part of pysqlite.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ │
|
||||
│ Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de> │
|
||||
│ │
|
||||
│ This file is part of pysqlite. │
|
||||
│ │
|
||||
│ This software is provided 'as-is', without any express or implied │
|
||||
│ warranty. In no event will the authors be held liable for any damages │
|
||||
│ arising from the use of this software. │
|
||||
│ │
|
||||
│ Permission is granted to anyone to use this software for any purpose, │
|
||||
│ including commercial applications, and to alter it and redistribute it │
|
||||
│ freely, subject to the following restrictions: │
|
||||
│ │
|
||||
│ 1. The origin of this software must not be misrepresented; you must not │
|
||||
│ claim that you wrote the original software. If you use this software │
|
||||
│ in a product, an acknowledgment in the product documentation would be │
|
||||
│ appreciated but is not required. │
|
||||
│ 2. Altered source versions must be plainly marked as such, and must not be │
|
||||
│ misrepresented as being the original software. │
|
||||
│ 3. This notice may not be removed or altered from any source distribution. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/python/Modules/_sqlite/cache.h"
|
||||
#include "third_party/python/Modules/_sqlite/connection.h"
|
||||
#include "statement.h"
|
||||
#include "cursor.h"
|
||||
#include "cache.h"
|
||||
#include "prepare_protocol.h"
|
||||
#include "microprotocols.h"
|
||||
#include "row.h"
|
||||
#include "third_party/python/Modules/_sqlite/cursor.h"
|
||||
#include "third_party/python/Modules/_sqlite/microprotocols.h"
|
||||
#include "third_party/python/Modules/_sqlite/prepare_protocol.h"
|
||||
#include "third_party/python/Modules/_sqlite/row.h"
|
||||
#include "third_party/python/Modules/_sqlite/statement.h"
|
||||
|
||||
#if SQLITE_VERSION_NUMBER >= 3003003
|
||||
#define HAVE_SHARED_CACHE
|
||||
#endif
|
||||
asm(".ident\t\"\\n\\n\
|
||||
pysqlite (zlib license)\\n\
|
||||
Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de>\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
/* clang-format off */
|
||||
|
||||
/* #if SQLITE_VERSION_NUMBER >= 3003003 */
|
||||
/* #define HAVE_SHARED_CACHE */
|
||||
/* #endif */
|
||||
|
||||
/* static objects at module-level */
|
||||
|
||||
|
@ -359,56 +366,56 @@ PyMODINIT_FUNC PyInit__sqlite3(void)
|
|||
|
||||
/*** Create DB-API Exception hierarchy */
|
||||
|
||||
if (!(pysqlite_Error = PyErr_NewException(MODULE_NAME ".Error", PyExc_Exception, NULL))) {
|
||||
if (!(pysqlite_Error = PyErr_NewException("sqlite3.Error", PyExc_Exception, NULL))) {
|
||||
goto error;
|
||||
}
|
||||
PyDict_SetItemString(dict, "Error", pysqlite_Error);
|
||||
|
||||
if (!(pysqlite_Warning = PyErr_NewException(MODULE_NAME ".Warning", PyExc_Exception, NULL))) {
|
||||
if (!(pysqlite_Warning = PyErr_NewException("sqlite3.Warning", PyExc_Exception, NULL))) {
|
||||
goto error;
|
||||
}
|
||||
PyDict_SetItemString(dict, "Warning", pysqlite_Warning);
|
||||
|
||||
/* Error subclasses */
|
||||
|
||||
if (!(pysqlite_InterfaceError = PyErr_NewException(MODULE_NAME ".InterfaceError", pysqlite_Error, NULL))) {
|
||||
if (!(pysqlite_InterfaceError = PyErr_NewException("sqlite3.InterfaceError", pysqlite_Error, NULL))) {
|
||||
goto error;
|
||||
}
|
||||
PyDict_SetItemString(dict, "InterfaceError", pysqlite_InterfaceError);
|
||||
|
||||
if (!(pysqlite_DatabaseError = PyErr_NewException(MODULE_NAME ".DatabaseError", pysqlite_Error, NULL))) {
|
||||
if (!(pysqlite_DatabaseError = PyErr_NewException("sqlite3.DatabaseError", pysqlite_Error, NULL))) {
|
||||
goto error;
|
||||
}
|
||||
PyDict_SetItemString(dict, "DatabaseError", pysqlite_DatabaseError);
|
||||
|
||||
/* pysqlite_DatabaseError subclasses */
|
||||
|
||||
if (!(pysqlite_InternalError = PyErr_NewException(MODULE_NAME ".InternalError", pysqlite_DatabaseError, NULL))) {
|
||||
if (!(pysqlite_InternalError = PyErr_NewException("sqlite3.InternalError", pysqlite_DatabaseError, NULL))) {
|
||||
goto error;
|
||||
}
|
||||
PyDict_SetItemString(dict, "InternalError", pysqlite_InternalError);
|
||||
|
||||
if (!(pysqlite_OperationalError = PyErr_NewException(MODULE_NAME ".OperationalError", pysqlite_DatabaseError, NULL))) {
|
||||
if (!(pysqlite_OperationalError = PyErr_NewException("sqlite3.OperationalError", pysqlite_DatabaseError, NULL))) {
|
||||
goto error;
|
||||
}
|
||||
PyDict_SetItemString(dict, "OperationalError", pysqlite_OperationalError);
|
||||
|
||||
if (!(pysqlite_ProgrammingError = PyErr_NewException(MODULE_NAME ".ProgrammingError", pysqlite_DatabaseError, NULL))) {
|
||||
if (!(pysqlite_ProgrammingError = PyErr_NewException("sqlite3.ProgrammingError", pysqlite_DatabaseError, NULL))) {
|
||||
goto error;
|
||||
}
|
||||
PyDict_SetItemString(dict, "ProgrammingError", pysqlite_ProgrammingError);
|
||||
|
||||
if (!(pysqlite_IntegrityError = PyErr_NewException(MODULE_NAME ".IntegrityError", pysqlite_DatabaseError,NULL))) {
|
||||
if (!(pysqlite_IntegrityError = PyErr_NewException("sqlite3.IntegrityError", pysqlite_DatabaseError,NULL))) {
|
||||
goto error;
|
||||
}
|
||||
PyDict_SetItemString(dict, "IntegrityError", pysqlite_IntegrityError);
|
||||
|
||||
if (!(pysqlite_DataError = PyErr_NewException(MODULE_NAME ".DataError", pysqlite_DatabaseError, NULL))) {
|
||||
if (!(pysqlite_DataError = PyErr_NewException("sqlite3.DataError", pysqlite_DatabaseError, NULL))) {
|
||||
goto error;
|
||||
}
|
||||
PyDict_SetItemString(dict, "DataError", pysqlite_DataError);
|
||||
|
||||
if (!(pysqlite_NotSupportedError = PyErr_NewException(MODULE_NAME ".NotSupportedError", pysqlite_DatabaseError, NULL))) {
|
||||
if (!(pysqlite_NotSupportedError = PyErr_NewException("sqlite3.NotSupportedError", pysqlite_DatabaseError, NULL))) {
|
||||
goto error;
|
||||
}
|
||||
PyDict_SetItemString(dict, "NotSupportedError", pysqlite_NotSupportedError);
|
||||
|
@ -473,7 +480,7 @@ PyMODINIT_FUNC PyInit__sqlite3(void)
|
|||
error:
|
||||
if (PyErr_Occurred())
|
||||
{
|
||||
PyErr_SetString(PyExc_ImportError, MODULE_NAME ": init failed");
|
||||
PyErr_SetString(PyExc_ImportError, "sqlite3: init failed");
|
||||
Py_DECREF(module);
|
||||
module = NULL;
|
||||
}
|
||||
|
|
|
@ -1,28 +1,35 @@
|
|||
/* clang-format off */
|
||||
/* prepare_protocol.c - the protocol for preparing values for SQLite
|
||||
*
|
||||
* Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de>
|
||||
*
|
||||
* This file is part of pysqlite.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ │
|
||||
│ Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de> │
|
||||
│ │
|
||||
│ This file is part of pysqlite. │
|
||||
│ │
|
||||
│ This software is provided 'as-is', without any express or implied │
|
||||
│ warranty. In no event will the authors be held liable for any damages │
|
||||
│ arising from the use of this software. │
|
||||
│ │
|
||||
│ Permission is granted to anyone to use this software for any purpose, │
|
||||
│ including commercial applications, and to alter it and redistribute it │
|
||||
│ freely, subject to the following restrictions: │
|
||||
│ │
|
||||
│ 1. The origin of this software must not be misrepresented; you must not │
|
||||
│ claim that you wrote the original software. If you use this software │
|
||||
│ in a product, an acknowledgment in the product documentation would be │
|
||||
│ appreciated but is not required. │
|
||||
│ 2. Altered source versions must be plainly marked as such, and must not be │
|
||||
│ misrepresented as being the original software. │
|
||||
│ 3. This notice may not be removed or altered from any source distribution. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/python/Modules/_sqlite/prepare_protocol.h"
|
||||
|
||||
#include "prepare_protocol.h"
|
||||
asm(".ident\t\"\\n\\n\
|
||||
pysqlite (zlib license)\\n\
|
||||
Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de>\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
/* clang-format off */
|
||||
|
||||
int pysqlite_prepare_protocol_init(pysqlite_PrepareProtocol* self, PyObject* args, PyObject* kwargs)
|
||||
{
|
||||
|
@ -36,7 +43,7 @@ void pysqlite_prepare_protocol_dealloc(pysqlite_PrepareProtocol* self)
|
|||
|
||||
PyTypeObject pysqlite_PrepareProtocolType= {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
MODULE_NAME ".PrepareProtocol", /* tp_name */
|
||||
"sqlite3.PrepareProtocol", /* tp_name */
|
||||
sizeof(pysqlite_PrepareProtocol), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
(destructor)pysqlite_prepare_protocol_dealloc, /* tp_dealloc */
|
||||
|
|
59
third_party/python/Modules/_sqlite/row.c
vendored
59
third_party/python/Modules/_sqlite/row.c
vendored
|
@ -1,29 +1,36 @@
|
|||
/* clang-format off */
|
||||
/* row.c - an enhanced tuple for database rows
|
||||
*
|
||||
* Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de>
|
||||
*
|
||||
* This file is part of pysqlite.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "third_party/python/Modules/_sqlite/row.h"
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ │
|
||||
│ Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de> │
|
||||
│ │
|
||||
│ This file is part of pysqlite. │
|
||||
│ │
|
||||
│ This software is provided 'as-is', without any express or implied │
|
||||
│ warranty. In no event will the authors be held liable for any damages │
|
||||
│ arising from the use of this software. │
|
||||
│ │
|
||||
│ Permission is granted to anyone to use this software for any purpose, │
|
||||
│ including commercial applications, and to alter it and redistribute it │
|
||||
│ freely, subject to the following restrictions: │
|
||||
│ │
|
||||
│ 1. The origin of this software must not be misrepresented; you must not │
|
||||
│ claim that you wrote the original software. If you use this software │
|
||||
│ in a product, an acknowledgment in the product documentation would be │
|
||||
│ appreciated but is not required. │
|
||||
│ 2. Altered source versions must be plainly marked as such, and must not be │
|
||||
│ misrepresented as being the original software. │
|
||||
│ 3. This notice may not be removed or altered from any source distribution. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/python/Modules/_sqlite/cursor.h"
|
||||
#include "third_party/python/Modules/_sqlite/row.h"
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
pysqlite (zlib license)\\n\
|
||||
Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de>\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
/* clang-format off */
|
||||
|
||||
void pysqlite_row_dealloc(pysqlite_Row* self)
|
||||
{
|
||||
|
@ -233,7 +240,7 @@ static PyMethodDef pysqlite_row_methods[] = {
|
|||
|
||||
PyTypeObject pysqlite_RowType = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
MODULE_NAME ".Row", /* tp_name */
|
||||
"sqlite3.Row", /* tp_name */
|
||||
sizeof(pysqlite_Row), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
(destructor)pysqlite_row_dealloc, /* tp_dealloc */
|
||||
|
|
61
third_party/python/Modules/_sqlite/statement.c
vendored
61
third_party/python/Modules/_sqlite/statement.c
vendored
|
@ -1,34 +1,41 @@
|
|||
/* clang-format off */
|
||||
/* statement.c - the statement type
|
||||
*
|
||||
* Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de>
|
||||
*
|
||||
* This file is part of pysqlite.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "third_party/python/Modules/_sqlite/statement.h"
|
||||
#include "third_party/python/Modules/_sqlite/cursor.h"
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ │
|
||||
│ Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de> │
|
||||
│ │
|
||||
│ This file is part of pysqlite. │
|
||||
│ │
|
||||
│ This software is provided 'as-is', without any express or implied │
|
||||
│ warranty. In no event will the authors be held liable for any damages │
|
||||
│ arising from the use of this software. │
|
||||
│ │
|
||||
│ Permission is granted to anyone to use this software for any purpose, │
|
||||
│ including commercial applications, and to alter it and redistribute it │
|
||||
│ freely, subject to the following restrictions: │
|
||||
│ │
|
||||
│ 1. The origin of this software must not be misrepresented; you must not │
|
||||
│ claim that you wrote the original software. If you use this software │
|
||||
│ in a product, an acknowledgment in the product documentation would be │
|
||||
│ appreciated but is not required. │
|
||||
│ 2. Altered source versions must be plainly marked as such, and must not be │
|
||||
│ misrepresented as being the original software. │
|
||||
│ 3. This notice may not be removed or altered from any source distribution. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/python/Modules/_sqlite/connection.h"
|
||||
#include "third_party/python/Modules/_sqlite/cursor.h"
|
||||
#include "third_party/python/Modules/_sqlite/microprotocols.h"
|
||||
#include "third_party/python/Modules/_sqlite/prepare_protocol.h"
|
||||
#include "third_party/python/Modules/_sqlite/statement.h"
|
||||
#include "third_party/python/Modules/_sqlite/util.h"
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
pysqlite (zlib license)\\n\
|
||||
Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de>\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
/* clang-format off */
|
||||
|
||||
/* prototypes */
|
||||
static int pysqlite_check_remaining_sql(const char* tail);
|
||||
|
||||
|
@ -498,7 +505,7 @@ static int pysqlite_check_remaining_sql(const char* tail)
|
|||
|
||||
PyTypeObject pysqlite_StatementType = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
MODULE_NAME ".Statement", /* tp_name */
|
||||
"sqlite3.Statement", /* tp_name */
|
||||
sizeof(pysqlite_Statement), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
(destructor)pysqlite_statement_dealloc, /* tp_dealloc */
|
||||
|
|
57
third_party/python/Modules/_sqlite/util.c
vendored
57
third_party/python/Modules/_sqlite/util.c
vendored
|
@ -1,29 +1,36 @@
|
|||
/* clang-format off */
|
||||
/* util.c - various utility functions
|
||||
*
|
||||
* Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de>
|
||||
*
|
||||
* This file is part of pysqlite.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ │
|
||||
│ Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de> │
|
||||
│ │
|
||||
│ This file is part of pysqlite. │
|
||||
│ │
|
||||
│ This software is provided 'as-is', without any express or implied │
|
||||
│ warranty. In no event will the authors be held liable for any damages │
|
||||
│ arising from the use of this software. │
|
||||
│ │
|
||||
│ Permission is granted to anyone to use this software for any purpose, │
|
||||
│ including commercial applications, and to alter it and redistribute it │
|
||||
│ freely, subject to the following restrictions: │
|
||||
│ │
|
||||
│ 1. The origin of this software must not be misrepresented; you must not │
|
||||
│ claim that you wrote the original software. If you use this software │
|
||||
│ in a product, an acknowledgment in the product documentation would be │
|
||||
│ appreciated but is not required. │
|
||||
│ 2. Altered source versions must be plainly marked as such, and must not be │
|
||||
│ misrepresented as being the original software. │
|
||||
│ 3. This notice may not be removed or altered from any source distribution. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/python/Modules/_sqlite/connection.h"
|
||||
#include "third_party/python/Modules/_sqlite/module.h"
|
||||
|
||||
#include "module.h"
|
||||
#include "connection.h"
|
||||
asm(".ident\t\"\\n\\n\
|
||||
pysqlite (zlib license)\\n\
|
||||
Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de>\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
/* clang-format off */
|
||||
|
||||
int pysqlite_step(sqlite3_stmt* statement, pysqlite_Connection* connection)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue