diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
index 8321b083a83d4412874529fd1489f67bf37124dc_bWVyY3VyaWFsL3B5Y29tcGF0LnB5..3874ddba1ab47d1ecd41bc37f0c2cce26b370317_bWVyY3VyaWFsL3B5Y29tcGF0LnB5 100644
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -10,6 +10,7 @@
 
 from __future__ import absolute_import
 
+import os
 import sys
 
 ispy3 = (sys.version_info[0] >= 3)
@@ -34,6 +35,5 @@
 if ispy3:
     import builtins
     import functools
-    import os
     fsencode = os.fsencode
     fsdecode = os.fsdecode
@@ -38,5 +38,7 @@
     fsencode = os.fsencode
     fsdecode = os.fsdecode
+    # A bytes version of os.name.
+    osname = os.name.encode('ascii')
 
     def sysstr(s):
         """Return a keyword str to be passed to Python functions such as
@@ -82,6 +84,8 @@
     def fsdecode(filename):
         return filename
 
+    osname = os.name
+
 stringio = io.StringIO
 empty = _queue.Empty
 queue = _queue.Queue