Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit811edcf

Browse files
Revert "gh-132775: Add _PyCode_GetVarCounts() (gh-133128)" (gh-133232)
The change broke the s390 builds, so I'm reverting it while I investigate.This reverts commit94b4fcd.
1 parent0119791 commit811edcf

File tree

5 files changed

+0
-689
lines changed

5 files changed

+0
-689
lines changed

‎Include/cpython/funcobject.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,6 @@ static inline PyObject* PyFunction_GET_GLOBALS(PyObject *func) {
9797
}
9898
#definePyFunction_GET_GLOBALS(func) PyFunction_GET_GLOBALS(_PyObject_CAST(func))
9999

100-
staticinlinePyObject*PyFunction_GET_BUILTINS(PyObject*func) {
101-
return_PyFunction_CAST(func)->func_builtins;
102-
}
103-
#definePyFunction_GET_BUILTINS(func) PyFunction_GET_BUILTINS(_PyObject_CAST(func))
104-
105100
staticinlinePyObject*PyFunction_GET_MODULE(PyObject*func) {
106101
return_PyFunction_CAST(func)->func_module;
107102
}

‎Include/internal/pycore_code.h

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -565,57 +565,6 @@ extern int _Py_ClearUnusedTLBC(PyInterpreterState *interp);
565565
#endif
566566

567567

568-
typedefstruct {
569-
inttotal;
570-
structco_locals_counts {
571-
inttotal;
572-
struct {
573-
inttotal;
574-
intnumposonly;
575-
intnumposorkw;
576-
intnumkwonly;
577-
intvarargs;
578-
intvarkwargs;
579-
}args;
580-
intnumpure;
581-
struct {
582-
inttotal;
583-
// numargs does not contribute to locals.total.
584-
intnumargs;
585-
intnumothers;
586-
}cells;
587-
struct {
588-
inttotal;
589-
intnumpure;
590-
intnumcells;
591-
}hidden;
592-
}locals;
593-
intnumfree;// nonlocal
594-
structco_unbound_counts {
595-
inttotal;
596-
struct {
597-
inttotal;
598-
intnumglobal;
599-
intnumbuiltin;
600-
intnumunknown;
601-
}globals;
602-
intnumattrs;
603-
intnumunknown;
604-
}unbound;
605-
}_PyCode_var_counts_t;
606-
607-
PyAPI_FUNC(void)_PyCode_GetVarCounts(
608-
PyCodeObject*,
609-
_PyCode_var_counts_t*);
610-
PyAPI_FUNC(int)_PyCode_SetUnboundVarCounts(
611-
PyThreadState*,
612-
PyCodeObject*,
613-
_PyCode_var_counts_t*,
614-
PyObject*globalnames,
615-
PyObject*attrnames,
616-
PyObject*globalsns,
617-
PyObject*builtinsns);
618-
619568
PyAPI_FUNC(int)_PyCode_ReturnsOnlyNone(PyCodeObject*);
620569

621570

‎Lib/test/test_code.py

Lines changed: 0 additions & 230 deletions
Original file line numberDiff line numberDiff line change
@@ -777,236 +777,6 @@ def test_local_kinds(self):
777777
kinds=_testinternalcapi.get_co_localskinds(func.__code__)
778778
self.assertEqual(kinds,expected)
779779

