Submitter | phabricator |
---|---|
Date | Nov. 2, 2019, 10:04 p.m. |
Message ID | <differential-rev-PHID-DREV-v3ruihtib6mgxdql3iez-req@mercurial-scm.org> |
Download | mbox | patch |
Permalink | /patch/42694/ |
State | Superseded |
Headers | show |
Comments
durin42 added inline comments. INLINE COMMENTS > bser.c:182 > +#else > + PyObject* utf = PyUnicode_AsEncodedString(sval, "utf-8", "ignore"); > + if (utf == NULL) { By reading this code, I believe `sval` should have been `key`, so I've fixed that in flight. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7210/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7210 To: indygreg, #hg-reviewers Cc: durin42, mercurial-devel
Patch
diff --git a/hgext/fsmonitor/pywatchman/bser.c b/hgext/fsmonitor/pywatchman/bser.c --- a/hgext/fsmonitor/pywatchman/bser.c +++ b/hgext/fsmonitor/pywatchman/bser.c @@ -175,7 +175,15 @@ const char* item_name = NULL; PyObject* key = PyTuple_GET_ITEM(obj->keys, i); + // tuple keys should always be str. +#if PY_MAJOR_VERSION >= 3 + item_name = PyUnicode_AsUTF8(key); +#else item_name = PyBytes_AsString(key); +#endif + if (item_name == NULL) { + goto bail; + } if (!strcmp(item_name, namestr)) { ret = PySequence_GetItem(obj->values, i); goto bail;