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

ERROR TYPE modi_code= types.CodeType( *modi_args ) #85

Closed
crocodile62 opened this issue Apr 14, 2020 · 6 comments
Closed

ERROR TYPE modi_code= types.CodeType( *modi_args ) #85

crocodile62 opened this issue Apr 14, 2020 · 6 comments

Comments

@crocodile62
Copy link

I get this erro from PyCharme debug and it is not importing the libray.
I have no clue about it.
I get the same error launching python3 -m cpppo.server.enip

I think something is wrong in my installation, somebody could help me?
thanks

My environment is Mac PowerBook with Catalina and python 3.8 with PyCharme
Thanks a lot for your help
this is the terminal response to python3 -m cpppo.server.enip
traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 184, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 110, in _get_module_details
import(pkg_name)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/cpppo/init.py", line 29, in
from .automata import *
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/cpppo/automata.py", line 33, in
from . import misc
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/cpppo/misc.py", line 204, in
change_function( __normal, co_filename=logging._srcfile )
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/cpppo/misc.py", line 163, in change_function
modi_code = types.CodeType( *modi_args )
TypeError: an integer is required (got type bytes)

modi_code = types.CodeType( *modi_args )
TypeError: an integer is required (got type bytes)

@kdorsel
Copy link

kdorsel commented Apr 21, 2020

I got the same error on Python 3.8.

It works fine on Python 2.7, and I imagine it also works fine on 3.7.

Python 3.8.2 (default, Feb 26 2020, 02:56:10) 
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from cpppo.server.enip.get_attribute import proxy as plc
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/gastronomous/gastro/env/lib/python3.8/site-packages/cpppo/__init__.py", line 29, in <module>
    from .automata import *
  File "/home/gastronomous/gastro/env/lib/python3.8/site-packages/cpppo/automata.py", line 33, in <module>
    from . import misc
  File "/home/gastronomous/gastro/env/lib/python3.8/site-packages/cpppo/misc.py", line 204, in <module>
    change_function( __normal, co_filename=logging._srcfile )
  File "/home/gastronomous/gastro/env/lib/python3.8/site-packages/cpppo/misc.py", line 163, in change_function
    modi_code			= types.CodeType( *modi_args )
TypeError: an integer is required (got type bytes)

@EarlAlnot
Copy link

EarlAlnot commented Apr 22, 2020

Got the same error and managed to solve it by adding changing line 143. Seems types.CodeType got a new attribute (at least in a 3.8.x release).

Was:

        attrs		       += [ "co_kwonlyargcount" ]

Now:

        attrs		       += [ "co_posonlyargcount" ,         # <-- Added
            		          "co_kwonlyargcount" ] 

First time posting and not so proficient with Github, so please have mercy.

@kdorsel
Copy link

kdorsel commented Apr 26, 2020

Awesome, that fixed it indeed. For those looking:

cpppo/misc.py

Line 143 in 272327c

attrs += [ "co_kwonlyargcount" ]

@pjkundert
Copy link
Owner

Python 3.7/3.8 compatibility is now complete in version 4.0.5; pushed to pypi

@barthelmeh
Copy link

I'm still getting an error on the same line: TypeError: code() argument 13 must be str, not int
Unsure how to fix this.

@EarlAlnot
Copy link

EarlAlnot commented Jun 19, 2023

Possibly already solved here by @crmaxj

It seems the arguments of type.codetype have changed again. The ones you need to use depend on your version of Python.

If you don't know where your cpppo library is stored, you could run a python script with the following lines:

import cpppo
print(cpppo.__file__)

If you need further assistance, please let me know which version of python you are running.

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

No branches or pull requests

5 participants