Skip to content

TypeError: expected str, bytes or os.PathLike object, not NoneType #219

Description

@natehardison

I use browser_cookie3 in one of my projects, and a user reported this crash to me on Python 3.12 on Ubuntu 24.04 using browser_cookie3==0.20.1:

 File ".../lib/python3.12/site-packages/browser_cookie3/__init__.py", line 445, in __init__
    self.__add_key_and_cookie_file(**kwargs)
  File ".../python3.12/site-packages/browser_cookie3/__init__.py", line 472, in __add_key_and_cookie_file
    cookie_file = self.cookie_file or _expand_paths(
                                      ^^^^^^^^^^^^^^
  File ".../lib/python3.12/site-packages/browser_cookie3/__init__.py", line 153, in _expand_paths
    return next(_expand_paths_impl(paths, os_name), None)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../lib/python3.12/site-packages/browser_cookie3/__init__.py", line 144, in _expand_paths_impl
    for path in paths:
  File "<frozen posixpath>", line 259, in expanduser
TypeError: expected str, bytes or os.PathLike object, not NoneType

I haven't gone through the motions of reproducing this, but from reading the code, I think the issue could be that the Arc class doesn't define linux_cookies like the other ChromiumBased subclasses do: https://github.com/borisbabic/browser_cookie3/blob/master/browser_cookie3/__init__.py#L695. Therefore linux_cookies=None gets passed to the _expand_paths(linux_cookies, 'linux') function call on https://github.com/borisbabic/browser_cookie3/blob/master/browser_cookie3/__init__.py#L473.

In my code, I'm just calling browser_cookie3.load(domain_name) instead of specifying a browser.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions