summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_pickle.c26
-rw-r--r--Modules/_sre.c16
-rw-r--r--Modules/timemodule.c18
3 files changed, 52 insertions, 8 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 2dc3a4116d..9410e528b6 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -2812,6 +2812,24 @@ save_global(PicklerObject *self, PyObject *obj, PyObject *name)
}
static int
+save_ellipsis(PicklerObject *self, PyObject *obj)
+{
+ PyObject *str = PyUnicode_FromString("Ellipsis");
+ if (str == NULL)
+ return -1;
+ return save_global(self, Py_Ellipsis, str);
+}
+
+static int
+save_notimplemented(PicklerObject *self, PyObject *obj)
+{
+ PyObject *str = PyUnicode_FromString("NotImplemented");
+ if (str == NULL)
+ return -1;
+ return save_global(self, Py_NotImplemented, str);
+}
+
+static int
save_pers(PicklerObject *self, PyObject *obj, PyObject *func)
{
PyObject *pid = NULL;
@@ -3114,6 +3132,14 @@ save(PicklerObject *self, PyObject *obj, int pers_save)
status = save_none(self, obj);
goto done;
}
+ else if (obj == Py_Ellipsis) {
+ status = save_ellipsis(self, obj);
+ goto done;
+ }
+ else if (obj == Py_NotImplemented) {
+ status = save_notimplemented(self, obj);
+ goto done;
+ }
else if (obj == Py_False || obj == Py_True) {
status = save_bool(self, obj);
goto done;
diff --git a/Modules/_sre.c b/Modules/_sre.c
index 92544808d3..cb1f791242 100644
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -1596,7 +1596,7 @@ SRE_SEARCH(SRE_STATE* state, SRE_CODE* pattern)
/* see sre.h for object declarations */
static PyObject*pattern_new_match(PatternObject*, SRE_STATE*, int);
-static PyObject*pattern_scanner(PatternObject*, PyObject*);
+static PyObject*pattern_scanner(PatternObject*, PyObject*, PyObject* kw);
static int
sre_literal_template(int charsize, char* ptr, Py_ssize_t len)
@@ -2132,13 +2132,13 @@ error:
#if PY_VERSION_HEX >= 0x02020000
static PyObject*
-pattern_finditer(PatternObject* pattern, PyObject* args)
+pattern_finditer(PatternObject* pattern, PyObject* args, PyObject* kw)
{
PyObject* scanner;
PyObject* search;
PyObject* iterator;
- scanner = pattern_scanner(pattern, args);
+ scanner = pattern_scanner(pattern, args, kw);
if (!scanner)
return NULL;
@@ -2576,10 +2576,10 @@ static PyMethodDef pattern_methods[] = {
{"findall", (PyCFunction) pattern_findall, METH_VARARGS|METH_KEYWORDS,
pattern_findall_doc},
#if PY_VERSION_HEX >= 0x02020000
- {"finditer", (PyCFunction) pattern_finditer, METH_VARARGS,
+ {"finditer", (PyCFunction) pattern_finditer, METH_VARARGS|METH_KEYWORDS,
pattern_finditer_doc},
#endif
- {"scanner", (PyCFunction) pattern_scanner, METH_VARARGS},
+ {"scanner", (PyCFunction) pattern_scanner, METH_VARARGS|METH_KEYWORDS},
{"__copy__", (PyCFunction) pattern_copy, METH_NOARGS},
{"__deepcopy__", (PyCFunction) pattern_deepcopy, METH_O},
{NULL, NULL}
@@ -3822,7 +3822,7 @@ static PyTypeObject Scanner_Type = {
};
static PyObject*
-pattern_scanner(PatternObject* pattern, PyObject* args)
+pattern_scanner(PatternObject* pattern, PyObject* args, PyObject* kw)
{
/* create search state object */
@@ -3831,7 +3831,9 @@ pattern_scanner(PatternObject* pattern, PyObject* args)
PyObject* string;
Py_ssize_t start = 0;
Py_ssize_t end = PY_SSIZE_T_MAX;
- if (!PyArg_ParseTuple(args, "O|nn:scanner", &string, &start, &end))
+ static char* kwlist[] = { "source", "pos", "endpos", NULL };
+ if (!PyArg_ParseTupleAndKeywords(args, kw, "O|nn:scanner", kwlist,
+ &string, &start, &end))
return NULL;
/* create scanner object */
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 59fe3eef03..6ebd3efc97 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -40,6 +40,10 @@
#include <sys/time.h>
#endif
+#if defined(__APPLE__)
+#include <mach/mach_time.h>
+#endif
+
/* Forward declarations */
static int floatsleep(double);
static double floattime(void);
@@ -816,7 +820,8 @@ of the returned value is undefined so only the difference of consecutive\n\
calls is valid.");
#if (defined(MS_WINDOWS) && !defined(__BORLANDC__)) \
- || (defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC))
+ || (defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)) \
+ || (defined(__APPLE__))
# define HAVE_PYTIME_MONOTONIC
#endif
@@ -826,6 +831,17 @@ time_monotonic(PyObject *self, PyObject *unused)
{
#if defined(MS_WINDOWS) && !defined(__BORLANDC__)
return win32_clock(0);
+#elif defined(__APPLE__)
+ uint64_t time = mach_absolute_time();
+ double secs;
+
+ static mach_timebase_info_data_t timebase;
+ if (timebase.denom == 0)
+ mach_timebase_info(&timebase);
+
+ secs = (double)time * timebase.numer / timebase.denom * 1e-9;
+
+ return PyFloat_FromDouble(secs);
#else
static int clk_index = 0;
clockid_t clk_ids[] = {