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

PostUpdate broken on python 2.7 when using str (byte) message #546

h3llrais3r opened this Issue Feb 20, 2018 · 1 comment


None yet
2 participants

h3llrais3r commented Feb 20, 2018

Hi, I've just upgraded to the last version 3.4 but I'm encountering the following issue:
I cannot longer do a PostUpdate in Python 2.7 when the message is a str(byte) string.
When using a unicode string, it works.

api = Api(consumer_key=CONSUMER_KEY,


I assume that you want to work with unicode string internally, but the code below does not seem to convert a byte string to a unicode string in all cases.


It seems that is only for Python 3 (where str is unicode). In Python 2 this is a byte string.
You may want to use the six library here to support both Python 2 and 3.

Since there is no conversion to unicode, it results in the following error:

File "C:\Tools\GitHub\Auto-Subliminal\lib\twitter\", line 1111, in PostUpdate
    if verify_status_length and calc_expected_status_length(u_status) > CHARACTER_LIMIT:
  File "C:\Tools\GitHub\Auto-Subliminal\lib\twitter\", line 185, in calc_expected_status_length
    if any([ord(normalize("NFC", character)) in char_range for char_range in CHAR_RANGES]):
TypeError: must be unicode, not str

h3llrais3r added a commit to h3llrais3r/Auto-Subliminal that referenced this issue Feb 20, 2018

Temporary fix for twitter api
Force unicode message until bear/python-twitter#546 is fixed.

This comment has been minimized.


jeremylow commented Feb 22, 2018

fixed in 409a733

@jeremylow jeremylow closed this Feb 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment