Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPRangeList() => TypeError: expected string or bytes-like object, got 'list' #26

Open
iPoetDev opened this issue Aug 15, 2023 · 1 comment
Labels

Comments

@iPoetDev
Copy link

I am optionally using this (to time save a local DHCP address allocation and guess work) and I get this when I run:

django-admin check auth admin as I am configuring the Admin Site for Development & Local environments.

 File "D:\Code\Code Institute\dash-and-do-github\dash_and_do\settings\__init__.py", line 7, 
    in <module> from .development import *
  File "D:\Code\Code Institute\dash-and-do-github\dash_and_do\settings\development.py", line 53, 
    in <module> INTERNAL_IPS = IpRangeList(['127.0.0.1/24', '192.168.0.0/16'])
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Code\Code Institute\dash-and-do-github\venv\Lib\site-packages\iptools\__init__.py", line 414, 
    in __init__ self.ips = tuple(map(IpRange, args))
                    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Code\Code Institute\dash-and-do-github\venv\Lib\site-packages\iptools\__init__.py", line 141, 
     in __init__ elif ipv4.validate_cidr(start):
                     ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Code\Code Institute\dash-and-do-github\venv\Lib\site-packages\iptools\ipv4.py", line 257, 
     in validate_cidr if _CIDR_RE.match(s):
                              ^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'list'
@bd808
Copy link
Owner

bd808 commented Aug 17, 2023

Your INTERNAL_IPS = IpRangeList(['127.0.0.1/24', '192.168.0.0/16']) config line should instead be INTERNAL_IPS = IpRangeList('127.0.0.1/24', '192.168.0.0/16'). See https://python-iptools.readthedocs.io/en/latest/#iptools.IpRangeList for the initializer signature.

There could be a documentation clarity issue here. The docs describe the parameters as *args (list of str and/or tuple) – List of ip addresses or CIDR notation and/or (start, end) tuples of ip addresses. I can imagine how the use of "list" in that description might lead someone to pass a literal list as you have. The *args parameter naming is intended to show that iterable unpacking is being used as the list source for this varadic function.

@bd808 bd808 added the question label Aug 17, 2023
@bd808 bd808 changed the title IPRangleList() => TypeError: expected string or bytes-like object, got 'list' IPRangeList() => TypeError: expected string or bytes-like object, got 'list' Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants