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

TypeError expected string or bytes-like object #4

Open
ignacionf opened this issue Feb 15, 2024 · 0 comments
Open

TypeError expected string or bytes-like object #4

ignacionf opened this issue Feb 15, 2024 · 0 comments

Comments

@ignacionf
Copy link

Hello. I am using your library to detect mobile devices but every now and then I get the following error:

Traceback (most recent call last):
  File "/opt/app/*************/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
  File "/opt/app/*************/venv/lib/python3.8/site-packages/sentry_sdk/integrations/django/middleware.py", line 176, in __call__
    return f(*args, **kwargs)
  File "/opt/app/*************/venv/lib/python3.8/site-packages/mobiledetect/middleware.py", line 10, in __call__
    self.process_request(request)
  File "/opt/app/*************/venv/lib/python3.8/site-packages/mobiledetect/middleware.py", line 17, in process_request
    request.device['is_mobile'] = detector.is_mobile()
  File "/opt/app/*************/venv/lib/python3.8/site-packages/mobiledetect/detection.py", line 46, in is_mobile
    return self.match_detection_rules()
  File "/opt/app/*************/venv/lib/python3.8/site-packages/mobiledetect/detection.py", line 105, in match_detection_rules
    if self.match(_regex, user_agent):
  File "/opt/app/*************/venv/lib/python3.8/site-packages/mobiledetect/detection.py", line 128, in match
    matches = re.findall(re.compile(match), user_agents if user_agents else self.user_agent.name)
  File "/usr/lib/python3.8/re.py", line 241, in findall
    return _compile(pattern, flags).findall(string)
TypeError: expected string or bytes-like object

pattern=re.compile('\x08iPhone\x08|\x08iPod\x08')
flags=0
string=None

$ pip freeze | grep mobile
django-mobile-detect==0.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant