Skip to content

Commit

Permalink
Merge branch 'Python3_update' into class_definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
sallner committed May 4, 2017
2 parents 4f60606 + d4a939d commit 6ce4c5a
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/RestrictedPython/MutatingWalker.py
Expand Up @@ -13,6 +13,16 @@

from compiler import ast

import warnings


warnings.warn(
"This Module (RestrictedPython.MutatingWalker) is deprecated"
"and will be gone soon.",
category=PendingDeprecationWarning,
stacklevel=1
)


ListType = type([])
TupleType = type(())
Expand Down
33 changes: 33 additions & 0 deletions src/RestrictedPython/RCompile.py
Expand Up @@ -30,6 +30,15 @@
from RestrictionMutator import RestrictionMutator

import MutatingWalker
import warnings


warnings.warn(
"This Module (RestrictedPython.RCompile) is deprecated"
"and will be gone soon.",
category=PendingDeprecationWarning,
stacklevel=1
)


def niceParse(source, filename, mode):
Expand Down Expand Up @@ -101,24 +110,48 @@ def compile_restricted_function(p, body, name, filename, globalize=None):
treated as globals (code is generated as if each name in the list
appeared in a global statement at the top of the function).
"""
warnings.warn(
"RestrictedPython.RCompile.compile_restricted_function is deprecated"
"use RestrictedPython.compile_restricted_function instead.",
category=PendingDeprecationWarning,
stacklevel=1
)
gen = RFunction(p, body, name, filename, globalize)
return compileAndTuplize(gen)


def compile_restricted_exec(source, filename='<string>'):
"""Compiles a restricted code suite."""
warnings.warn(
"RestrictedPython.RCompile.compile_restricted_exec is deprecated"
"use RestrictedPython.compile_restricted_exec instead.",
category=PendingDeprecationWarning,
stacklevel=1
)
gen = RModule(source, filename)
return compileAndTuplize(gen)


def compile_restricted_eval(source, filename='<string>'):
"""Compiles a restricted expression."""
warnings.warn(
"RestrictedPython.RCompile.compile_restricted_eval is deprecated"
"use RestrictedPython.compile_restricted_eval instead.",
category=PendingDeprecationWarning,
stacklevel=1
)
gen = RExpression(source, filename)
return compileAndTuplize(gen)


def compile_restricted(source, filename, mode):
"""Replacement for the builtin compile() function."""
warnings.warn(
"RestrictedPython.RCompile.compile_restricted is deprecated"
"use RestrictedPython.compile_restricted instead.",
category=PendingDeprecationWarning,
stacklevel=1
)
if mode == "single":
gen = RInteractive(source, filename)
elif mode == "exec":
Expand Down
10 changes: 10 additions & 0 deletions src/RestrictedPython/RestrictionMutator.py
Expand Up @@ -23,6 +23,16 @@
from compiler.consts import OP_DELETE
from compiler.transformer import parse

import warnings


warnings.warn(
"This Module (RestrictedPython.RestrictionMutator) is deprecated"
"and will be gone soon.",
category=PendingDeprecationWarning,
stacklevel=1
)


# These utility functions allow us to generate AST subtrees without
# line number attributes. These trees can then be inserted into other
Expand Down
9 changes: 9 additions & 0 deletions src/RestrictedPython/SelectCompiler.py
Expand Up @@ -25,3 +25,12 @@

# Use the compiler from the standard library.
import compiler
import warnings


warnings.warn(
"This Module (RestrictedPython.SelectCompiler) is deprecated"
"and will be gone soon.",
category=PendingDeprecationWarning,
stacklevel=1
)
6 changes: 3 additions & 3 deletions src/RestrictedPython/__init__.py
Expand Up @@ -17,7 +17,7 @@
# as this file should be logically grouped imports


# Old API --> Old Import Locations
# Old API --> Old Import Locations (Deprecated)
# from RestrictedPython.RCompile import compile_restricted
# from RestrictedPython.RCompile import compile_restricted_eval
# from RestrictedPython.RCompile import compile_restricted_exec
Expand All @@ -43,5 +43,5 @@
# Policy
from RestrictedPython.transformer import RestrictingNodeTransformer # isort:skip


# from RestrictedPython.Eval import RestrictionCapableEval
#
from RestrictedPython.Eval import RestrictionCapableEval
8 changes: 8 additions & 0 deletions src/RestrictedPython/tests/verify.py
Expand Up @@ -23,6 +23,7 @@

import dis
import types
import warnings


def verify(code):
Expand All @@ -31,6 +32,13 @@ def verify(code):
In particular, traverse into contained code objects in the
co_consts table.
"""
warnings.warn(
"RestrictedPython.test.verify is deprecated and will be gone soon."
"verify(<code>) tests on byte code level, which did not make sense"
"with new implementation which is Python Implementation independend.",
category=PendingDeprecationWarning,
stacklevel=1
)
verifycode(code)
for ob in code.co_consts:
if isinstance(ob, types.CodeType):
Expand Down

0 comments on commit 6ce4c5a

Please sign in to comment.