# Buggy code
def _after_create_parent_question(self, force_overwrite, remember_directory):
    """After asking about parent directory.

    Args:
        force_overwrite: Force overwriting existing files.
        remember_directory: If True, remember the directory for future
                            downloads.
    """
    global last_used_directory

    try:
        os.makedirs(os.path.dirname(self._filename))
    except FileExistsError:
        pass
    except OSError as e:
        self._die(e.strerror)

    self.basename = os.path.basename(self._filename)
    if remember_directory:
        last_used_directory = os.path.dirname(self._filename)

    log.downloads.debug("Setting filename to {}".format(self._filename))
    if force_overwrite:
        self._after_set_filename()
    elif os.path.isfile(self._filename):
        # The file already exists, so ask the user if it should be
        # overwritten.
        txt = "<b>{}</b> already exists. Overwrite?".format(html.escape(self._filename))
        self._ask_confirm_question("Overwrite existing file?", txt)
    # FIFO, device node, etc. Make sure we want to do this
    elif os.path.exists(self._filename) and not os.path.isdir(self._filename):
        txt = (
            "<b>{}</b> already exists and is a special file. Write to "
            "it anyways?".format(html.escape(self._filename))
        )
        self._ask_confirm_question("Overwrite special file?", txt)
    else:
        self._after_set_filename()


# Traceback (PermissionError)
15:48:51 DEBUG    downloads  qtnetworkdownloads:fetch:489 fetch: PyQt5.QtCore.QUrl('https://en.wikipedia.org/wiki/Canadian_National_Vimy_Memorial') -> Canadian_National_Vimy_Memorial
15:48:51 DEBUG    downloads  downloads:_on_begin_insert_row:825 _on_begin_insert_row with idx 0, webengine False
15:48:51 DEBUG    misc       standarddir:_writable_location:143 writable location for DownloadLocation: D:/
15:48:51 ERROR    misc       crashsignal:exception_hook:205 Uncaught exception
Traceback (most recent call last):
File "scripts/dev\..\..\scripts\..\qutebrowser\app.py", line 875, in eventFilter
File "scripts/dev\..\..\scripts\..\qutebrowser\app.py", line 835, in _handle_key_event
File "scripts/dev\..\..\scripts\..\qutebrowser\keyinput\modeman.py", line 337, in eventFilter
File "scripts/dev\..\..\scripts\..\qutebrowser\keyinput\modeman.py", line 168, in _eventFilter_keypress
File "scripts/dev\..\..\scripts\..\qutebrowser\keyinput\basekeyparser.py", line 311, in handle
File "scripts/dev\..\..\scripts\..\qutebrowser\keyinput\modeparsers.py", line 75, in _handle_single_key
File "scripts/dev\..\..\scripts\..\qutebrowser\keyinput\basekeyparser.py", line 200, in _handle_single_key
File "scripts/dev\..\..\scripts\..\qutebrowser\keyinput\keyparser.py", line 44, in execute
File "scripts/dev\..\..\scripts\..\qutebrowser\commands\runners.py", line 274, in run
File "scripts/dev\..\..\scripts\..\qutebrowser\commands\command.py", line 525, in run
File "scripts/dev\..\..\scripts\..\qutebrowser\browser\commands.py", line 1360, in download
File "scripts/dev\..\..\scripts\..\qutebrowser\browser\qtnetworkdownloads.py", line 386, in get
File "scripts/dev\..\..\scripts\..\qutebrowser\browser\qtnetworkdownloads.py", line 451, in get_request
File "scripts/dev\..\..\scripts\..\qutebrowser\browser\qtnetworkdownloads.py", line 467, in _fetch_request
File "scripts/dev\..\..\scripts\..\qutebrowser\browser\qtnetworkdownloads.py", line 509, in fetch
File "scripts/dev\..\..\scripts\..\qutebrowser\browser\downloads.py", line 160, in get_filename_question
File "scripts/dev\..\..\scripts\..\qutebrowser\browser\downloads.py", line 108, in _path_suggestion
File "scripts/dev\..\..\scripts\..\qutebrowser\browser\downloads.py", line 76, in download_dir
File "scripts/dev\..\..\scripts\..\qutebrowser\utils\standarddir.py", line 101, in download
File "scripts/dev\..\..\scripts\..\qutebrowser\utils\standarddir.py", line 193, in _create
File "c:\Python\64-bit\3.4\lib\os.py", line 237, in makedirs
PermissionError: [WinError 5] Access is denied: 'D:\\'

# Fixed code
def _after_create_parent_question(self, force_overwrite, remember_directory):
    """After asking about parent directory.

    Args:
        force_overwrite: Force overwriting existing files.
        remember_directory: If True, remember the directory for future
                            downloads.
    """
    global last_used_directory

    try:
        os.makedirs(os.path.dirname(self._filename), exist_ok=True)
    except OSError as e:
        self._die(e.strerror)

    self.basename = os.path.basename(self._filename)
    if remember_directory:
        last_used_directory = os.path.dirname(self._filename)

    log.downloads.debug("Setting filename to {}".format(self._filename))
    if force_overwrite:
        self._after_set_filename()
    elif os.path.isfile(self._filename):
        # The file already exists, so ask the user if it should be
        # overwritten.
        txt = "<b>{}</b> already exists. Overwrite?".format(html.escape(self._filename))
        self._ask_confirm_question("Overwrite existing file?", txt)
    # FIFO, device node, etc. Make sure we want to do this
    elif os.path.exists(self._filename) and not os.path.isdir(self._filename):
        txt = (
            "<b>{}</b> already exists and is a special file. Write to "
            "it anyways?".format(html.escape(self._filename))
        )
        self._ask_confirm_question("Overwrite special file?", txt)
    else:
        self._after_set_filename()