Skip to content

Version 2022.5.18 incompatible with Python 3.5: AttributeError: module 'os' has no attribute 'PathLike' #195

@Edward-Knight

Description

@Edward-Knight

The type hinting added in the latest version isn't compatible with Python 3.5, triggering: AttributeError: module 'os' has no attribute 'PathLike'.

Reproduction in an Ubuntu Xenial Docker container:

$ apt update
$ apt install -y python3-pip
$ pip3 install --upgrade "pip<21"  # latest version of pip compatible with 3.5
$ pip3 install certifi==2022.5.18
$ python3 --version
Python 3.5.2
$ python3 -c "import certifi"
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/certifi/core.py", line 14, in <module>
    from importlib.resources import path as get_path, read_text
ImportError: No module named 'importlib.resources'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/certifi/__init__.py", line 1, in <module>
    from .core import contents, where
  File "/usr/local/lib/python3.5/dist-packages/certifi/core.py", line 46, in <module>
    Resource = Union[str, "os.PathLike"]
  File "/usr/lib/python3.5/typing.py", line 552, in __getitem__
    dict(self.__dict__), parameters, _root=True)
  File "/usr/lib/python3.5/typing.py", line 512, in __new__
    for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
  File "/usr/lib/python3.5/typing.py", line 512, in <genexpr>
    for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
  File "/usr/lib/python3.5/typing.py", line 190, in __subclasscheck__
    self._eval_type(globalns, localns)
  File "/usr/lib/python3.5/typing.py", line 177, in _eval_type
    eval(self.__forward_code__, globalns, localns),
  File "<string>", line 1, in <module>
AttributeError: module 'os' has no attribute 'PathLike'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions