py3: remove dead code to open file with O_CLOEXEC on Python 2
authorManuel Jacob <me@manueljacob.de>
Sun, 29 May 2022 16:24:44 +0200
changeset 49291 1bf3eb65e970
parent 49290 76f56d69a457
child 49292 33872fec41e7
py3: remove dead code to open file with O_CLOEXEC on Python 2 The O_CLOEXEC flag is passed by default on Python 3.
hgext/remotefilelog/basepack.py
--- a/hgext/remotefilelog/basepack.py	Tue May 31 01:16:41 2022 +0200
+++ b/hgext/remotefilelog/basepack.py	Sun May 29 16:24:44 2022 +0200
@@ -13,7 +13,6 @@
 from mercurial.node import hex
 from mercurial import (
     policy,
-    pycompat,
     util,
     vfs as vfsmod,
 )
@@ -54,14 +53,6 @@
 # loaded the pack list.
 REFRESHRATE = 0.1
 
-if pycompat.isposix and not pycompat.ispy3:
-    # With glibc 2.7+ the 'e' flag uses O_CLOEXEC when opening.
-    # The 'e' flag will be ignored on older versions of glibc.
-    # Python 3 can't handle the 'e' flag.
-    PACKOPENMODE = b'rbe'
-else:
-    PACKOPENMODE = b'rb'
-
 
 class _cachebackedpacks:
     def __init__(self, packs, cachesize):
@@ -343,12 +334,12 @@
             self._data.close()
 
         # TODO: use an opener/vfs to access these paths
-        with open(self.indexpath, PACKOPENMODE) as indexfp:
+        with open(self.indexpath, b'rb') as indexfp:
             # memory-map the file, size 0 means whole file
             self._index = mmap.mmap(
                 indexfp.fileno(), 0, access=mmap.ACCESS_READ
             )
-        with open(self.packpath, PACKOPENMODE) as datafp:
+        with open(self.packpath, b'rb') as datafp:
             self._data = mmap.mmap(datafp.fileno(), 0, access=mmap.ACCESS_READ)
 
         self._pagedin = 0