The recent revendoring of pywatchman undid this changeset.
Let's reapply it.
This commit was generated by running hg graft -f b1f62cd39b5c.
It applied cleanly.
hg-reviewers |
The recent revendoring of pywatchman undid this changeset.
Let's reapply it.
This commit was generated by running hg graft -f b1f62cd39b5c.
It applied cleanly.
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | hgext/fsmonitor/pywatchman/bser.c (33 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
0da15732527c | e1386f0cc8ac | Gregory Szorc | Nov 2 2019, 3:54 PM |
PyObject_Del(o); | PyObject_Del(o); | ||||
} | } | ||||
static PyObject* bserobj_getattrro(PyObject* o, PyObject* name) { | static PyObject* bserobj_getattrro(PyObject* o, PyObject* name) { | ||||
bserObject* obj = (bserObject*)o; | bserObject* obj = (bserObject*)o; | ||||
Py_ssize_t i, n; | Py_ssize_t i, n; | ||||
PyObject* name_bytes = NULL; | PyObject* name_bytes = NULL; | ||||
PyObject* ret = NULL; | PyObject* ret = NULL; | ||||
const char* namestr; | const char* namestr = NULL; | ||||
if (PyIndex_Check(name)) { | if (PyIndex_Check(name)) { | ||||
i = PyNumber_AsSsize_t(name, PyExc_IndexError); | i = PyNumber_AsSsize_t(name, PyExc_IndexError); | ||||
if (i == -1 && PyErr_Occurred()) { | if (i == -1 && PyErr_Occurred()) { | ||||
goto bail; | goto bail; | ||||
} | } | ||||
if (i == 8 && PySequence_Size(obj->values) < 9) { | |||||
// Hack alert: Python 3 removed support for os.stat().st_mtime | |||||
// being an integer.Instead, if you need an integer, you have to | |||||
// use os.stat()[stat.ST_MTIME] instead. stat.ST_MTIME is 8, and | |||||
// our stat tuples are shorter than that, so we can detect | |||||
// requests for index 8 on tuples shorter than that and return | |||||
// st_mtime instead. | |||||
namestr = "st_mtime"; | |||||
} else { | |||||
ret = PySequence_GetItem(obj->values, i); | ret = PySequence_GetItem(obj->values, i); | ||||
goto bail; | goto bail; | ||||
} | } | ||||
} else { | |||||
// We can be passed in Unicode objects here -- we don't support anything other | // We can be passed in Unicode objects here -- we don't support anything other | ||||
// than UTF-8 for keys. | // than UTF-8 for keys. | ||||
if (PyUnicode_Check(name)) { | if (PyUnicode_Check(name)) { | ||||
name_bytes = PyUnicode_AsUTF8String(name); | name_bytes = PyUnicode_AsUTF8String(name); | ||||
if (name_bytes == NULL) { | if (name_bytes == NULL) { | ||||
goto bail; | goto bail; | ||||
} | } | ||||
namestr = PyBytes_AsString(name_bytes); | namestr = PyBytes_AsString(name_bytes); | ||||
} else { | } else { | ||||
namestr = PyBytes_AsString(name); | namestr = PyBytes_AsString(name); | ||||
} | } | ||||
} | |||||
if (namestr == NULL) { | if (namestr == NULL) { | ||||
goto bail; | goto bail; | ||||
} | } | ||||
// hack^Wfeature to allow mercurial to use "st_size" to reference "size" | // hack^Wfeature to allow mercurial to use "st_size" to reference "size" | ||||
if (!strncmp(namestr, "st_", 3)) { | if (!strncmp(namestr, "st_", 3)) { | ||||
namestr += 3; | namestr += 3; | ||||
} | } |