Patchwork D11763: cext: define S_IFLNK on Python 2.7 and Windows

login
register
mail settings
Submitter phabricator
Date Nov. 16, 2021, 3:54 a.m.
Message ID <differential-rev-PHID-DREV-xkxugovl6n42fowqqhjn-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50088/
State Superseded
Headers show

Comments

phabricator - Nov. 16, 2021, 3:54 a.m.
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Before this change, building on Python 2.7 on Windows fails due to
  S_IFLNK being undefined. This regression was introduced by
  a32a96079e2d <https://phab.mercurial-scm.org/rHGa32a96079e2d48005e7a1c23b208d729ff96768b> / D11518 <https://phab.mercurial-scm.org/D11518>.
  
  It worked on Python 3 because its pyport.h (which is included via
  Python.h) contains effectively the same code as added by this
  changeset.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/cext/parsers.c

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c
--- a/mercurial/cext/parsers.c
+++ b/mercurial/cext/parsers.c
@@ -25,6 +25,12 @@ 
 #define PyInt_FromLong PyLong_FromLong
 #define PyInt_FromSsize_t PyLong_FromSsize_t
 #define PyInt_AsLong PyLong_AsLong
+#else
+/* Windows on Python 2.7 doesn't define S_IFLNK. Python 3+ defines via
+ * pyport.h. */
+#ifndef S_IFLNK
+#define S_IFLNK 0120000
+#endif
 #endif
 
 static const char *const versionerrortext = "Python minor version mismatch";