You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeError: decode() argument 1 must be string, not None #67
However, the error message that you used as the title of this bug is unexpected, and when I run your code on my local machine using Python 2.7 it runs without error, so I think yours and mine are equivalent.
This is the code in the add() method:
defadd(self, *strings):
""" Add the lower case and no-period version of the string arguments to the set. Returns ``self`` for chaining. """forsinstrings:
iftype(s) ==binary_type:
s=s.decode(sys.stdin.encoding)
self.elements.add(lc(s))
returnself
So the error message makes me think that the real problem is that your system does not set a value for sys.stdin.encoding. Try running this command from your environment:
python -c "import sys; print(sys.stdin.encoding)"
I'm guessing it returns None or empty string. Not sure what is an appropriate value to use as a default for your system. And it looks like that class does not implement any way to explicitly set the encoding like the parser class does. I should probably add that.
I just pushed a change to master that I think will fix this on your system, it falls back to utf-8. I also added a new add_with_encoding() method that you can use to specify an encoding.
Activity
derek73 commentedon Dec 7, 2017
Thanks for the bug report. I'm not super clear what's going on. I'm guessing you're using Python 2.7? I would expect this to work in Python 2.7:
However, the error message that you used as the title of this bug is unexpected, and when I run your code on my local machine using Python 2.7 it runs without error, so I think yours and mine are equivalent.
This is the code in the
add()method:So the error message makes me think that the real problem is that your system does not set a value for
sys.stdin.encoding. Try running this command from your environment:I'm guessing it returns
Noneor empty string. Not sure what is an appropriate value to use as a default for your system. And it looks like that class does not implement any way to explicitly set the encoding like the parser class does. I should probably add that.derek73 commentedon Dec 7, 2017
I just pushed a change to master that I think will fix this on your system, it falls back to utf-8. I also added a new
add_with_encoding()method that you can use to specify an encoding.It seems to have broken the python 2.6 build, not sure why. Guess I'll have to track that down before I push this to pip.
derek73 commentedon Dec 7, 2017
I was able to push v0.5.4 to pypi so try a fresh pip install and lmk how it goes.
kpmgceeftech commentedon Dec 7, 2017
With v0.5.4 all works well. Thanks a lot for quick help!