question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: expected string or bytes-like object

See original GitHub issue

I’m running my code on a server, and the connection to Amazon works correct when I first boot at the server, but after some requests it fails all the time. If I restart the server it starts working again, but then fails on the same previous situation. I’ve tried changing the IP from the server, to check if my IP was blocked. But that wasn’t the case. I’m not getting a clear error from the API, only an empty object error, so I can’t figure out how to solve the issue.

Here is the error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/amazon/api.py", line 174, in lookup
    response = self.api.ItemLookup(ResponseGroup=ResponseGroup, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/bottlenose/api.py", line 274, in __call__
    {'api_url': api_url, 'cache_url': cache_url})
  File "/usr/local/lib/python3.5/dist-packages/bottlenose/api.py", line 235, in _call_api
    return urllib2.urlopen(api_request, timeout=self.Timeout)
  File "/usr/lib/python3.5/urllib/request.py", line 163, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.5/urllib/request.py", line 466, in open
    response = self._open(req, data)
  File "/usr/lib/python3.5/urllib/request.py", line 484, in _open
    '_open', req)
  File "/usr/lib/python3.5/urllib/request.py", line 444, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 1297, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/usr/lib/python3.5/urllib/request.py", line 1254, in do_open
    h.request(req.get_method(), req.selector, req.data, headers)
  File "/usr/lib/python3.5/http/client.py", line 1107, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python3.5/http/client.py", line 1147, in _send_request
    self.putheader(hdr, value)
  File "/usr/lib/python3.5/http/client.py", line 1083, in putheader
    if _is_illegal_header_value(values[i]):
TypeError: expected string or bytes-like object

Thanks!

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dlocommented, Mar 26, 2019

@sergioteula Very weird! Can you confirm that after a response fails on the server, that it works locally immediately afterwards?

0reactions
sergioteulacommented, Mar 27, 2019

@dlo I don’t think so… It has started to fail some days ago, it was working perfectly until now. The strange thing is what I said, stopping running the code and starting it again solves the issue for a moment. Can I send you any extra information?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix: Typeerror: expected string or bytes-like object
This error typically occurs when you attempt to use the re.sub() function to replace certain patterns in an object but the object you're...
Read more >
TypeError expected string or bytes-like object - STechies
You might have used various functions in Python. While working with functions, there may be an error called “TypeError expected string or bytes-like...
Read more >
re.sub erroring with "Expected string or bytes-like object"
from my experience in Python, this is caused by a None value in the second argument used in the function re.findall(). import re...
Read more >
TypeError: expected string or bytes-like object in Python
The “TypeError: expected string or bytes-like object” arises when we pass various data type values to a method that expects string type parameter...
Read more >
re.sub erroring with “Expected string or bytes-like object”
Note: This error usually encountered when a function that you are using or have defined is fed an integer or float. It might...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found