This repository was archived by the owner on Mar 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… if LDAPObject._trace_level is non-zero and Python is running in debug mode
…RL into a list to be displayed with self.fail()
Testing of attributetypes and objectclasses parsing from file Fixes: #79
Well obliviously it needs some better error reporting, asserts instead of print? (see #82) |
This belongs to When |
…r.py based on module unittest
…n module unittest
Thanks, let me know if any help with this is needed |
I've added Samba's |
Sync with upstream 2.4.35
Those were introduced in 3c46166; however, we strive to be absolutely explicit on the return type of our functions: - with `bytes_mode=True` (legacy behavior), we use bytes (Py2 'str') on every Distinguished Name like attributes - with `bytes_mode=False` or under Py3, we always use text (Py2 'unicode' or Py3 'str') for those attributes => `ldap.search_subschemasubentry_s` should return values according to those rules.
This is a backport from python-ldap 2.4.37 Fixes: #90
This is a backport from python-ldap 2.4.39+ Fixes: #90
…troduced in 2.4.35 #94
_unbytesify_value is a no-op in Python 3, so add a new function that actually decodes bytes to text when bytes_mode is set to False, reagrdless of Python version. To match the other bytesify functions, the type assertion is only run under Python 2.
Rework how pyldap handles converting Unicode to UTF-8 encoded byte-strings to avoid inconsistencies between Python 2 and Python 3 in how Python's C API handles the "s" format unit. The inconsistencies result in Python 2 raising UnicodeEncodeErrors when Unicode strings with non-ASCII characters are passed to the C bindings. - In Python 3, the "s" format expects the argument to be a unicode string, and it encodes it using UTF-8 (unconditionally). - In Python 2, the "s" format tries to encode unicode strings using the default encoding (sys.getdefaultencoding(), which defaults to 'ascii'). Avoid these inconsistencies (while preserving the warnings/error handling) by explicitly encoding values to UTF-8 bytes, instead of passing passing unicode objects to C. Doing this addresses the issue, while still relying on Python for GC/memory management. The alternatives (e.g. using the "es" format unit) would require more invasive changes in the C bindings, including explicit memory management. Also update `attrs_from_List` to align with these changes: - In Python 2, assume a sequence of bytes objects (encoded to UTF-8) - In Python 3, assume a sequence of string (Unicode) objects and rely on Python to encode to UTF-8 and handle the memory allocations. This simplification of attrs_from_List also fixes a leak of the bytes objects; previously, the new object returned by PyUnicode_AsUTF8String was leaked. Fixes #4 Fixes #39 Fixes #54
The original comparison made python3 sad with "BytesWarning: Comparison between bytes and string" warning.
PEP8-styling accidentally snuck into parts of _unbytesify_result. Also comment a commented-out bind test.
Remove usage of dict.keys().pop(). Closes #84.
Improve unicode handling in Python 2
- Improve docstrings - Rename helpers to clarify their role - Merge _bytesify_value and _unbytesify_encoded_text
A call to 'result4' returns properly typed entries for Py3, we have to convert it back to bytes only under Py2 bytes_mode. Converting from bytes to text should only occur when decoding attribute *values*.
I've updated this to the current master, so the tests still pass. Sorry for what it looks like on GitHub. |
Ok, no problem |
I have written tests in upstream PR python-ldap/python-ldap#52 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Testing of attributetypes and objectclasses parsing from file
Fixes: #79
I inspired by
test_tokenizer
, and I'm not sure if that was the best idea, I miss asserts there, so let me know if that test should be done in different way.