403Webshell
Server IP : 217.160.0.212  /  Your IP : 216.73.216.141
Web Server : Apache
System : Linux www 6.18.51-i1-ampere #1196 SMP Fri Sep 11 20:43:55 CEST 2026 aarch64
User : sws1073854427 ( 1073854427)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/pythran/transformations/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/pythran/transformations/expand_builtins.py
""" ExpandBuiltins replaces builtins by their full paths. """

from pythran.analyses import Globals, Locals
from pythran.passmanager import Transformation
from pythran.syntax import PythranSyntaxError
from pythran.tables import MODULES

import gast as ast


class ExpandBuiltins(Transformation):

    """
    Expands all builtins into full paths.

    >>> import gast as ast
    >>> from pythran import passmanager, backend
    >>> node = ast.parse("def foo(): return list()")
    >>> pm = passmanager.PassManager("test")
    >>> _, node = pm.apply(ExpandBuiltins, node)
    >>> print(pm.dump(backend.Python, node))
    def foo():
        return builtins.list()
    """

    def __init__(self):
        Transformation.__init__(self, Locals, Globals)

    def visit_NameConstant(self, node):
        self.update = True
        return ast.Attribute(
            ast.Name('builtins', ast.Load(), None, None),
            str(node.value),
            ast.Load())

    def visit_Name(self, node):
        s = node.id
        if(isinstance(node.ctx, ast.Load) and
           s not in self.locals[node] and
           s not in self.globals and
           s in MODULES['builtins']):
            if s == 'getattr':
                raise PythranSyntaxError("You fool! Trying a getattr?", node)
            self.update = True
            return ast.Attribute(
                ast.Name('builtins', ast.Load(), None, None),
                s,
                node.ctx)
        else:
            return node

Youez - 2016 - github.com/yon3zu
LinuXploit