Repository: pypa/pipenv

Issue:
TypeError: _mkstemp_inner() takes 4 positional arguments but 5 were given
<details><summary>$ python -m pipenv.help output</summary>

Pipenv version: `'11.10.3'`

Pipenv location: `'/data/dch/.local/lib/python3.4/site-packages/pipenv'`

Python location: `'/usr/bin/python3'`

Other Python installations in `PATH`:

  - `2.7`: `/usr/bin/python2.7`
  - `2.7`: `/usr/bin/python2.7`
  - `3.4`: `/usr/bin/python3.4m`
  - `3.4`: `/usr/bin/python3.4`

  - `2.7.5`: `/usr/bin/python`
  - `2.7.5`: `/usr/bin/python2`
  - `3.4.8`: `/usr/bin/python3`

PEP 508 Information:

```
{'implementation_name': 'cpython',
 'implementation_version': '3.4.8',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '3.10.0-693.21.1.el7.x86_64',
 'platform_system': 'Linux',
 'platform_version': '#1 SMP Wed Mar 7 19:03:37 UTC 2018',
 'python_full_version': '3.4.8',
 'python_version': '3.4',
 'sys_platform': 'linux'}
```

System environment variables:

  - `SELINUX_USE_CURRENT_RANGE`
  - `SSH_TTY`
  - `DISPLAY`
  - `_fzf_orig_completion_tail`
  - `OLDPWD`
  - `QTINC`
  - `_fzf_orig_completion_uniq`
  - `PERL5LIB`
  - `_fzf_orig_completion_gunzip`
  - `TMUX_PANE`
  - `LANG`
  - `_fzf_orig_completion_grep`
  - `_fzf_orig_completion_head`
  - `TERM`
  - `_`
  - `_fzf_orig_completion_diff`
  - `QT_GRAPHICSSYSTEM_CHECKED`
  - `_fzf_orig_completion_vim`
  - `_fzf_orig_completion_ln`
  - `PERL_LOCAL_LIB_ROOT`
  - `HISTSIZE`
  - `ASAN_SYMBOLIZER_PATH`
  - `_fzf_orig_completion_less`
  - `SELINUX_LEVEL_REQUESTED`
  - `SSH_AUTH_SOCK`
  - `SELINUX_ROLE_REQUESTED`
  - `_fzf_orig_completion_telnet`
  - `HOSTNAME`
  - `SHLVL`                                                                                                                                             [18/147]
  - `_fzf_orig_completion_ls`
  - `_fzf_orig_completion_cp`
  - `PATH`
  - `_fzf_orig_completion_unzip`
  - `ASAN_OPTIONS`
  - `_fzf_orig_completion_bunzip2`
  - `LS_COLORS`
  - `PYTHONDONTWRITEBYTECODE`
  - `SHELL`
  - `_fzf_orig_completion_wc`
  - `LOGNAME`
  - `_fzf_orig_completion_sed`
  - `TMUX`
  - `MAIL`
  - `_fzf_orig_completion_vi`
  - `FZF_DEFAULT_COMMAND`
  - `_fzf_orig_completion_view`
  - `PIP_PYTHON_PATH`
  - `_fzf_orig_completion_tee`
  - `PERL_MM_OPT`
  - `HISTCONTROL`
  - `HISTTIMEFORMAT`
  - `HISTFILESIZE`
  - `_fzf_orig_completion_ftp`
  - `_fzf_orig_completion_sort`
  - `JAVA_HOME`
  - `PWD`
  - `HOME`
  - `XDG_SESSION_ID`
  - `XDG_RUNTIME_DIR`
  - `_fzf_orig_completion_mv`
  - `_fzf_orig_completion_cat`
  - `SSH_ASKPASS`
  - `_fzf_orig_completion_emacs`
  - `_fzf_orig_completion_awk`
  - `USER`
  - `PYTHON27`
  - `LESSOPEN`
  - `_fzf_orig_completion_git`
  - `_fzf_orig_completion_rmdir`
  - `_fzf_orig_completion_ld`
  - `_fzf_orig_completion_cd`
  - `QTDIR`
  - `QTLIB`
  - `_fzf_orig_completion_rm`
  - `_fzf_orig_completion_gvim`
  - `PERL_MB_OPT`
  - `SSH_CONNECTION`
  - `_fzf_orig_completion_du`
  - `SSH_CLIENT`

Pipenv–specific environment variables:


Debug–specific environment variables:

  - `PATH`: `/data/dch/perl5/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/puppetlabs/bin:/data/dch/.fzf/bin:/data/dch/.local
/bin:/data/dch/.cargo/bin`
  - `SHELL`: `/bin/bash`
  - `LANG`: `en_GB.utf8`
  - `PWD`: `/data/dch/foo`

---------------------------

Contents of `Pipfile` ('/data/dch/foo/Pipfile'):

```toml
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]

[requires]
python_version = "3.4"

[dev-packages]
```

</details>

------------

##### Expected result

`pipenv update` will update lockfile etc

##### Actual result

Failure with following traceback:

```
$ pipenv update
Running $ pipenv lock then $ pipenv sync.
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Traceback (most recent call last):
  File "/data/dch/.local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/data/dch/.local/lib/python3.4/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/data/dch/.local/lib/python3.4/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/data/dch/.local/lib/python3.4/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/data/dch/.local/lib/python3.4/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/data/dch/.local/lib/python3.4/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/data/dch/.local/lib/python3.4/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/data/dch/.local/lib/python3.4/site-packages/pipenv/cli.py", line 788, in update
    verbose=verbose, clear=clear, pre=pre, keep_outdated=keep_outdated
  File "/data/dch/.local/lib/python3.4/site-packages/pipenv/core.py", line 1168, in do_lock
    project.write_lockfile(lockfile)
  File "/data/dch/.local/lib/python3.4/site-packages/pipenv/project.py", line 644, in write_lockfile
    with atomic_open_for_write(self.lockfile_location, newline=newlines) as f:
  File "/usr/lib64/python3.4/contextlib.py", line 59, in __enter__
    return next(self.gen)
  File "/data/dch/.local/lib/python3.4/site-packages/pipenv/utils.py", line 1333, in atomic_open_for_write
    delete=False,
  File "/data/dch/.local/lib/python3.4/site-packages/pipenv/_compat.py", line 263, in NamedTemporaryFile
    (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags, output_type)
TypeError: _mkstemp_inner() takes 4 positional arguments but 5 were given
```

##### Steps to replicate

Brand new pipenv environment, then `pipenv update`.



Discussion:

Resolving patch:
diff --git a/pipenv/_compat.py b/pipenv/_compat.py
--- a/pipenv/_compat.py
+++ b/pipenv/_compat.py
@@ -8,6 +8,7 @@
 import io
 import os
 import six
+import sys
 import warnings
 from tempfile import _bin_openflags, gettempdir, _mkstemp_inner, mkdtemp
 from .utils import (logging, rmtree)
@@ -257,7 +258,7 @@ def NamedTemporaryFile(
     # the file when it is closed.  This is only supported by Windows.
     if os.name == "nt" and delete:
         flags |= os.O_TEMPORARY
-    if six.PY2:
+    if sys.version_info < (3, 5):
         (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags)
     else:
         (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags, output_type)


Test patch: