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

Support python 3.11, fix bug in CodeType arg order #110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

crmaxj
Copy link

@crmaxj crmaxj commented Jan 6, 2023

I had an import failing when trying to run my cpppo code in python 3.11:

  File "/Users/maxj/Documents/Charge/factory/factory/drivers/al1120.py", line 16, in <module>
    from cpppo.server.enip.get_attribute import proxy_simple
  File "/Users/maxj/Library/Caches/pypoetry/virtualenvs/factory-4i3Wbpjw-py3.11/lib/python3.11/site-packages/cpppo/__init__.py", line 29, in <module>
    from .automata import *
  File "/Users/maxj/Library/Caches/pypoetry/virtualenvs/factory-4i3Wbpjw-py3.11/lib/python3.11/site-packages/cpppo/automata.py", line 33, in <module>
    from . import misc
  File "/Users/maxj/Library/Caches/pypoetry/virtualenvs/factory-4i3Wbpjw-py3.11/lib/python3.11/site-packages/cpppo/misc.py", line 221, in <module>
    change_function( __normal, co_filename=logging._srcfile )
  File "/Users/maxj/Library/Caches/pypoetry/virtualenvs/factory-4i3Wbpjw-py3.11/lib/python3.11/site-packages/cpppo/misc.py", line 180, in change_function
    modi_code			= types.CodeType( *modi_args )

I looked into this and it looked like there was some python-version-specific code in misc.py.

In addition to adding support for python version 3.11, I also noticed what I think is a bug in the existing code. If you run help(types.CodeType) in a python 3.8, 3.9, or 3.10 shell, you'll see that the second argument to code is posonlyargcount, but in the current code it is assumed to be kwonlyargcount. I fixed that in this PR as well.

I tested this by running the import in python versions 3.7, 3.9, 3.10, and 3.11. I did not test in python 2.

It would be cool if someone with more knowledge of this code than me could kill this function entirely! Also I didn't see any CONTRIBUTING docs, so apologies if I'm doing this wrong. Thank you!

@djformby
Copy link

djformby commented Jun 2, 2023

I ran into this too and made my own fix before finding yours. I just tested your changes with version 3.11 and can confirm that it fixed my problem

beenje added a commit to beenje/cpppo-feedstock that referenced this pull request Sep 8, 2023
@acode-x
Copy link

acode-x commented Dec 5, 2023

Can we get this merged?

@crmaxj
Copy link
Author

crmaxj commented Apr 16, 2024

Hi @pjkundert, just wanted to follow up on this, any chance we could please merge this PR?

@pjkundert
Copy link
Owner

Hi, @crmaxj;

Sorry, I've been super busy with other work!  I have a huge branch that includes all this and many other fixes (feature-pro).

Unfortunately, nobody seems all that interested in this project, so I've had to prioritise paying work!  I'll see if I can get to it soon.

@crmaxj
Copy link
Author

crmaxj commented Apr 17, 2024

No worries at all, that is super understandable! Just sent a small donation your way, keep up the good work.

@pjkundert
Copy link
Owner

Wow thanks! That's really appreciated. I'll try to get to it soon.

@pjkundert pjkundert force-pushed the master branch 3 times, most recently from 5d7841f to 00e38df Compare November 22, 2024 17:35
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