-
Notifications
You must be signed in to change notification settings - Fork 26
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
Make tests run on py3 #398
Merged
Merged
Conversation
This file contains 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
This was used for live translation, a feature which ceased to exist long time ago.
We need to do this because the file has been open in binary mode.
The `tostring` API only accepts strings, and this didn't break in py2 because `unicode` exists as a constructor. So while it didn't break, it was encoding strings as ASCII. Refs. https://github.com/lxml/lxml/blob/6beef451a6690796d13fc3d2a19321434b880d16/src/lxml/html/__init__.py#L1790-L1793
int and long are now contained within int.
From the Python docs: "for backward compatibility, the re.U flag still exists (as well as its synonym re.UNICODE and its embedded counterpart (?u)), but these are redundant in Python 3 since matches are Unicode by default for strings"
Previously the `__str__` method would perform the conversion step, and the `serialize` method was relying on that behavior. When we merged `__unicode__` and `__str__` methods though, that behavior ceased to exist. At the same time, we need to serialize to bytes (which was str in PY2), so that change is needed too.
By default, files will be open in text mode under py3 (py2 was str, hence bytes). In order to keep the previous behavior, we need to force reading to bytes by specifying the extra 'b' flag to `open`.
`last_sync_revision` and `source_revision` can be `None`, and in such cases comparisons and even logging would fail, because py3 is stricter on what operations can be done across data types.
We convert filter/map to list comprehensions only when we actually need a list. No changes have been made in cases where an iterator can be used (e.g. for post-processing with `any`, `sorted`, `list`, or just iterating).
Because now `keys()` and `items()` return iterators, in some cases we need to convert them to lists.
The QuerySet returned by `values()` is not subscriptable, so we need to convert it to a list.
The reported DB name string is different now.
Fixes linting issues and simplifies some patterns by removing unneeded escaping.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR:
The codebase will definitely need more fixes because our current test coverage is around 80%.
Refs. #377.