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

Porting PyClean to python3 #8

Merged
merged 5 commits into from Jan 8, 2023
Merged

Conversation

Julien-Elie
Copy link
Contributor

This PR is to apply after #7.
It is made of 3 commits:

  • Copy dictionary keys when modified inside a loop as Python 3.x no longer copies the dictionary when getting the keys, and therefore the loop fails with an exception because the dictionary is changed inside the loop.
  • Properly handle memoryview objects, encoding and decoding them when appropriate. Use UTF-8 when translating from or to strings, as well as when logging articles.
  • Use a portable syntax for Exception.

There was a mix of LF and CRLF.  Switch to LF as the only new line character
for both one-line header fields, continuation lines in header fields and the
article body.
The art dictionary contains all the usual header fields (more than 70,
populated by innd).  When empty, they have a None value.

In some places in the code, the detection was wrong (looking at the presence
of the header field name in the dictionary instead of the presence of a value).
Python 3.x no longer copies the dictionary when getting the keys, and therefore
the loop fails with an exception because the dictionary is changed inside the
loop.

Adds an explicit copy.
Properly handle memoryview objects, encoding and decoding them when
appropriate.  Use UTF-8 when translating from or to strings.

Also, use UTF-8 when logging articles.
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.

None yet

2 participants