Skip to content

Add bytes_strictness to allow configuring behavior on bytes/text mismatch #171

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

Merged
merged 3 commits into from
Mar 2, 2018

Conversation

encukou
Copy link
Member

@encukou encukou commented Jan 22, 2018

See #166 for initial discussion, or the changed docs for what is added.

I've used bytes_strictness instead of bytes_warnings, since warnings is just one of the possible behaviors. The new name isn't perfect either, though.

@codecov
Copy link

codecov bot commented Jan 22, 2018

Codecov Report

Merging #171 into master will decrease coverage by 0.09%.
The diff coverage is 59.09%.

@@            Coverage Diff            @@
##           master     #171     +/-   ##
=========================================
- Coverage   69.61%   69.51%   -0.1%     
=========================================
  Files          49       49             
  Lines        4732     4740      +8     
  Branches      817      820      +3     
=========================================
+ Hits         3294     3295      +1     
- Misses       1084     1088      +4     
- Partials      354      357      +3
Impacted Files Coverage Δ
Lib/ldap/ldapobject.py 70.63% <59.09%> (-0.94%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e148184...2920ac2. Read the comment docs.

@encukou
Copy link
Member Author

encukou commented Jan 23, 2018

@tiran, whenever you're ready, could you take a look?
(I realize this is in the order of weeks, thanks to a conference)

@tiran
Copy link
Member

tiran commented Jan 23, 2018

@encukou Next week after DevConf CZ.

if bytes_mode:
raise ValueError("bytes_mode is *not* supported under Python 3.")
bytes_mode = False
bytes_strictness = 'error'
Copy link
Member

Choose a reason for hiding this comment

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

Maybe raise an exception when bytes_strictness argument is neither 'error' nor None?

is a subclass of :class:`BytesWarning` designed to be easily
:ref:`filtered out <filter-bytes-warning>` if needed.
``bytes_strictness='error'`` (default if ``bytes_mode`` is specified):
A ``TypeError`` is raised.
Copy link
Member

Choose a reason for hiding this comment

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

We should spell out the behavior in form of an example and list affected attributes

If bytes_mode is True and a text string is encountered, then a TypeError is raised. If bytes_mode is False...

Bytes mode applies to:

  • dn argument
  • attr argument
  • newrdn argument for rename
  • who and cred for bind
  • user, oldpw and newpw for passwd
  • base, filterstr and attrlist members for search*
  • mod_type (2nd argument) of modlist member for add*, modify*

Copy link
Member Author

Choose a reason for hiding this comment

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

I linked to text mode from those arguments. Does that look good?

Copy link
Member

@tiran tiran left a comment

Choose a reason for hiding this comment

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

Code looks mostly fine. See inline comments for nit-picks and improved documentation.

@encukou
Copy link
Member Author

encukou commented Feb 1, 2018

Should document that the strictness option only applies to py2; on py3 it's ignored. It's done this way for py2/py3 single-source compatibility.

@encukou
Copy link
Member Author

encukou commented Feb 19, 2018

@tiran, do you think you'll find some time to review?

@encukou
Copy link
Member Author

encukou commented Feb 28, 2018

@tiran, can you get to a review by end of this week?
It's OK if not, or if you need more time. Just please let me know.

Copy link
Member

@tiran tiran left a comment

Choose a reason for hiding this comment

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

@encukou encukou merged commit deb411c into python-ldap:master Mar 2, 2018
@encukou encukou deleted the bytes-strictness branch March 2, 2018 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants