Skip to content

Commit 8df697e

Browse files
Add more examples.
1 parent 2c2ec36 commit 8df697e

File tree

3 files changed

+8
-17
lines changed

3 files changed

+8
-17
lines changed

Modules/_interpretersmodule.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,14 +1245,11 @@ interp_get_config(PyObject *self, PyObject *args, PyObject *kwds)
12451245
PyObject *idobj = NULL;
12461246
int restricted = 0;
12471247
if (!PyArg_ParseTupleAndKeywords(args, kwds,
1248-
"O|$p:get_config", kwlist,
1248+
"O?|$p:get_config", kwlist,
12491249
&idobj, &restricted))
12501250
{
12511251
return NULL;
12521252
}
1253-
if (idobj == Py_None) {
1254-
idobj = NULL;
1255-
}
12561253

12571254
int reqready = 0;
12581255
PyInterpreterState *interp = \
@@ -1369,14 +1366,14 @@ capture_exception(PyObject *self, PyObject *args, PyObject *kwds)
13691366
static char *kwlist[] = {"exc", NULL};
13701367
PyObject *exc_arg = NULL;
13711368
if (!PyArg_ParseTupleAndKeywords(args, kwds,
1372-
"|O:capture_exception", kwlist,
1369+
"|O?:capture_exception", kwlist,
13731370
&exc_arg))
13741371
{
13751372
return NULL;
13761373
}
13771374

13781375
PyObject *exc = exc_arg;
1379-
if (exc == NULL || exc == Py_None) {
1376+
if (exc == NULL) {
13801377
exc = PyErr_GetRaisedException();
13811378
if (exc == NULL) {
13821379
Py_RETURN_NONE;

Modules/_threadmodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,12 +641,12 @@ PyThreadHandleObject_join(PyObject *op, PyObject *args)
641641
PyThreadHandleObject *self = (PyThreadHandleObject*)op;
642642

643643
PyObject *timeout_obj = NULL;
644-
if (!PyArg_ParseTuple(args, "|O:join", &timeout_obj)) {
644+
if (!PyArg_ParseTuple(args, "|O?:join", &timeout_obj)) {
645645
return NULL;
646646
}
647647

648648
PyTime_t timeout_ns = -1;
649-
if (timeout_obj != NULL && timeout_obj != Py_None) {
649+
if (timeout_obj != NULL) {
650650
if (_PyTime_FromSecondsObject(&timeout_ns, timeout_obj,
651651
_PyTime_ROUND_TIMEOUT) < 0) {
652652
return NULL;

Modules/mmapmodule.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,7 +1689,7 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
16891689
DWORD off_lo; /* lower 32 bits of offset */
16901690
DWORD size_hi; /* upper 32 bits of size */
16911691
DWORD size_lo; /* lower 32 bits of size */
1692-
PyObject *tagname = Py_None;
1692+
PyObject *tagname = NULL;
16931693
DWORD dwErr = 0;
16941694
int fileno;
16951695
HANDLE fh = 0;
@@ -1699,7 +1699,7 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
16991699
"tagname",
17001700
"access", "offset", NULL };
17011701

1702-
if (!PyArg_ParseTupleAndKeywords(args, kwdict, "in|OiL", keywords,
1702+
if (!PyArg_ParseTupleAndKeywords(args, kwdict, "in|U?iL", keywords,
17031703
&fileno, &map_size,
17041704
&tagname, &access, &offset)) {
17051705
return NULL;
@@ -1832,13 +1832,7 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
18321832
m_obj->weakreflist = NULL;
18331833
m_obj->exports = 0;
18341834
/* set the tag name */
1835-
if (!Py_IsNone(tagname)) {
1836-
if (!PyUnicode_Check(tagname)) {
1837-
Py_DECREF(m_obj);
1838-
return PyErr_Format(PyExc_TypeError, "expected str or None for "
1839-
"'tagname', not %.200s",
1840-
Py_TYPE(tagname)->tp_name);
1841-
}
1835+
if (tagname != NULL) {
18421836
m_obj->tagname = PyUnicode_AsWideCharString(tagname, NULL);
18431837
if (m_obj->tagname == NULL) {
18441838
Py_DECREF(m_obj);

0 commit comments

Comments
 (0)