title: python os.makedirs doesn't assign group write permission
body: <p>Here is a list of steps to reproduce this problem:</p>
  
  <pre><code>chaudhary@recsys $ ipython3
  Python 3.5.2 (default, Nov 17 2016, 17:05:23)
  Type 'copyright', 'credits' or 'license' for more information
  IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.
  
  In [1]: !pwd
  /tmp/test
  
  In [2]: !ls -ltr /tmp | grep test
  drwxrwxr-x 2 chaudhary recsys     4096 Jul 20 12:01 test
  
  In [3]: import os
  
  In [4]: os.makedirs('foo/bar/baz', mode=0o775)
  
  In [5]: !tree -pugh
  .
  └── [drwxr-xr-x chaudhary recsys   4.0K]  foo
      └── [drwxr-xr-x chaudhary recsys   4.0K]  bar
          └── [drwxr-xr-x chaudhary recsys   4.0K]  baz
  
  3 directories, 0 files
  </code></pre>
  
  <p>Ideally, all these folders should have group write permission <code>drwxrwxr-x</code>. I know that I can work around this as mentioned in <a href="https://stackoverflow.com/a/45206556/2670370">this question's answer</a>.</p>
  
  <p>I would like to know if there is something I'm missing that might be the reason why group permission is wrong.</p>
  
  <p><strong>UPDATE:</strong> </p>
  
  <p>Test snippet shown above was done on Linux (Ubuntu 16.04). I was able to reproduce this in Mac also.</p>
  
  <pre><code>chaudhary@MacBookProoo $ mkdir /tmp/test; chmod 775 /tmp/test; ls -l /tmp/ | grep test; cd /tmp/test; python3 -c 'import os; os.makedirs("foo/bar/baz", 0o775)'; ls -l /tmp/test; ls -l /tmp/test/foo; ls -l /tmp/test/foo/bar
  
  drwxrwxr-x 2 chaudhary wheel      68 Jul 20 12:22 test
  total 0
  drwxr-xr-x 3 chaudhary wheel 102 Jul 20 12:22 foo
  total 0
  drwxr-xr-x 3 chaudhary wheel 102 Jul 20 12:22 bar
  total 0
  drwxr-xr-x 2 chaudhary wheel 68 Jul 20 12:22 baz
  </code></pre>