Skip to content

Commit b04d5a8

Browse files
committed
Fix python 3.11 support
Add patch from open PR pjkundert/cpppo#110
1 parent 7ee758a commit b04d5a8

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed

recipe/meta.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ source:
1010
sha256: 8c5a2947d6e9fd732d2d887fa02216beebb4068ab99e2590590f491425992bc6
1111
patches:
1212
- remove_getattr_entrypoint.diff
13+
# From https://github.com/pjkundert/cpppo/pull/110
14+
- python-311-support-pr110.patch
1315

1416
build:
1517
noarch: python
1618
script: {{ PYTHON }} -m pip install . -vv
17-
number: 0
19+
number: 1
1820
entry_points:
1921
- enip_server = cpppo.server.enip.main:main
2022
- enip_client = cpppo.server.enip.client:main

recipe/python-311-support-pr110.patch

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
diff --git a/misc.py b/misc.py
2+
index 99a41ad..f063b97 100644
3+
--- a/misc.py
4+
+++ b/misc.py
5+
@@ -136,41 +136,29 @@ def change_function( function, **kwds ):
6+
7+
will change the func's co_filename to the specified string.
8+
9+
- The types.CodeType constructor differs between Python 2 and 3; see
10+
- type help(types.CodeType) at the interpreter prompt for information:
11+
+ The types.CodeType constructor differs between Python versions; see
12+
+ type help(types.CodeType) at the interpreter prompt for information.
13+
14+
- Python2:
15+
- code(argcount, nlocals, stacksize, flags, codestring,
16+
- | constants, names, varnames, filename, name, firstlineno,
17+
- | lnotab[, freevars[, cellvars]])
18+
+ """
19+
20+
- Python3:
21+
- code(argcount, kwonlyargcount, nlocals, stacksize, flags, codestring,
22+
- | constants, names, varnames, filename, name, firstlineno,
23+
- | lnotab[, freevars[, cellvars]])
24+
+ version_lookup = {
25+
+ (2, 7): ["co_argcount", "co_nlocals", "co_stacksize", "co_flags", "co_code", "co_consts", "co_names", "co_varnames", "co_filename", "co_name", "co_firstlineno", "co_lnotab", "co_freevars", "co_cellvars"],
26+
+ (3, 7): ["co_argcount", "co_kwonlyargcount", "co_nlocals", "co_stacksize", "co_flags", "co_code", "co_consts", "co_names", "co_varnames", "co_filename", "co_name", "co_firstlineno", "co_lnotab", "co_freevars", "co_cellvars"],
27+
+ (3, 8): ["co_argcount", "co_posonlyargcount", "co_kwonlyargcount", "co_nlocals", "co_stacksize", "co_flags", "co_code", "co_consts", "co_names", "co_varnames", "co_filename", "co_name", "co_firstlineno", "co_lnotab", "co_freevars", "co_cellvars"],
28+
+ (3, 9): ["co_argcount", "co_posonlyargcount", "co_kwonlyargcount", "co_nlocals", "co_stacksize", "co_flags", "co_code", "co_consts", "co_names", "co_varnames", "co_filename", "co_name", "co_firstlineno", "co_lnotab", "co_freevars", "co_cellvars"],
29+
+ (3, 10): ["co_argcount", "co_posonlyargcount", "co_kwonlyargcount", "co_nlocals", "co_stacksize", "co_flags", "co_code", "co_consts", "co_names", "co_varnames", "co_filename", "co_name", "co_firstlineno", "co_linetable", "co_freevars", "co_cellvars"],
30+
+ (3, 11): ["co_argcount", "co_posonlyargcount", "co_kwonlyargcount", "co_nlocals", "co_stacksize", "co_flags", "co_code", "co_consts", "co_names", "co_varnames", "co_filename", "co_name", "co_qualname", "co_firstlineno", "co_linetable", "co_exceptiontable", "co_freevars", "co_cellvars"]
31+
+ }
32+
33+
+ version, minor = sys.version_info[0], sys.version_info[1]
34+
35+
- """
36+
- # Enumerate all the __code__ attributes in the same order; types.CodeTypes
37+
- # doesn't accept keyword args, only position.
38+
- attrs = [ "co_argcount" ]
39+
- if sys.version_info[0] >= 3:
40+
- attrs += [ "co_kwonlyargcount" ]
41+
- if sys.version_info[1] >= 8:
42+
- attrs += [ "co_posonlyargcount" ]
43+
- attrs += [ "co_nlocals",
44+
- "co_stacksize",
45+
- "co_flags",
46+
- "co_code",
47+
- "co_consts",
48+
- "co_names",
49+
- "co_varnames",
50+
- "co_filename",
51+
- "co_name",
52+
- "co_firstlineno",
53+
- "co_lnotab",
54+
- "co_freevars",
55+
- "co_cellvars" ]
56+
+ # Clamp major version to 2 or 3
57+
+ version = max(min(version, 3), 2)
58+
+
59+
+ # Clamp minor version to 7-11
60+
+ minor = max(min(minor, 11), 7)
61+
+
62+
+ attrs = version_lookup[(version, minor)]
63+
64+
assert all( k in attrs for k in kwds ), \
65+
"Invalid function keyword(s) supplied: %s" % ( ", ".join( kwds.keys() ))

0 commit comments

Comments
 (0)