10000 bpo-44347: [doc] clarify meaning of shutil.copytree's dirs_exist_ok kwarg by jdevries3133 · Pull Request #26643 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-44347: [doc] clarify meaning of shutil.copytree's dirs_exist_ok kwarg #26643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 70 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
74727b9
bpo-44347: [doc] clarify meaning of shutil.copytree's dirs_exist_ok …
jdevries3133 Jun 9, 2021
0fa96d1
bpo-44347: [doc] clarify shutil.copytree dirs_exist_ok kwarg
jdevries3133 Jun 10, 2021
318a99c
Merge branch 'main' of github.com:python/cpython into bpo-44347
jdevries3133 Jun 10, 2021
9b262b8
bpo-44347: [doc|fix]: add NEWS.d entry, remove use of default context
jdevries3133 Jun 10, 2021
952dbf1
Merge branch 'main' of github.com:python/cpython into bpo-44347
jdevries3133 Jun 10, 2021
e365e52
bpo-44347: [doc] better document argument shutil.copytree(dirs_exist_…
jdevries3133 Jun 11, 2021
eb3ee6f
Merge branch 'main' of github.com:python/cpython into bpo-44347
jdevries3133 Jun 11, 2021
d340c87
bpo-44347: [doc|fix]: add missed updated docstring from previous commit
jdevries3133 Jun 11, 2021
dd2f5c3
bpo-44381: Windows build now allows enabling control flow guard (GH-2…
zooba Jun 11, 2021
d8837d8
bpo-40128: Fix IDLE autocomplete on macOS (GH-26672)
thsubaku9 Jun 11, 2021
869f2fa
bpo-44339: Fix math.pow corner case to comply with IEEE 754 (GH-26606)
mdickinson Jun 12, 2021
29584b7
bpo-43475: Fix the Python implementation of hash of Decimal NaN (GH-2…
serhiy-storchaka Jun 12, 2021
b63a793
Add more const modifiers. (GH-26691)
serhiy-storchaka Jun 12, 2021
feca673
bpo-44376 - reduce pow() overhead for small exponents (GH-26662)
tim-one Jun 12, 2021
b1e8a39
bpo-44396: Update multi-line-start location when reallocating tokeniz…
pablogsal Jun 12, 2021
732ecab
bpo-44389: Remove duplicate SSL_OP_NO_TLSv1_2 flag (GH-26680)
Jun 12, 2021
2a93215
bpo-43425: Update test_c_parser not to use TempdirManager (GH-26693)
corona10 Jun 12, 2021
50aee65
Fix typos in multiple files (GH-26689)
enjoy-binbin Jun 13, 2021
6966890
Fix a potential reference-counting bug in long_pow (GH-26690)
mdickinson Jun 13, 2021
d1a2233
bpo-44389: Fix deprecation of OP_NO_TLSv1_3 (GH-26700)
tiran Jun 13, 2021
67d241b
bpo-44310: Note that lru_cache keep references to both arguments and…
rhettinger Jun 14, 2021
0208b06
bpo-44338: Port LOAD_GLOBAL to PEP 659 adaptive interpreter (GH-26638)
markshannon Jun 14, 2021
ad667a2
Remove accidentally duplicated STAT_INC (GH-26718)
markshannon Jun 14, 2021
6109bfa
bpo-38291: Remove mention of typing.io and typing.re again (GH-26113)
srittau Jun 14, 2021
101dc7e
Fix typo in lnotab_notes.txt (GH-26711)
P403n1x87 Jun 14, 2021
ed3d0b5
bpo-44409: Fix error location in tokenizer errors that happen during …
pablogsal Jun 14, 2021
44d2ad8
Fix a typo in _make_class_unpicklable() docstring (GH-26729)
akulakov Jun 15, 2021
77b67cb
Add extra stats for attribute misses (GH-26732)
markshannon Jun 15, 2021
1628fb8
bpo-42064: Move sqlite3 types to global state (GH-26537)
Jun 15, 2021
c60a9c6
bpo-42972: _thread.RLock implements the GH protocol (GH-26734)
vstinner Jun 15, 2021
1d63579
bpo-44422: Fix threading.enumerate() reentrant call (GH-26727)
vstinner Jun 15, 2021
3e45844
[Enum] improve test, add andrei kulakov to ACKS (GH-26726)
ethanfurman Jun 15, 2021
3e2e824
bpo-43475: Add what's new entry for NaN hash changes (GH-26725)
mdickinson Jun 15, 2021
fc3ca19
bpo-43693: Eliminate unused "fast locals". (gh-26587)
ericsnowcurrently Jun 15, 2021
949a2b7
bpo-44342: [Enum] sync current docs to 3.10 (GH-26750)
ethanfurman Jun 16, 2021
b7f3aca
bpo-43795: Don't list private names in the limited API (GH-26740)
encukou Jun 16, 2021
8fc6dd3
bpo-44422: threading.Thread reuses the _delete() method (GH-26741)
vstinner Jun 16, 2021
66eab7a
bpo-38211: Clean up type_init() (GH-16257)
sir-sigurd Jun 16, 2021
e78f506
bpo-44392: Add Py_GenericAlias to C API docs (GH-26724)
Fidget-Spinner Jun 16, 2021
66c976d
bpo-44426: Use of 'complex' as a C variable name confuses Sphinx; cha…
mdickinson Jun 16, 2021
439482a
bpo-44389: Fix typo in ssl deprecation warning message (GH-26754)
j178 Jun 17, 2021
76bed3a
bpo-43908: Make heap types converted during 3.10 alpha immutable (GH-…
Jun 17, 2021
f446866
Do not clear globals or builtins when calling clear() on a frame obje…
markshannon Jun 17, 2021
3010391
bpo-43024: improve signature (in help, etc) for functions taking sent…
iritkatriel Jun 17, 2021
6e231c0
bpo-44310: Add a FAQ entry for caching method calls (GH-26731)
rhettinger Jun 17, 2021
9ad9fd7
bpo-44032: Move pointer to code object from frame-object to frame spe…
markshannon Jun 18, 2021
95aa9d6
Reorganize the pattern matching suite (GH-26661)
brandtbucher Jun 18, 2021
d808829
bpo-44451: Reset DeprecationWarning filters in test_importlib.test_en…
hroncok Jun 18, 2021
f3dd96a
bpo-43945: [Enum] reduce scope of new format() behavior (GH-26752)
ethanfurman Jun 18, 2021
d4b87bc
Add a note about NameError/AttributeError suggestions with custom err…
pablogsal Jun 18, 2021
32fd669
Remove dubious suggestion (GH-26789)
rhettinger Jun 19, 2021
df719d4
bpo-38820: Test with OpenSSL 3.0.0-beta1 (GH-26769)
tiran Jun 19, 2021
0cf3409
bpo-43298: Improved error message when building without the Windows S…
zooba Jun 19, 2021
07f631d
bpo-44426: Fix use of the C keyword 'default' as a variable name (GH-…
mdickinson Jun 19, 2021
f879593
Merge remote-tracking branch 'upstream/main' into pr_26643
terryjreedy Jun 19, 2021
d035783
commit suggested change from @terryjreedy
jdevries3133 Jun 20, 2021
a1f767c
commit suggested change from @terryjreedy
jdevries3133 Jun 20, 2021
7151b46
commit suggested change from @terryjreedy
jdevries3133 Jun 20, 2021
a0a46be
commit suggested change from @terryjreedy
jdevries3133 Jun 20, 2021
e02e998
bpo-38291: DeprecationWarning when importing typing.{io,re} (#26719)
srittau Jun 19, 2021
82ae9d6
bpo-44347: fix spelling
jdevries3133 Jun 20, 2021
568c773
Merge remote-tracking branch 'upstream/main' into pr_26643
terryjreedy Jun 20, 2021
b2d7cc0
bpo-44347: add note to further clarify edge case
jdevries3133 Jun 21, 2021
a07b324
bpo-44347: (small fix) remove redundant line from example
jdevries3133 Jun 21, 2021
48f30ee
bpo-44347: highlight relationship to os.makedirs
jdevries3133 Jun 21, 2021
5b8366a
small rewording fix
jdevries3133 Jul 1, 2021
60a0eb6
Merge branch 'main' of github.com:python/cpython into bpo-44347
jdevries3133 Apr 8, 2022
8303dc5
revise old changes
jdevries3133 Apr 8, 2022
c169b1d
apply @JelleZijlstra's feedback
jdevries3133 Apr 9, 2022
ac3f837
update docstring
jdevries3133 Apr 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
bpo-42064: Move sqlite3 types to global state (GH-26537)
* Move connection type to global state
* Move cursor type to global state
* Move prepare protocol type to global state
* Move row type to global state
* Move statement type to global state
* ADD_TYPE takes a pointer
* pysqlite_get_state is now static inline
  • Loading branch information
Erlend Egeberg Aasland authored and jdevries3133 committed Jun 19, 2021
commit 1628fb8251cbf5df5aed0b68c41d0ff7cb3f6a71
6 changes: 3 additions & 3 deletions Modules/_sqlite/clinic/connection.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Modules/_sqlite/clinic/cursor.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Modules/_sqlite/clinic/module.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Modules/_sqlite/clinic/row.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 14 additions & 10 deletions Modules/_sqlite/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@
#define HAVE_TRACE_V2
#endif

#define clinic_state() (pysqlite_get_state(NULL))
#include "clinic/connection.c.h"
#undef clinic_state

/*[clinic input]
module _sqlite3
class _sqlite3.Connection "pysqlite_Connection *" "pysqlite_ConnectionType"
class _sqlite3.Connection "pysqlite_Connection *" "clinic_state()->ConnectionType"
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=aa796073bd8f69db]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=67369db2faf80891]*/

_Py_IDENTIFIER(cursor);

Expand Down Expand Up @@ -339,14 +342,15 @@ pysqlite_connection_cursor_impl(pysqlite_Connection *self, PyObject *factory)
return NULL;
}

pysqlite_state *state = pysqlite_get_state(NULL);
if (factory == NULL) {
factory = (PyObject*)pysqlite_CursorType;
factory = (PyObject *)state->CursorType;
}

cursor = PyObject_CallOneArg(factory, (PyObject *)self);
if (cursor == NULL)
return NULL;
if (!PyObject_TypeCheck(cursor, pysqlite_CursorType)) {
if (!PyObject_TypeCheck(cursor, state->CursorType)) {
PyErr_Format(PyExc_TypeError,
"factory must return a cursor, not %.100s",
Py_TYPE(cursor)->tp_name);
Expand Down Expand Up @@ -1592,7 +1596,7 @@ pysqlite_connection_iterdump_impl(pysqlite_Connection *self)
/*[clinic input]
_sqlite3.Connection.backup as pysqlite_connection_backup

target: object(type='pysqlite_Connection *', subclass_of='pysqlite_ConnectionType')
target: object(type='pysqlite_Connection *', subclass_of='clinic_state()->ConnectionType')
*
pages: int = -1
progress: object = None
Expand All @@ -1607,7 +1611,7 @@ pysqlite_connection_backup_impl(pysqlite_Connection *self,
pysqlite_Connection *target, int pages,
PyObject *progress, const char *name,
double sleep)
/*[clinic end generated code: output=306a3e6a38c36334 input=30ae45fc420bfd3b]*/
/*[clinic end generated code: output=306a3e6a38c36334 input=c759627ab1ad46ff]*/
{
int rc;
int sleep_ms = (int)(sleep * 1000.0);
Expand Down Expand Up @@ -1914,14 +1918,14 @@ static PyType_Spec connection_spec = {
.slots = connection_slots,
};

PyTypeObject *pysqlite_ConnectionType = NULL;

int
pysqlite_connection_setup_types(PyObject *module)
{
pysqlite_ConnectionType = (PyTypeObject *)PyType_FromModuleAndSpec(module, &connection_spec, NULL);
if (pysqlite_ConnectionType == NULL) {
PyO 6DB6 bject *type = PyType_FromModuleAndSpec(module, &connection_spec, NULL);
if (type == NULL) {
return -1;
}
pysqlite_state *state = pysqlite_get_state(module);
state->ConnectionType = (PyTypeObject *)type;
return 0;
}
19 changes: 11 additions & 8 deletions Modules/_sqlite/cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,31 @@
#include "cursor.h"
#include "module.h"
#include "util.h"

#define clinic_state() (pysqlite_get_state(NULL))
#include "clinic/cursor.c.h"
#undef clinic_state

/*[clinic input]
module _sqlite3
class _sqlite3.Cursor "pysqlite_Cursor *" "pysqlite_CursorType"
class _sqlite3.Cursor "pysqlite_Cursor *" "clinic_state()->CursorType"
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=b2072d8db95411d5]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=3c5b8115c5cf30f1]*/

static const char errmsg_fetch_across_rollback[] = "Cursor needed to be reset because of commit/rollback and can no longer be fetched from.";

/*[clinic input]
_sqlite3.Cursor.__init__ as pysqlite_cursor_init

connection: object(type='pysqlite_Connection *', subclass_of='pysqlite_ConnectionType')
connection: object(type='pysqlite_Connection *', subclass_of='clinic_state()->ConnectionType')
/

[clinic start generated code]*/

static int
pysqlite_cursor_init_impl(pysqlite_Cursor *self,
pysqlite_Connection *connection)
/*[clinic end generated code: output=ac59dce49a809ca8 input=a8a4f75ac90999b2]*/
/*[clinic end generated code: output=ac59dce49a809ca8 input=23d4265b534989fb]*/
{
Py_INCREF(connection);
Py_XSETREF(self->connection, connection);
Expand Down Expand Up @@ -1079,14 +1082,14 @@ static PyType_Spec cursor_spec = {
.slots = cursor_slots,
};

PyTypeObject *pysqlite_CursorType = NULL;

int
pysqlite_cursor_setup_types(PyObject *module)
{
pysqlite_CursorType = (PyTypeObject *)PyType_FromModuleAndSpec(module, &cursor_spec, NULL);
if (pysqlite_CursorType == NULL) {
PyObject *type = PyType_FromModuleAndSpec(module, &cursor_spec, NULL);
if (type == NULL) {
return -1;
}
pysqlite_state *state = pysqlite_get_state(module);
state->CursorType = (PyTypeObject *)type;
return 0;
}
6 changes: 3 additions & 3 deletions Modules/_sqlite/microprotocols.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ pysqlite_microprotocols_add(PyTypeObject *type, PyObject *proto, PyObject *cast)
PyObject* key;
int rc;

if (proto == NULL) proto = (PyObject*)pysqlite_PrepareProtocolType;

assert(type != NULL);
assert(proto != NULL);
key = Py_BuildValue("(OO)", (PyObject*)type, proto);
if (!key) {
return -1;
Expand All @@ -81,7 +81,7 @@ pysqlite_microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt)
PyObject *adapter, *key, *adapted;

/* we don't check for exact type conformance as specified in PEP 246
because the pysqlite_PrepareProtocolType type is abstract and there is no
because the PrepareProtocolType type is abstract and there is no
way to get a quotable object to be its instance */

/* look for an adapter in the registry */
Expand Down
34 changes: 18 additions & 16 deletions Modules/_sqlite/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
#error "SQLite 3.7.15 or higher required"
#endif

#define clinic_state() (pysqlite_get_state(NULL))
#include "clinic/module.c.h"
#undef clinic_state

/*[clinic input]
module _sqlite3
[clinic start generated code]*/
Expand All @@ -57,12 +60,6 @@ int pysqlite_BaseTypeAdapted = 0;

pysqlite_state pysqlite_global_state;

pysqlite_state *
pysqlite_get_state(PyObject *Py_UNUSED(module))
{
return &pysqlite_global_state;
}

static PyObject* module_connect(PyObject* self, PyObject* args, PyObject*
kwargs)
{
Expand Down Expand Up @@ -93,7 +90,8 @@ static PyObject* module_connect(PyObject* self, PyObject* args, PyObject*
}

if (factory == NULL) {
factory = (PyObject*)pysqlite_ConnectionType;
pysqlite_state *state = pysqlite_get_state(self);
factory = (PyObject *)state->ConnectionType;
}

return PyObject_Call(factory, args, kwargs);
Expand Down Expand Up @@ -176,9 +174,12 @@ pysqlite_register_adapter_impl(PyObject *module, PyTypeObject *type,
pysqlite_BaseTypeAdapted = 1;
}

rc = pysqlite_microprotocols_add(type, (PyObject*)pysqlite_PrepareProtocolType, caster);
if (rc == -1)
pysqlite_state *state = pysqlite_get_state(NULL);
PyObject *protocol = (PyObject *)state->PrepareProtocolType;
rc = pysqlite_microprotocols_add(type, protocol, caster);
if (rc == -1) {
return NULL;
}

Py_RETURN_NONE;
}
Expand Down Expand Up @@ -240,7 +241,7 @@ pysqlite_enable_callback_trace_impl(PyObject *module, int enable)
_sqlite3.adapt as pysqlite_adapt

obj: object
proto: object(c_default='(PyObject*)pysqlite_PrepareProtocolType') = PrepareProtocolType
proto: object(c_default='(PyObject *)clinic_state()->PrepareProtocolType') = PrepareProtocolType
alt: object = NULL
/

Expand All @@ -250,7 +251,7 @@ Adapt given object to given protocol. Non-standard.
static PyObject *
pysqlite_adapt_impl(PyObject *module, PyObject *obj, PyObject *proto,
PyObject *alt)
/*[clinic end generated code: output=0c3927c5fcd23dd9 input=a58ab77fb5ae22dd]*/
/*[clinic end generated code: output=0c3927c5fcd23dd9 input=c8995aeb25d0e542]*/
{
return pysqlite_microprotocols_adapt(obj, proto, alt);
}
Expand Down Expand Up @@ -358,7 +359,7 @@ static struct PyModuleDef _sqlite3module = {

#define ADD_TYPE(module, type) \
do { \
if (PyModule_AddType(module, &type) < 0) { \
if (PyModule_AddType(module, type) < 0) { \
goto error; \
} \
} while (0)
Expand Down Expand Up @@ -392,6 +393,7 @@ PyMODINIT_FUNC PyInit__sqlite3(void)
}

module = PyModule_Create(&_sqlite3module);
pysqlite_state *state = pysqlite_get_state(module);

if (!module ||
(pysqlite_row_setup_types(module) < 0) ||
Expand All @@ -403,10 +405,10 @@ PyMODINIT_FUNC PyInit__sqlite3(void)
goto error;
}

ADD_TYPE(module, *pysqlite_ConnectionType);
ADD_TYPE(module, *pysqlite_CursorType);
ADD_TYPE(module, *pysqlite_PrepareProtocolType);
ADD_TYPE(module, *pysqlite_RowType);
ADD_TYPE(module, state->ConnectionType);
ADD_TYPE(module, state->CursorType);
ADD_TYPE(module, state->PrepareProtocolType);
ADD_TYPE(module, state->RowType);

/*** Create DB-API Exception hierarchy */
ADD_EXCEPTION(module, "Error", pysqlite_Error, PyExc_Exception);
Expand Down
13 changes: 12 additions & 1 deletion Modules/_sqlite/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,20 @@

typedef struct {
PyObject *lru_cache;
PyTypeObject *ConnectionType;
PyTypeObject *CursorType;
PyTypeObject *PrepareProtocolType;
PyTypeObject *RowType;
PyTypeObject *StatementType;
} pysqlite_state;

extern pysqlite_state *pysqlite_get_state(PyObject *module);
extern pysqlite_state pysqlite_global_state;

static inline pysqlite_state *
pysqlite_get_state(PyObject *Py_UNUSED(module))
{
return &pysqlite_global_state;
}

extern PyObject* pysqlite_Error;
extern PyObject* pysqlite_Warning;
Expand Down
8 changes: 4 additions & 4 deletions Modules/_sqlite/prepare_protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ static PyType_Spec type_spec = {
.slots = type_slots,
};

PyTypeObject *pysqlite_PrepareProtocolType = NULL;

int
pysqlite_prepare_protocol_setup_types(PyObject *module)
{
pysqlite_PrepareProtocolType = (PyTypeObject *)PyType_FromModuleAndSpec(module, &type_spec, NULL);
if (pysqlite_PrepareProtocolType == NULL) {
PyObject *type = PyType_FromModuleAndSpec(module, &type_spec, NULL);
if (type == NULL) {
return -1;
}
pysqlite_state *state = pysqlite_get_state(module);
state->PrepareProtocolType = (PyTypeObject *)type;
return 0;
}
Loading
0