Unbabel / OpenKiwi

Open-Source Machine Translation Quality Estimation in PyTorch
https://unbabel.github.io/OpenKiwi/
GNU Affero General Public License v3.0
229 stars 48 forks source link

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

Open mtreviso opened 3 years ago

mtreviso commented 3 years ago

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):

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