ejwa/gitinspector

`TypeError: 'bool' object is not iterable` after npm install

ybnd opened this issue ยท 18 comments

ybnd commented

Hi,

I can't get gitinspector to run from the npmpackage; after a clean install it crashes with

$ gitinspector -h
Traceback (most recent call last):
  File "/home/ybnd/.npm/node_modules/bin/gitinspector", line 21, in <module>
    from gitinspector import gitinspector
  File "/home/ybnd/.npm/node_modules/lib/node_modules/gitinspector/gitinspector/gitinspector.py", line 26, in <module>
    from .blame import Blame
  File "/home/ybnd/.npm/node_modules/lib/node_modules/gitinspector/gitinspector/blame.py", line 28, in <module>
    from .changes import FileDiff
  File "/home/ybnd/.npm/node_modules/lib/node_modules/gitinspector/gitinspector/changes.py", line 29, in <module>
    from . import extensions, filtering, format, interval, terminal
  File "/home/ybnd/.npm/node_modules/lib/node_modules/gitinspector/gitinspector/format.py", line 28, in <module>
    from . import basedir, localization, terminal, version
  File "/home/ybnd/.npm/node_modules/lib/node_modules/gitinspector/gitinspector/version.py", line 23, in <module>
    localization.init()
  File "/home/ybnd/.npm/node_modules/lib/node_modules/gitinspector/gitinspector/localization.py", line 71, in init
    __translation__.install(True)
  File "/usr/lib/python3.8/gettext.py", line 352, in install
    for name in allowed & set(names):
TypeError: 'bool' object is not iterable

Environment:

  • 5.8.0-2-Manjaro
  • Python 3.8.5
  • npm 6.14.4
ybnd commented

Right, it's for python2

FeXd commented

This should be re-opoened. gitinspector has supported Python 3 for a long time.

It appears this is a recent break due to Python 3.8.x.

I can run everything fine using Python 3.6.6 but today I upgraded to 3.8.5 and am getting the same error you were.

Traceback (most recent call last):
  File "/Users/arlin/.nvm/versions/node/v12.18.1/bin/gitinspector", line 21, in <module>
    from gitinspector import gitinspector
  File "/Users/arlin/.nvm/versions/node/v12.18.1/lib/node_modules/gitinspector/gitinspector/gitinspector.py", line 26, in <module>
    from .blame import Blame
  File "/Users/arlin/.nvm/versions/node/v12.18.1/lib/node_modules/gitinspector/gitinspector/blame.py", line 28, in <module>
    from .changes import FileDiff
  File "/Users/arlin/.nvm/versions/node/v12.18.1/lib/node_modules/gitinspector/gitinspector/changes.py", line 29, in <module>
    from . import extensions, filtering, format, interval, terminal
  File "/Users/arlin/.nvm/versions/node/v12.18.1/lib/node_modules/gitinspector/gitinspector/format.py", line 28, in <module>
    from . import basedir, localization, terminal, version
  File "/Users/arlin/.nvm/versions/node/v12.18.1/lib/node_modules/gitinspector/gitinspector/version.py", line 23, in <module>
    localization.init()
  File "/Users/arlin/.nvm/versions/node/v12.18.1/lib/node_modules/gitinspector/gitinspector/localization.py", line 71, in init
    __translation__.install(True)
  File "/Users/arlin/.pyenv/versions/3.8.2/lib/python3.8/gettext.py", line 352, in install
    for name in allowed & set(names):
TypeError: 'bool' object is not iterable

Environment:

  • MacOS: 10.15.7
  • Python: 3.8.5
  • npm: 6.14.7

Indeed. It seems to be something in the gettext module that has changed. There is a patch in debian atm for reference that you could try @FeXd.

https://sources.debian.org/patches/gitinspector/0.4.4+dfsg-9/Drop-superfluous-argument-to-NullTranslations.install.patch

Though, unlike the patch, I think install(unicode=True)might be the "right" call here. I'm planing on doing some compatibility testing with different Python versions - so I'll add it to the list.

I too use Python 3.8.5 and was getting the same error as others on this post, tried the old faithful delete and re-installed, get this error. I am not sure if this is or not related to this post but I suspect it's related to the python version.

sudo pip install gitinspector --no-cache-dir

Collecting gitinspector
  Downloading gitinspector-0.3.2.tar.gz (227 kB)
     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 227 kB 332 kB/s 
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-hm1t9cld/gitinspector/setup.py'"'"'; __file__='"'"'/tmp/pip-install-hm1t9cld/gitinspector/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-ntap7ime
         cwd: /tmp/pip-install-hm1t9cld/gitinspector/
    Complete output (16 lines):
    Traceback (most recent call last):
      File "/tmp/pip-install-hm1t9cld/gitinspector/gitinspector/version.py", line 25, in <module>
        localization.init()
    AttributeError: module 'localization' has no attribute 'init'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-hm1t9cld/gitinspector/setup.py", line 22, in <module>
        from gitinspector.version import __version__
      File "/tmp/pip-install-hm1t9cld/gitinspector/gitinspector/version.py", line 27, in <module>
        import gitinspector.localization
      File "/tmp/pip-install-hm1t9cld/gitinspector/gitinspector/localization.py", line 22, in <module>
        import basedir
    ModuleNotFoundError: No module named 'basedir'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

