Skip to content

pkgutil.iter_modules() error: 'PosixPath' object has no attribute 'startswith' #107

@mtreviso

Description

@mtreviso

Describe the bug
pkgutil.iter_modules breaks if a Path is passed instead of a str on some versions of python. This is due to a regression in Python. See the original issue report here: https://bugs.python.org/issue44061

To Reproduce
Try:

from pathlib import Path
from pkgutil import iter_modules
package_dir = Path('.')
iter_modules([package_dir])

>> AttributeError: 'PosixPath' object has no attribute 'startswith'

Environment (please complete the following information):

  • OS: Ubuntu 20.04.2 LTS
  • OpenKiwi version: 2.1.0
  • Python version: 3.8.10

Additional context
A simple fix is to convert Path to str:

iter_modules([str(package_dir)])

File where the error occurs: kiwi/systems/__init__.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions