Fix python2 server compatibility#513
Conversation
Fixes sshuttle#469. We replace python3 exclusive code with a check for python3 and a compatibility fix. Note that the switch from os.set_nonblocking to fcntl.fcntl in 98d052d (fixing sshuttle#503) also fixes python2 compatibility.
|
I think these two lines need fixing also: Lines 302 to 303 in 45f8cce Python 2.7 doesn't support the rb string prefix. |
|
Do they get called on the server? I thought that was client side. My intention was just to patch the server side code for python2 compatibility. Then we might manage to maintain it for a while. Trying keep the whole client python2 compatible seems like too much work. Either way, I think the 'b' can be safely removed right? Just testing those asserts in python2 and python3 everything seems to work fine as just r-strings. If you agree then I push a change to remove the 'b'. |
|
OK, sounds good to me. No,unfortunately, you can't remove the b prefix, it will break under python3 because the string is a byte value: |
|
Ah yes, I didn't think about the case the string being searched was byte string. Let me see if I can work around it. |
Python2 ignores the byte string qualification (b’foo’) but falls over for the combination rb for this regexp. Switching the qualification to br appears to fix this and works in both python2 and python3.
|
Haha, how about that for a fix! I made a minimal test outside of sshuttle and it seemed to be fine once I switched the order of rb to br! Not sure how to test within sshuttle because I don't think my usage ever hits those lines. |
|
Wow. I never thought of switching it to 'br'. Anyway, thanks for you work here. |
|
Any clue bout when will it be released? |
|
@leiserfg sshuttle 1.0.5 was recently released with this fix. |
Fixes #469. We replace python3 exclusive code with a check for python3 and a compatibility fix. Note that the switch from os.set_nonblocking to fcntl.fcntl in 98d052d (fixing #503) also fixes python2 compatibility.
@brianmay I don't know if you like where I put the definition of the 'which' function. Maybe that should be moved? I think the changes are relatively minor and fix python2 compatibility with the server.
sshuttle is now working for my with a python2 server, but I only have a single setup I can test. Could you or someone else test with a python3 server?
I marked the compatibility code with
#python2 compatcomments to make it clear in the future.