Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
0dfcf753
Commit
0dfcf753
authored
Aug 12, 1996
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable support for access statement
parent
aacdc9da
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
649 additions
and
633 deletions
+649
-633
Grammar/Grammar
Grammar/Grammar
+6
-5
Include/accessobject.h
Include/accessobject.h
+6
-0
Include/graminit.h
Include/graminit.h
+33
-35
Objects/accessobject.c
Objects/accessobject.c
+4
-0
Objects/classobject.c
Objects/classobject.c
+27
-4
Objects/moduleobject.c
Objects/moduleobject.c
+6
-0
Python/ceval.c
Python/ceval.c
+28
-0
Python/compile.c
Python/compile.c
+4
-2
Python/graminit.c
Python/graminit.c
+535
-587
No files found.
Grammar/Grammar
View file @
0dfcf753
...
...
@@ -29,7 +29,8 @@ fplist: fpdef (',' fpdef)* [',']
stmt: simple_stmt | compound_stmt
simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE
small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | access_stmt | exec_stmt
#small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | access_stmt | exec_stmt
small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | exec_stmt
expr_stmt: testlist ('=' testlist)*
# For assignments, additional restrictions enforced by the interpreter
print_stmt: 'print' (test ',')* [test]
...
...
@@ -43,10 +44,10 @@ raise_stmt: 'raise' test [',' test [',' test]]
import_stmt: 'import' dotted_name (',' dotted_name)* | 'from' dotted_name 'import' ('*' | NAME (',' NAME)*)
dotted_name: NAME ('.' NAME)*
global_stmt: 'global' NAME (',' NAME)*
access_stmt: 'access' ('*' | NAME (',' NAME)*) ':' accesstype (',' accesstype)*
accesstype: NAME+
# accesstype should be ('public' | 'protected' | 'private') ['read'] ['write']
# but can't be because that would create undesirable reserved words!
#
access_stmt: 'access' ('*' | NAME (',' NAME)*) ':' accesstype (',' accesstype)*
#
accesstype: NAME+
#
#
accesstype should be ('public' | 'protected' | 'private') ['read'] ['write']
#
#
but can't be because that would create undesirable reserved words!
exec_stmt: 'exec' expr ['in' test [',' test]]
compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef
...
...
Include/accessobject.h
View file @
0dfcf753
...
...
@@ -28,6 +28,10 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
/* This object type is no longer supported */
#ifdef SUPPORT_OBSOLETE_ACCESS
/* Access object interface */
/* Access mode bits (note similarity with UNIX permissions) */
...
...
@@ -60,6 +64,8 @@ int PyAccess_HasValue Py_PROTO((PyObject *));
extern
DL_IMPORT
(
PyTypeObject
)
PyAnyNumber_Type
,
PyAnySequence_Type
,
PyAnyMapping_Type
;
#endif
/* !SUPPORT_OBSOLETE_ACCESS */
#ifdef __cplusplus
}
#endif
...
...
Include/graminit.h
View file @
0dfcf753
...
...
@@ -21,38 +21,36 @@
#define import_stmt 276
#define dotted_name 277
#define global_stmt 278
#define access_stmt 279
#define accesstype 280
#define exec_stmt 281
#define compound_stmt 282
#define if_stmt 283
#define while_stmt 284
#define for_stmt 285
#define try_stmt 286
#define except_clause 287
#define suite 288
#define test 289
#define and_test 290
#define not_test 291
#define comparison 292
#define comp_op 293
#define expr 294
#define xor_expr 295
#define and_expr 296
#define shift_expr 297
#define arith_expr 298
#define term 299
#define factor 300
#define power 301
#define atom 302
#define lambdef 303
#define trailer 304
#define subscriptlist 305
#define subscript 306
#define sliceop 307
#define exprlist 308
#define testlist 309
#define dictmaker 310
#define classdef 311
#define arglist 312
#define argument 313
#define exec_stmt 279
#define compound_stmt 280
#define if_stmt 281
#define while_stmt 282
#define for_stmt 283
#define try_stmt 284
#define except_clause 285
#define suite 286
#define test 287
#define and_test 288
#define not_test 289
#define comparison 290
#define comp_op 291
#define expr 292
#define xor_expr 293
#define and_expr 294
#define shift_expr 295
#define arith_expr 296
#define term 297
#define factor 298
#define power 299
#define atom 300
#define lambdef 301
#define trailer 302
#define subscriptlist 303
#define subscript 304
#define sliceop 305
#define exprlist 306
#define testlist 307
#define dictmaker 308
#define classdef 309
#define arglist 310
#define argument 311
Objects/accessobject.c
View file @
0dfcf753
...
...
@@ -22,6 +22,8 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
#ifdef SUPPORT_OBSOLETE_ACCESS
/* This object type is no longer supported */
/* Access object implementation */
/* XXX TO DO LIST
...
...
@@ -358,3 +360,5 @@ typeobject Anymappingtype = {
0
,
/*ob_size*/
"*mapping*"
,
/*tp_name*/
};
#endif
/* SUPPORT_OBSOLETE_ACCESS */
Objects/classobject.c
View file @
0dfcf753
...
...
@@ -37,8 +37,10 @@ newclassobject(bases, dict, name)
object
*
dict
;
object
*
name
;
/* String; NULL if unknown */
{
#ifdef SUPPORT_OBSOLETE_ACCESS
int
pos
;
object
*
key
,
*
value
;
#endif
classobject
*
op
,
*
dummy
;
static
object
*
getattrstr
,
*
setattrstr
,
*
delattrstr
;
if
(
dictlookup
(
dict
,
"__doc__"
)
==
NULL
)
{
...
...
@@ -73,11 +75,13 @@ newclassobject(bases, dict, name)
XINCREF
(
op
->
cl_getattr
);
XINCREF
(
op
->
cl_setattr
);
XINCREF
(
op
->
cl_delattr
);
#ifdef SUPPORT_OBSOLETE_ACCESS
pos
=
0
;
while
(
mappinggetnext
(
dict
,
&
pos
,
&
key
,
&
value
))
{
if
(
is_accessobject
(
value
))
setaccessowner
(
value
,
(
object
*
)
op
);
}
#endif
return
(
object
*
)
op
;
}
...
...
@@ -151,12 +155,14 @@ class_getattr(op, name)
err_setval
(
AttributeError
,
name
);
return
NULL
;
}
#ifdef SUPPORT_OBSOLETE_ACCESS
if
(
is_accessobject
(
v
))
{
v
=
getaccessvalue
(
v
,
getowner
());
if
(
v
==
NULL
)
return
NULL
;
}
else
#endif
INCREF
(
v
);
if
(
is_funcobject
(
v
))
{
object
*
w
=
newinstancemethodobject
(
v
,
(
object
*
)
NULL
,
...
...
@@ -173,7 +179,9 @@ class_setattr(op, name, v)
object
*
name
;
object
*
v
;
{
#ifdef SUPPORT_OBSOLETE_ACCESS
object
*
ac
;
#endif
char
*
sname
=
getstringvalue
(
name
);
if
(
sname
[
0
]
==
'_'
&&
sname
[
1
]
==
'_'
)
{
int
n
=
getstringsize
(
name
);
...
...
@@ -187,9 +195,11 @@ class_setattr(op, name, v)
"classes are read-only in restricted mode"
);
return
-
1
;
}
#ifdef SUPPORT_OBSOLETE_ACCESS
ac
=
mappinglookup
(
op
->
cl_dict
,
name
);
if
(
ac
!=
NULL
&&
is_accessobject
(
ac
))
return
setaccessvalue
(
ac
,
getowner
(),
v
);
#endif
if
(
v
==
NULL
)
{
int
rv
=
mappingremove
(
op
->
cl_dict
,
name
);
if
(
rv
<
0
)
...
...
@@ -260,6 +270,7 @@ issubclass(class, base)
/* Instance objects */
#ifdef SUPPORT_OBSOLETE_ACCESS
static
int
addaccess
(
class
,
inst
)
classobject
*
class
;
...
...
@@ -295,6 +306,7 @@ addaccess(class, inst)
}
return
0
;
}
#endif
object
*
newinstanceobject
(
class
,
arg
,
kw
)
...
...
@@ -315,8 +327,11 @@ newinstanceobject(class, arg, kw)
INCREF
(
class
);
inst
->
in_class
=
(
classobject
*
)
class
;
inst
->
in_dict
=
newdictobject
();
if
(
inst
->
in_dict
==
NULL
||
addaccess
((
classobject
*
)
class
,
inst
)
!=
0
)
{
if
(
inst
->
in_dict
==
NULL
#ifdef SUPPORT_OBSOLETE_ACCESS
||
addaccess
((
classobject
*
)
class
,
inst
)
!=
0
#endif
)
{
DECREF
(
inst
);
return
NULL
;
}
...
...
@@ -382,8 +397,12 @@ instance_dealloc(inst)
if
((
del
=
instance_getattr1
(
inst
,
delstr
))
!=
NULL
)
{
object
*
res
=
call_object
(
del
,
(
object
*
)
NULL
);
DECREF
(
del
);
XDECREF
(
res
);
/* XXX If __del__ raised an exception, it is ignored! */
if
(
res
==
NULL
)
{
writestring
(
"exception in __del__ method ignored
\n
"
,
sysget
(
"stdout"
));
}
else
DECREF
(
res
);
}
/* Restore the saved exception and undo the temporary revival */
err_restore
(
error_type
,
error_value
,
error_traceback
);
...
...
@@ -438,12 +457,14 @@ instance_getattr1(inst, name)
return
NULL
;
}
}
#ifdef SUPPORT_OBSOLETE_ACCESS
if
(
is_accessobject
(
v
))
{
v
=
getaccessvalue
(
v
,
getowner
());
if
(
v
==
NULL
)
return
NULL
;
}
else
#endif
INCREF
(
v
);
if
(
class
!=
NULL
)
{
if
(
is_funcobject
(
v
))
{
...
...
@@ -492,10 +513,12 @@ instance_setattr1(inst, name, v)
object
*
name
;
object
*
v
;
{
#ifdef SUPPORT_OBSOLETE_ACCESS
object
*
ac
;
ac
=
mappinglookup
(
inst
->
in_dict
,
name
);
if
(
ac
!=
NULL
&&
is_accessobject
(
ac
))
return
setaccessvalue
(
ac
,
getowner
(),
v
);
#endif
if
(
v
==
NULL
)
{
int
rv
=
mappingremove
(
inst
->
in_dict
,
name
);
if
(
rv
<
0
)
...
...
Objects/moduleobject.c
View file @
0dfcf753
...
...
@@ -127,9 +127,11 @@ module_getattr(m, name)
if
(
res
==
NULL
)
err_setstr
(
AttributeError
,
name
);
else
{
#ifdef SUPPORT_OBSOLETE_ACCESS
if
(
is_accessobject
(
res
))
res
=
getaccessvalue
(
res
,
getglobals
());
else
#endif
INCREF
(
res
);
}
return
res
;
...
...
@@ -141,14 +143,18 @@ module_setattr(m, name, v)
char
*
name
;
object
*
v
;
{
#ifdef SUPPORT_OBSOLETE_ACCESS
object
*
ac
;
#endif
if
(
name
[
0
]
==
'_'
&&
strcmp
(
name
,
"__dict__"
)
==
0
)
{
err_setstr
(
TypeError
,
"read-only special attribute"
);
return
-
1
;
}
#ifdef SUPPORT_OBSOLETE_ACCESS
ac
=
dictlookup
(
m
->
md_dict
,
name
);
if
(
ac
!=
NULL
&&
is_accessobject
(
ac
))
return
setaccessvalue
(
ac
,
getglobals
(),
v
);
#endif
if
(
v
==
NULL
)
{
int
rv
=
dictremove
(
m
->
md_dict
,
name
);
if
(
rv
<
0
)
...
...
Python/ceval.c
View file @
0dfcf753
...
...
@@ -95,7 +95,9 @@ static int cmp_member PROTO((object *, object *));
static
object
*
cmp_outcome
PROTO
((
int
,
object
*
,
object
*
));
static
int
import_from
PROTO
((
object
*
,
object
*
,
object
*
));
static
object
*
build_class
PROTO
((
object
*
,
object
*
,
object
*
));
#ifdef SUPPORT_OBSOLETE_ACCESS
static
int
access_statement
PROTO
((
object
*
,
object
*
,
frameobject
*
));
#endif
static
int
exec_statement
PROTO
((
object
*
,
object
*
,
object
*
));
static
object
*
find_from_args
PROTO
((
frameobject
*
,
int
));
...
...
@@ -324,7 +326,9 @@ eval_code2(co, globals, locals,
register
frameobject
*
f
;
/* Current frame */
register
object
**
fastlocals
;
object
*
retval
;
/* Return value */
#ifdef SUPPORT_OBSOLETE_ACCESS
int
defmode
=
0
;
/* Default access mode for new variables */
#endif
#ifdef LLTRACE
int
lltrace
;
#endif
...
...
@@ -1082,6 +1086,7 @@ eval_code2(co, globals, locals,
err_setstr
(
SystemError
,
"no locals"
);
break
;
}
#ifdef SUPPORT_OBSOLETE_ACCESS
u
=
dict2lookup
(
x
,
w
);
if
(
u
==
NULL
)
{
if
(
defmode
!=
0
)
{
...
...
@@ -1103,6 +1108,7 @@ eval_code2(co, globals, locals,
DECREF
(
v
);
break
;
}
#endif
err
=
dict2insert
(
x
,
w
,
v
);
DECREF
(
v
);
break
;
...
...
@@ -1113,12 +1119,14 @@ eval_code2(co, globals, locals,
err_setstr
(
SystemError
,
"no locals"
);
break
;
}
#ifdef SUPPORT_OBSOLETE_ACCESS
u
=
dict2lookup
(
x
,
w
);
if
(
u
!=
NULL
&&
is_accessobject
(
u
))
{
err
=
setaccessvalue
(
u
,
x
,
(
object
*
)
NULL
);
break
;
}
#endif
if
((
err
=
dict2remove
(
x
,
w
))
!=
0
)
err_setval
(
NameError
,
w
);
break
;
...
...
@@ -1196,6 +1204,7 @@ eval_code2(co, globals, locals,
case
STORE_GLOBAL
:
w
=
GETNAMEV
(
oparg
);
v
=
POP
();
#ifdef SUPPORT_OBSOLETE_ACCESS
if
(
f
->
f_locals
!=
NULL
)
{
u
=
dict2lookup
(
f
->
f_locals
,
w
);
if
(
u
!=
NULL
&&
is_accessobject
(
u
))
{
...
...
@@ -1205,12 +1214,14 @@ eval_code2(co, globals, locals,
break
;
}
}
#endif
err
=
dict2insert
(
f
->
f_globals
,
w
,
v
);
DECREF
(
v
);
break
;
case
DELETE_GLOBAL
:
w
=
GETNAMEV
(
oparg
);
#ifdef SUPPORT_OBSOLETE_ACCESS
if
(
f
->
f_locals
!=
NULL
)
{
u
=
dict2lookup
(
f
->
f_locals
,
w
);
if
(
u
!=
NULL
&&
is_accessobject
(
u
))
{
...
...
@@ -1219,6 +1230,7 @@ eval_code2(co, globals, locals,
break
;
}
}
#endif
if
((
err
=
dict2remove
(
f
->
f_globals
,
w
))
!=
0
)
err_setval
(
NameError
,
w
);
break
;
...
...
@@ -1248,12 +1260,14 @@ eval_code2(co, globals, locals,
}
}
}
#ifdef SUPPORT_OBSOLETE_ACCESS
if
(
is_accessobject
(
x
))
{
x
=
getaccessvalue
(
x
,
f
->
f_globals
/* XXX */
);
if
(
x
==
NULL
)
break
;
}
else
#endif
INCREF
(
x
);
PUSH
(
x
);
break
;
...
...
@@ -1269,12 +1283,14 @@ eval_code2(co, globals, locals,
break
;
}
}
#ifdef SUPPORT_OBSOLETE_ACCESS
if
(
is_accessobject
(
x
))
{
x
=
getaccessvalue
(
x
,
f
->
f_globals
);
if
(
x
==
NULL
)
break
;
}
else
#endif
INCREF
(
x
);
PUSH
(
x
);
break
;
...
...
@@ -1310,28 +1326,33 @@ eval_code2(co, globals, locals,
oparg
));
break
;
}
#ifdef SUPPORT_OBSOLETE_ACCESS
if
(
is_accessobject
(
x
))
{
x
=
getaccessvalue
(
x
,
f
->
f_locals
);
if
(
x
==
NULL
)
break
;
}
else
#endif
INCREF
(
x
);
PUSH
(
x
);
break
;
case
STORE_FAST
:
v
=
POP
();
#ifdef SUPPORT_OBSOLETE_ACCESS
w
=
GETLOCAL
(
oparg
);
if
(
w
!=
NULL
&&
is_accessobject
(
w
))
{
err
=
setaccessvalue
(
w
,
f
->
f_locals
,
v
);
DECREF
(
v
);
break
;
}
#endif
SETLOCAL
(
oparg
,
v
);
break
;
case
DELETE_FAST
:
#ifdef SUPPORT_OBSOLETE_ACCESS
x
=
GETLOCAL
(
oparg
);
if
(
x
==
NULL
)
{
err_setval
(
NameError
,
...
...
@@ -1344,6 +1365,7 @@ eval_code2(co, globals, locals,
(
object
*
)
NULL
);
break
;
}
#endif
SETLOCAL
(
oparg
,
NULL
);
break
;
...
...
@@ -1439,6 +1461,7 @@ eval_code2(co, globals, locals,
locals_2_fast
(
f
,
0
);
break
;
#ifdef SUPPORT_OBSOLETE_ACCESS
case
ACCESS_MODE
:
v
=
POP
();
w
=
GETNAMEV
(
oparg
);
...
...
@@ -1448,6 +1471,7 @@ eval_code2(co, globals, locals,
err
=
access_statement
(
w
,
v
,
f
);
DECREF
(
v
);
break
;
#endif
case
JUMP_FORWARD
:
JUMPBY
(
oparg
);
...
...
@@ -2826,6 +2850,7 @@ import_from(locals, v, name)
if
(
!
is_stringobject
(
name
)
||
getstringvalue
(
name
)[
0
]
==
'_'
)
continue
;
#ifdef SUPPORT_OBSOLETE_ACCESS
if
(
is_accessobject
(
value
))
{
value
=
getaccessvalue
(
value
,
(
object
*
)
NULL
);
if
(
value
==
NULL
)
{
...
...
@@ -2834,6 +2859,7 @@ import_from(locals, v, name)
}
}
else
#endif
INCREF
(
value
);
err
=
dict2insert
(
locals
,
name
,
value
);
DECREF
(
value
);
...
...
@@ -2902,6 +2928,7 @@ build_class(methods, bases, name)
return
newclassobject
(
bases
,
methods
,
name
);
}
#ifdef SUPPORT_OBSOLETE_ACCESS
static
int
access_statement
(
name
,
vmode
,
f
)
object
*
name
;
...
...
@@ -2931,6 +2958,7 @@ access_statement(name, vmode, f)
locals_2_fast
(
f
,
0
);
return
ret
;
}
#endif
static
int
exec_statement
(
prog
,
globals
,
locals
)
...
...
Python/compile.c
View file @
0dfcf753
...
...
@@ -1792,12 +1792,12 @@ com_newlocal(c, name)
#define strequ(a, b) (strcmp((a), (b)) == 0)
#ifdef SUPPORT_OBSOLETE_ACCESS
static
void
com_access_stmt
(
c
,
n
)
struct
compiling
*
c
;
node
*
n
;
{
#if 0
int
i
,
j
,
k
,
mode
,
imode
;
object
*
vmode
;
REQ
(
n
,
access_stmt
);
...
...
@@ -1848,8 +1848,8 @@ com_access_stmt(c, n)
com_addoparg
(
c
,
LOAD_CONST
,
imode
);
com_addopname
(
c
,
ACCESS_MODE
,
CHILD
(
n
,
i
));
}
#endif
}
#endif
static
void
com_exec_stmt
(
c
,
n
)
...
...
@@ -2421,9 +2421,11 @@ com_node(c, n)
case
global_stmt
:
com_global_stmt
(
c
,
n
);
break
;
#ifdef SUPPORT_OBSOLETE_ACCESS
case
access_stmt
:
com_access_stmt
(
c
,
n
);
break
;
#endif
case
exec_stmt
:
com_exec_stmt
(
c
,
n
);
break
;
...
...
Python/graminit.c
View file @
0dfcf753
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment