durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  It's unclear to me how these `bserobj_tuple` objects are used, other
  than as stat objects. This should fix fsmonitor in the wake of
  https://phab.mercurial-scm.org/rHGffa3026d41964b2d06358c4f21f7e722264d1b3f 
and similar changes.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2939

AFFECTED FILES
  hgext/fsmonitor/pywatchman/bser.c

CHANGE DETAILS

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
@@ -99,6 +99,15 @@
 static PyObject* bserobj_tuple_item(PyObject* o, Py_ssize_t i) {
   bserObject* obj = (bserObject*)o;
 
+  if (i == 8 && PySequence_Size(obj->values) < 7) {
+    // 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.
+    return bserobj_getattrro(o, "st_mtime");
+  }
   return PySequence_GetItem(obj->values, i);
 }
 



To: durin42, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to