-
-
Notifications
You must be signed in to change notification settings - Fork 316
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
Fix action functions with unicode constants py2 #3139
Fix action functions with unicode constants py2 #3139
Conversation
… an array of items one of which was unicode.
…ting it to a bytearray utf-8 encoded. This was breaking python action functions with unicode constant strings
…). This allows easily running a single test
Also added info on bug fix in this branch.
Fixes in 783a97 and 97f9431 look good to me. |
This change looks unnecessarily complicated. The culprit is this condition: if isinstance (s, (bytes, bytearray)) or bytes is str:
return s It always passes on python2, regardless of what Anything that's not def to_bytes(s):
if s is None:
return b'None'
if isinstance(s, (bytes, bytearray)):
return s
return bytearray(s, 'utf-8') |
On py2 we want a string an not bytearray().. So not really.
|
It was changed to |
py 2 string, or bytearray is what we want for signatures.
bytearray is used to encode a py2 unicode.
…On Thu, Jun 28, 2018 at 12:17 PM, lightmare ***@***.***> wrote:
not PY3 is basically the same thing as bytes is str. The error in that
part of the condition is that it doesn't take the type of s into account
-- it can be str (i.e. bytes) or unicode on py2 (or maybe even
UserString, not sure) -- and you don't want to return s when it's unicode.
On py2 we want a string an not bytearray().. So not really.
It was changed to bytearray for py2 in master so I assumed that's
desired. bytearray can be used in the same way on both py2 and py3
(unlike bytes whose constructor doesn't accept encoding on py2).
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#3139 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAFBNJmkgYNWfaZucPZgVGTxw9vb7jmWks5uBSvcgaJpZM4U0n-N>
.
|
That's what the function I posted above does. Returns py2.str as is; py2.unicode as bytearray; py3.str as bytearray. |
Didn't realized bytes === string for py2. Good simplification!
…On Sat, Jun 30, 2018 at 3:19 AM, lightmare ***@***.***> wrote:
That's what the function I posted above does. Returns py2.str as is;
py2.unicode as bytearray; py3.str as bytearray.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#3139 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAFBNE5f8z5yxl6gVn7oUWUPydu_6L_Eks5uB1CigaJpZM4U0n-N>
.
|
Fix for bug reported on mailing list by Eugene Leskinen
https://pairlist4.pair.net/pipermail/scons-users/2018-June/007067.html
Here's a small SConstruct to exercise. A unit test has been added to cover the core issue which was that to_Bytes wasn't converting unicode strings to bytearray on python 2.7. This was then getting joined with bytes and throwing a stack trace.
Contributor Checklist:
master/src/CHANGES.txt
directory (and read theREADME.txt
in that directory)