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

Add compatibility to python 3.8 #2

Merged
merged 4 commits into from
Jun 17, 2022
Merged

Conversation

daniel-freiermuth
Copy link
Contributor

@daniel-freiermuth daniel-freiermuth commented Jun 16, 2020

py3traits stops working for python 3.8. With the change proposed in this PR py3traits works for 3.8 again.

@jhermann
Copy link

jhermann commented Jun 16, 2020

Why not add a simple sys.version_info check to have both? Or even better check for availability of the new code attribute / catch the attribute error.

@daniel-freiermuth
Copy link
Contributor Author

Sounds good. I adapted the PR. Thanks!

@@ -39,7 +40,8 @@ def _clone_function(self, function):

trait["co_argcount"] = function.__code__.co_argcount
trait["co_kwonlyargcount"] = function.__code__.co_kwonlyargcount
trait["co_posonlyargcount"] = function.__code__.co_posonlyargcount
if sys.version_info[0] == 3 and sys.version_info[1] >= 8:
Copy link

@jhermann jhermann Jun 17, 2020

Choose a reason for hiding this comment

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

sys.version_info[:2] >= (3, 8) is more common, because way more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, this is a nice and compact test.

@@ -40,7 +40,7 @@ def _clone_function(self, function):

trait["co_argcount"] = function.__code__.co_argcount
trait["co_kwonlyargcount"] = function.__code__.co_kwonlyargcount
if sys.version_info[0] == 3 and sys.version_info[1] >= 8:
if sys.version_info[:1] >= (3, 8) :

Choose a reason for hiding this comment

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

must be :2 sorry I thought I had fixed that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh sorry, I thought the slice indices to be inclusive, which is apparently not true. (Your suggestion above was correct.)

Copy link

Choose a reason for hiding this comment

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

oh dear... this been here a while. Thank you a lot, I appreciate the effort! I stumbled similar error yesterday in different context.

@Debith Debith merged commit 473dd57 into Debith:master Jun 17, 2022
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.

4 participants