Skip to content
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

[Py3] WSGI part 2 #427

Closed
wants to merge 7 commits into from
Closed

[Py3] WSGI part 2 #427

wants to merge 7 commits into from

Conversation

MartinBasti
Copy link
Contributor

@MartinBasti MartinBasti commented Jan 31, 2017

with this PR:

  • server can be installed with python3-mod_wsgi
  • any xmlrpc test can be executed to find a new py3 issues (still a lot of them there)

delval = unicode(base64.b64encode(delval))
raise errors.AttrValueNotFound(attr=attr, value=delval)
delval = base64.b64encode(delval).decode('ascii')
raise errors.AttrValueNotFound(attr=attr, value=delval)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you indent the line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea

@@ -255,7 +255,8 @@ def entry_to_dict(entry, **options):
value = list(entry.raw[attr])
for (i, v) in enumerate(value):
try:
value[i] = v.decode('utf-8')
if isinstance(v, bytes):
value[i] = v.decode('utf-8')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

entry.raw[] should always return a list of bytes. Why the if?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be fixed in ipaldap

ipalib/rpc.py Outdated
@@ -308,7 +308,7 @@ def json_encode_binary(val, version):
encoded = encoded.decode('ascii')
return {'__base64__': encoded}
elif isinstance(val, Decimal):
return {'__base64__': base64.b64encode(str(val))}
return {'__base64__': base64.b64encode(str(val).encode('ascii'))}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value must be text, but base64.b64encode() returns binary data, so you should also decode its result.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

ipalib/rpc.py Outdated
@@ -308,7 +308,8 @@ def json_encode_binary(val, version):
encoded = encoded.decode('ascii')
return {'__base64__': encoded}
elif isinstance(val, Decimal):
return {'__base64__': base64.b64encode(str(val))}
return {'__base64__': base64.b64encode(
str(val).encode('ascii')).decode('ascii')}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we please get rid of this non-sense and return unicode(val)? (It is a backward compatible change.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as you wish

Using unicode(bytes) call causes undesired side effect that is inserting
`b` character to result. This obviously causes issues with binary base64 data

https://fedorahosted.org/freeipa/ticket/4985
In py3 keys() doesn't return list but iterator so it must be transformed
to tuple otherwise iterator will be broken.

https://fedorahosted.org/freeipa/ticket/4985
The encode method of LDAPClient didn't return DNSName as bytes but
string in py3. In py2 it returns non-unicode string so it can be encoded
safely by ascii as to_text() method returns only ascii characters.

https://fedorahosted.org/freeipa/ticket/4985
for Decimal only from client to server direction uses __base64__
notation. Server replies with pure string for Decimal data, and also
server is able to parse string and create decimal values where needed.

without this we need ugly py3 code:
-        return {'__base64__': base64.b64encode(str(val))}
+        return {'__base64__': base64.b64encode(
+            str(val).encode('ascii')).decode('ascii')}

https://fedorahosted.org/freeipa/ticket/4985
@HonzaCholasta HonzaCholasta added ack Pull Request approved, can be merged pushed Pull Request has already been pushed labels Feb 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ack Pull Request approved, can be merged pushed Pull Request has already been pushed
Projects
None yet
3 participants