still not fixed?

Not yet @ezhukovskiy . Until its included in a release - temporary fix available in in #216 and the comment above. I need to make sure it works with all versions of the gettext dependency.

Hi,

I am getting the same error running on latest python version '3.9.4' with below 'gitinspector' command. can you please help me with this?

Environment:

windows: 10 Enterprise
Python: 3.9.2
npm: 7.7.6

Logs:

Traceback (most recent call last):
  File "C:\Users\devops_mgr\gitinspector-0.4.4\gitinspector\gitinspector.py", line 25, in <module>
    localization.init()
  File "C:\Users\devops_mgr\gitinspector-0.4.4\gitinspector\localization.py", line 76, in init
    __translation__.install(True)
  File "C:\Users\devops_mgr\AppData\Local\Programs\Python\Python39\lib\gettext.py", line 354, in install
    for name in allowed & set(names):
TypeError: 'bool' object is not iterable ```

Hi @nishanthkumar23, there's a workaround that may work for you while the fix isn't released.

Wow, it's almost a year since this issue was created, and it just happened to me too ๐Ÿ˜ž

abij commented

He, same here! waiting on a proper fix.

Azure DevOps hosted ubuntu agent:

  • Py 3.9.6
  • gitinspector (0.5.0dev) installed with npm

My "fix" inspired by maccuaa and thiagodp

# Note: I have hardcoded the path, this might be different for you.
#
# If this file exists, chain on success with &&...
#     sed -i  means: inline replace (overwrite file)
#         replace .install(True) with .install()

[ -f /usr/local/lib/node_modules/gitinspector/gitinspector/localization.py ] \
          && sed -i s'/.install(True)/.install()/' /usr/local/lib/node_modules/gitinspector/gitinspector/localization.py

Going a step further from abij:

My "fix" inspired by maccuaa and thiagodp

Here's something for Windows 10 using %USERPROFILE% for global install of gitinspector. (works in git bash):

#!/bin/bash
# If this file exists
#     sed -i  means: inline replace (overwrite file)
#         replace .install(True) with .install()

PATCHFILE="${USERPROFILE}/AppData/Roaming/npm/node_modules/gitinspector/gitinspector/localization.py"
POSIX_PATH=`cygpath $PATCHFILE`
if test -f $POSIX_PATH; then
    echo $POSIX_PATH
    sed -i s'/.install(True)/.install()/' $POSIX_PATH
fi

Still happening

Ubuntu 20.04
Python 3.8

Traceback (most recent call last):
  File "/usr/bin/gitinspector", line 11, in <module>
    load_entry_point('gitinspector==0.4.4', 'console_scripts', 'gitinspector')()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 490, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2854, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2445, in load
    return self.resolve()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2451, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3/dist-packages/gitinspector/gitinspector.py", line 25, in <module>
    localization.init()
  File "/usr/lib/python3/dist-packages/gitinspector/localization.py", line 76, in init
    __translation__.install(True)
  File "/usr/lib/python3.8/gettext.py", line 352, in install
    for name in allowed & set(names):
TypeError: 'bool' object is not iterable

Going a step further from abij:

My "fix" inspired by maccuaa and thiagodp

Here's something for Windows 10 using %USERPROFILE% for global install of gitinspector. (works in git bash):

#!/bin/bash
# If this file exists
#     sed -i  means: inline replace (overwrite file)
#         replace .install(True) with .install()

PATCHFILE="${USERPROFILE}/AppData/Roaming/npm/node_modules/gitinspector/gitinspector/localization.py"
POSIX_PATH=`cygpath $PATCHFILE`
if test -f $POSIX_PATH; then
    echo $POSIX_PATH
    sed -i s'/.install(True)/.install()/' $POSIX_PATH
fi

This worked for me Windows 10, Cygwin, Python 3.8.10.

Still happening when using the search making mylar3 unusable.

Python Version : 3.9.7
Docker running on RaspberyPi4 with Dietpi v8_1

500 Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request.

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/cherrypy/_cprequest.py", line 638, in respond
    self._do_respond(path_info)
  File "/usr/lib/python3.9/site-packages/cherrypy/_cprequest.py", line 697, in _do_respond
    response.body = self.handler()
  File "/usr/lib/python3.9/site-packages/cherrypy/lib/encoding.py", line 223, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/cherrypy/_cpdispatch.py", line 54, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/app/mylar3/mylar/webserve.py", line 996, in searchit
    for x in searchresults:
TypeError: 'bool' object is not iterable

still happens even with the patch on localization.py...
Python version 3.9.13
Mac m1 12.4

Still happening (latest ubuntu). However localization fix fixed it.

Other warnings though:
image

fresh install on Windows 11
npm install -g gitinspector
gitinspector

result:

File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1520.0_x64__qbz5n2kfra8p0\Lib\gettext.py", line 312, in install
for name in allowed & set(names):
^^^^^^^^^^
TypeError: 'bool' object is not iterable

Temporary solution

use python 3.7 to run the program :

> pyenv local 3.7.17
> python3 --version
Python 3.7.17
> python3 gitinspector.py