780-
@unittest.skipIf(_testinternalcapiisNone,"missing _testinternalcapi")
781-
deftest_var_counts(self):
782-
self.maxDiff=None
783-
defnew_var_counts(*,
784-
posonly=0,
785-
posorkw=0,
786-
kwonly=0,
787-
varargs=0,
788-
varkwargs=0,
789-
purelocals=0,
790-
argcells=0,
791-
othercells=0,
792-
freevars=0,
793-
globalvars=0,
794-
attrs=0,
795-
unknown=0,
796-
):
797-
nargvars=posonly+posorkw+kwonly+varargs+varkwargs
798-
nlocals=nargvars+purelocals+othercells
799-
ifisinstance(globalvars,int):
800-
globalvars= {
801-
'total':globalvars,
802-
'numglobal':0,
803-
'numbuiltin':0,
804-
'numunknown':globalvars,
805-
}
806-
else:
807-
g_numunknown=0
808-
ifisinstance(globalvars,dict):
809-
numglobal=globalvars['numglobal']
810-
numbuiltin=globalvars['numbuiltin']
811-
size=2
812-
if'numunknown'inglobalvars:
813-
g_numunknown=globalvars['numunknown']
814-
size+=1
815-
assertlen(globalvars)==size,globalvars
816-
else:
817-
assertnotisinstance(globalvars,str),repr(globalvars)
818-
try:
819-
numglobal,numbuiltin=globalvars
820-
exceptValueError:
821-
numglobal,numbuiltin,g_numunknown=globalvars
822-
globalvars= {
823-
'total':numglobal+numbuiltin+g_numunknown,
824-
'numglobal':numglobal,
825-
'numbuiltin':numbuiltin,
826-
'numunknown':g_numunknown,
827-
}
828-
unbound=globalvars['total']+attrs+unknown
829-
return {
830-
'total':nlocals+freevars+unbound,
831-
'locals': {
832-
'total':nlocals,
833-
'args': {
834-
'total':nargvars,
835-
'numposonly':posonly,
836-
'numposorkw':posorkw,
837-
'numkwonly':kwonly,
838-
'varargs':varargs,
839-
'varkwargs':varkwargs,
840-
},
841-
'numpure':purelocals,
842-
'cells': {
843-
'total':argcells+othercells,
844-
'numargs':argcells,
845-
'numothers':othercells,
846-
},
847-
'hidden': {
848-
'total':0,
849-
'numpure':0,
850-
'numcells':0,
851-
},
852-
},
853-
'numfree':freevars,
854-
'unbound': {
855-
'total':unbound,
856-
'globals':globalvars,
857-
'numattrs':attrs,
858-
'numunknown':unknown,
859-
},
860-
}
861-
862-
importtest._code_definitionsasdefs
863-
funcs= {
864-
defs.spam_minimal:new_var_counts(),
865-
defs.spam_full:new_var_counts(
866-
posonly=2,
867-
posorkw=2,
868-
kwonly=2,
869-
varargs=1,
870-
varkwargs=1,
871-
purelocals=4,
872-
globalvars=3,
873-
attrs=1,
874-
),
875-
defs.spam:new_var_counts(
876-
posorkw=1,
877-
),
878-
defs.spam_N:new_var_counts(
879-
posorkw=1,
880-
purelocals=1,
881-
),
882-
defs.spam_C:new_var_counts(
883-
posorkw=1,
884-
purelocals=1,
885-
argcells=1,
886-
othercells=1,
887-
),
888-
defs.spam_NN:new_var_counts(
889-
posorkw=1,
890-
purelocals=1,
891-
),
892-
defs.spam_NC:new_var_counts(
893-
posorkw=1,
894-
purelocals=1,
895-
argcells=1,
896-
othercells=1,
897-
),
898-
defs.spam_CN:new_var_counts(
899-
posorkw=1,
900-
purelocals=1,
901-
argcells=1,
902-
othercells=1,
903-
),
904-
defs.spam_CC:new_var_counts(
905-
posorkw=1,
906-
purelocals=1,
907-
argcells=1,
908-
othercells=1,
909-
),
910-
defs.eggs_nested:new_var_counts(
911-
posorkw=1,
912-
),
913-
defs.eggs_closure:new_var_counts(
914-
posorkw=1,
915-
freevars=2,
916-
),
917-
defs.eggs_nested_N:new_var_counts(
918-
posorkw=1,
919-
purelocals=1,
920-
),
921-
defs.eggs_nested_C:new_var_counts(
922-
posorkw=1,
923-
purelocals=1,
924-
argcells=1,
925-
freevars=2,
926-
),
927-
defs.eggs_closure_N:new_var_counts(
928-
posorkw=1,
929-
purelocals=1,
930-
freevars=2,
931-
),
932-
defs.eggs_closure_C:new_var_counts(
933-
posorkw=1,
934-
purelocals=1,
935-
argcells=1,
936-
othercells=1,
937-
freevars=2,
938-
),
939-
defs.ham_nested:new_var_counts(
940-
posorkw=1,
941-
),
942-
defs.ham_closure:new_var_counts(
943-
posorkw=1,
944-
freevars=3,
945-
),
946-
defs.ham_C_nested:new_var_counts(
947-
posorkw=1,
948-
),
949-
defs.ham_C_closure:new_var_counts(
950-
posorkw=1,
951-
freevars=4,
952-
),
953-
}
954-
assertlen(funcs)==len(defs.FUNCTIONS), (len(funcs),len(defs.FUNCTIONS))
955-
forfuncindefs.FUNCTIONS:
956-
withself.subTest(func):
957-
expected=funcs[func]
958-
counts=_testinternalcapi.get_code_var_counts(func.__code__)
959-
self.assertEqual(counts,expected)
960-
961-
deffunc_with_globals_and_builtins():
962-
mod1=_testinternalcapi
963-
mod2=dis
964-
mods= (mod1,mod2)
965-
checks=tuple(callable(m)forminmods)
966-
returncallable(mod2),tuple(mods),list(mods),checks
967-
968-
func=func_with_globals_and_builtins
969-
withself.subTest(f'{func} code'):
970-
expected=new_var_counts(
971-
purelocals=4,
972-
globalvars=5,
973-
)
974-
counts=_testinternalcapi.get_code_var_counts(func.__code__)
975-
self.assertEqual(counts,expected)
976-
977-
withself.subTest(f'{func} with own globals and builtins'):
978-
expected=new_var_counts(
979-
purelocals=4,
980-
globalvars=(2,3),
981-
)
982-
counts=_testinternalcapi.get_code_var_counts(func)
983-
self.assertEqual(counts,expected)
984-
985-
withself.subTest(f'{func} without globals'):
986-
expected=new_var_counts(
987-
purelocals=4,
988-
globalvars=(0,3,2),
989-
)
990-
counts=_testinternalcapi.get_code_var_counts(func,globalsns={})
991-
self.assertEqual(counts,expected)
992-
993-
withself.subTest(f'{func} without both'):
994-
expected=new_var_counts(
995-
purelocals=4,
996-
globalvars=5,
997-
)
998-
counts=_testinternalcapi.get_code_var_counts(func,globalsns={},
999-
builtinsns={})
1000-
self.assertEqual(counts,expected)
1001-
1002-
withself.subTest(f'{func} without builtins'):
1003-
expected=new_var_counts(
1004-
purelocals=4,
1005-
globalvars=(2,0,3),
1006-
)
1007-
counts=_testinternalcapi.get_code_var_counts(func,builtinsns={})
1008-
self.assertEqual(counts,expected)
1009-
1010780

1011781
defisinterned(s):
1012782
returnsissys.intern(('_'+s+'_')[1:-1])

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp