AttributeError: 'bool' object has no attribute 'lower'
noraj opened this issue · comments
Issue
Traceback (most recent call last):
File "/usr/bin/bopscrk.py", line 22, in <module>
Config.setup()
File "/usr/lib/python3.10/site-packages/modules/config.py", line 42, in setup
self.EXTRA_COMBINATIONS = self.parse_booleans(self.read_config('COMBINATIONS', 'extra_combinations'))
File "/usr/lib/python3.10/site-packages/modules/config.py", line 32, in parse_booleans
if value.lower() == 'true':
AttributeError: 'bool' object has no attribute 'lower'
Related code
Line 19 in 715cb41
Line 42 in 715cb41
Lines 31 to 34 in 715cb41
Lines 14 to 21 in 715cb41
Example
test.ini
[TEST]
key=true
It seems at some point the 'true'
string is cast to a True
boolean, but reproducing manually extracting the conf is giving a string and not a bool so I don't know at which level the issue happens.
$ python
Python 3.10.5 (main, Jun 6 2022, 18:49:26) [GCC 12.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import configparser
>>> config = configparser.ConfigParser()
>>> config.sections()
[]
>>> config.read('test.ini')
['test.ini']
>>> config.sections()
['TEST']
>>> config['TEST']['key']
'true'
>>> config.get('TEST', 'key')
'true'
>>> 'true'.lower()
'true'
>>> True.lower()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'bool' object has no attribute 'lower'
By the way you could remove your parse_booleans()
and use the native getboolean() as explained on the documentation https://docs.python.org/3/library/configparser.html#supported-datatypes
Oh I guess it's this change f98cc20 which is responsible.
Here is the content of the BA PKGBUILD
$ pacman -Ql bopscrk
bopscrk /usr/
bopscrk /usr/bin/
bopscrk /usr/bin/bopscrk
bopscrk /usr/bin/bopscrk.py
bopscrk /usr/lib/
bopscrk /usr/lib/python3.10/
bopscrk /usr/lib/python3.10/site-packages/
bopscrk /usr/lib/python3.10/site-packages/bopscrk-2.4.2-py3.10.egg-info/
bopscrk /usr/lib/python3.10/site-packages/bopscrk-2.4.2-py3.10.egg-info/PKG-INFO
bopscrk /usr/lib/python3.10/site-packages/bopscrk-2.4.2-py3.10.egg-info/SOURCES.txt
bopscrk /usr/lib/python3.10/site-packages/bopscrk-2.4.2-py3.10.egg-info/dependency_links.txt
bopscrk /usr/lib/python3.10/site-packages/bopscrk-2.4.2-py3.10.egg-info/entry_points.txt
bopscrk /usr/lib/python3.10/site-packages/bopscrk-2.4.2-py3.10.egg-info/requires.txt
bopscrk /usr/lib/python3.10/site-packages/bopscrk-2.4.2-py3.10.egg-info/top_level.txt
bopscrk /usr/lib/python3.10/site-packages/modules/
bopscrk /usr/lib/python3.10/site-packages/modules/__init__.py
bopscrk /usr/lib/python3.10/site-packages/modules/__pycache__/
bopscrk /usr/lib/python3.10/site-packages/modules/__pycache__/__init__.cpython-310.opt-1.pyc
bopscrk /usr/lib/python3.10/site-packages/modules/__pycache__/__init__.cpython-310.pyc
bopscrk /usr/lib/python3.10/site-packages/modules/__pycache__/args.cpython-310.opt-1.pyc
bopscrk /usr/lib/python3.10/site-packages/modules/__pycache__/args.cpython-310.pyc
bopscrk /usr/lib/python3.10/site-packages/modules/__pycache__/auxiliars.cpython-310.opt-1.pyc
bopscrk /usr/lib/python3.10/site-packages/modules/__pycache__/auxiliars.cpython-310.pyc
bopscrk /usr/lib/python3.10/site-packages/modules/__pycache__/banners.cpython-310.opt-1.pyc
bopscrk /usr/lib/python3.10/site-packages/modules/__pycache__/banners.cpython-310.pyc
bopscrk /usr/lib/python3.10/site-packages/modules/__pycache__/color.cpython-310.opt-1.pyc
bopscrk /usr/lib/python3.10/site-packages/modules/__pycache__/color.cpython-310.pyc
bopscrk /usr/lib/python3.10/site-packages/modules/__pycache__/combinators.cpython-310.opt-1.pyc
bopscrk /usr/lib/python3.10/site-packages/modules/__pycache__/combinators.cpython-310.pyc
bopscrk /usr/lib/python3.10/site-packages/modules/__pycache__/config.cpython-310.opt-1.pyc
bopscrk /usr/lib/python3.10/site-packages/modules/__pycache__/config.cpython-310.pyc
bopscrk /usr/lib/python3.10/site-packages/modules/__pycache__/excluders.cpython-310.opt-1.pyc
bopscrk /usr/lib/python3.10/site-packages/modules/__pycache__/excluders.cpython-310.pyc
bopscrk /usr/lib/python3.10/site-packages/modules/__pycache__/main.cpython-310.opt-1.pyc
bopscrk /usr/lib/python3.10/site-packages/modules/__pycache__/main.cpython-310.pyc
bopscrk /usr/lib/python3.10/site-packages/modules/__pycache__/transforms.cpython-310.opt-1.pyc
bopscrk /usr/lib/python3.10/site-packages/modules/__pycache__/transforms.cpython-310.pyc
bopscrk /usr/lib/python3.10/site-packages/modules/args.py
bopscrk /usr/lib/python3.10/site-packages/modules/auxiliars.py
bopscrk /usr/lib/python3.10/site-packages/modules/banners.py
bopscrk /usr/lib/python3.10/site-packages/modules/color.py
bopscrk /usr/lib/python3.10/site-packages/modules/combinators.py
bopscrk /usr/lib/python3.10/site-packages/modules/config.py
bopscrk /usr/lib/python3.10/site-packages/modules/excluders.py
bopscrk /usr/lib/python3.10/site-packages/modules/main.py
bopscrk /usr/lib/python3.10/site-packages/modules/transforms.py
bopscrk /usr/lib/python3.10/site-packages/tests/
bopscrk /usr/lib/python3.10/site-packages/tests/__init__.py
bopscrk /usr/lib/python3.10/site-packages/tests/__pycache__/
bopscrk /usr/lib/python3.10/site-packages/tests/__pycache__/__init__.cpython-310.opt-1.pyc
bopscrk /usr/lib/python3.10/site-packages/tests/__pycache__/__init__.cpython-310.pyc
bopscrk /usr/lib/python3.10/site-packages/tests/__pycache__/combinators_tests.cpython-310.opt-1.pyc
bopscrk /usr/lib/python3.10/site-packages/tests/__pycache__/combinators_tests.cpython-310.pyc
bopscrk /usr/lib/python3.10/site-packages/tests/__pycache__/excluders_tests.cpython-310.opt-1.pyc
bopscrk /usr/lib/python3.10/site-packages/tests/__pycache__/excluders_tests.cpython-310.pyc
bopscrk /usr/lib/python3.10/site-packages/tests/__pycache__/transforms_tests.cpython-310.opt-1.pyc
bopscrk /usr/lib/python3.10/site-packages/tests/__pycache__/transforms_tests.cpython-310.pyc
bopscrk /usr/lib/python3.10/site-packages/tests/combinators_tests.py
bopscrk /usr/lib/python3.10/site-packages/tests/excluders_tests.py
bopscrk /usr/lib/python3.10/site-packages/tests/transforms_tests.py
which is just running
build() {
cd $pkgname
python setup.py build
}
package() {
cd "$pkgname"
python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build
}
so it should be similar to the content of the python package.
- it's putting stuff in
/usr/lib/python3.10/site-packages/modules/
while it shouldn't, - it should deploy in
/usr/lib/python3.10/site-packages/bopscrk/
but it isn't - it's packaging some pycache
.pyc
while it shouldn't - it's packaging test while it shouldn't
- and concerning this issue, it's not packaging
bopscrk.cfg
Those issue are due to :
- the usage of
find_packages()
that tries to automatically detect which file should be included or not, cf. https://setuptools.pypa.io/en/latest/userguide/package_discovery.html#finding-simple-packages, but it's better to do it manually to avoid including irrelevant stuff and forgetting important stuff - that the folder where is stored you code is named
modules
instead ofbopscrk
So the issue described above is because as bopscrk.cfg
is not contained in the package so when 'COMBINATIONS', 'extra_combinations'
is parsed from the non-existing config file, the extracted value is None and None.lower() can't be.
But anyway nowaday setup.py is deprecated and the proper way is to use pyproject.toml
cf. https://pip.pypa.io/en/stable/reference/build-system/pyproject-toml/
I started PoCing around #19
I have just released a new version that should fixes this bugs, it is also available on pypi to install via pip, can you double check before I close the issue? By now, all my tests goes well:
I am able to download it from pypi and run it with the default configuration file (which is being included now in the same directory where the package is installed => ~/.local/lib/python3.10/site-packages/bopscrk/
), I can also specify a custom configuration file by absolute or relative path to the user's current working directory (which is the expected behavior, instead of script working directory).
There are no more traces of compiled files or test modules (only the __pycache__
generated directories, as far as I know this is normal).
It's working now and the config file is included