Skip to content

Migrate to Python 3#1

Draft
gabrc52 wants to merge 7 commits intomit-athena:masterfrom
gabrc52:master
Draft

Migrate to Python 3#1
gabrc52 wants to merge 7 commits intomit-athena:masterfrom
gabrc52:master

Conversation

@gabrc52
Copy link
Copy Markdown

@gabrc52 gabrc52 commented Mar 30, 2023

This PR also migrates from the older Pyrex to the newer Cython. Also note that I have not touched the debian branch or tested .deb generation, so it may need some tweaking.

Comment thread README
Alternatively, PyMoira has been packaged for Debian and Ubuntu. To
build the Debian package of the latest release, run::

_(NOTE: deb generation is untested)_
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please test it?

Comment thread _moira.pyx Outdated
Comment thread moira.py Outdated
Comment thread moira.py Outdated
"""
if isinstance(s, str):
return s.encode()
else:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remove the else and unindent the return s since you early-return on line 30

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

Comment thread moira.py Outdated
Comment thread moira.py Outdated
Comment thread _moira.pyx Outdated
@gabrc52 gabrc52 marked this pull request as draft March 30, 2023 05:31
Comment thread moira.py
_et_cache = {}


def _to_bytes(s):
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I am not completely sure how necessary this function is, but doing .encode() instead of _to_bytes everywhere I used _to_bytes results in messages like AttributeError: 'bytes' object has no attribute 'encode'. Did you mean: 'decode'?.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks like _to_bytes is basically coping with sometimes being passed a bytes and sometimes a string. If you need to handle that, I suspect you need something like _to_bytes, but if you can be consistent about "this function always takes a string" or "this function always takes bytes", you can just use .encode as needed.

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.

3 participants