• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(139)  |  Call(81)  |  Derive(0)  |  Import(58)
code(argcount, nlocals, stacksize, flags, codestring, constants, names,
      varnames, filename, name, firstlineno, lnotab[, freevars[, cellvars]])

Create a code object.  Not for the faint of heart.

src/p/y/pylibs-HEAD/optimise.py   pylibs(Download)
import sys
 
from opcode import opmap, HAVE_ARGUMENT, EXTENDED_ARG
from types import FunctionType, ClassType, CodeType
 
# ------------------------------------------------------------------------------
# some konstants
 
    codestr = ''.join(map(chr, newcode))
    codeobj = CodeType(
        co.co_argcount, co.co_nlocals, co.co_stacksize,
        co.co_flags, codestr, tuple(newconsts), co.co_names,
        co.co_varnames, co.co_filename, co.co_name,
        co.co_firstlineno, co.co_lnotab, co.co_freevars,

src/d/e/Dejavu-1.5.0/dejavu/codewalk.py   Dejavu(Download)
 
import operator
import sets
from types import CodeType, FunctionType, MethodType
 
from compiler.consts import *
CO_NOFREE = 0x0040
# CodeType(argcount, nlocals, stacksize, flags, codestring, constants,
#          names, varnames, filename, name, firstlineno,
#          lnotab[, freevars[, cellvars]])
_derefblock = CodeType(0, 0, 1, 3, ''.join(map(chr, _deref_bytecode)),
                       (None,), ('cell',), (), '', '', 2, '', ('cell',))
def deref_cell(cell):
    """Return the value of 'cell' (an object from a func_closure)."""
    def code_object(self):
        """Walk self and produce a new code object."""
        self.walk()
        codestr = ''.join(map(chr, self.newcode))
        return CodeType(self.co_argcount, self.co_nlocals, self.co_stacksize,
                        # Notice co_consts should *not* be safe_tupled.
                        self.co_flags, codestr, tuple(self.co_consts),
    def code_object(self):
        """Walk self and produce a new code object."""
        self.walk()
        codestr = ''.join(map(chr, self.newcode))
        # Assert CO_NOFREE, since all free vars should have been made constant.
        self.co_flags |= CO_NOFREE
        co = CodeType(self.co_argcount, self.co_nlocals, self.stack.maxsize,

src/p/y/pynomic-HEAD/jinja2/debug.py   pynomic(Download)
    :license: BSD.
"""
import sys
from types import CodeType
 
 
def translate_exception(exc_info):
            location = 'block "%s"' % function[6:]
        else:
            location = 'template'
        code = CodeType(0, code.co_nlocals, code.co_stacksize,
                        code.co_flags, code.co_code, code.co_consts,
                        code.co_names, code.co_varnames, filename,
                        location, code.co_firstlineno,

src/p/y/pylibs-HEAD/genshi/template/eval.py   pylibs(Download)
import __builtin__
 
from textwrap import dedent
from types import CodeType
 
from genshi.core import Markup
from genshi.template.astutil import ASTTransformer, ASTCodeGenerator, \
    def __setstate__(self, state):
        self.source = state['source']
        self.ast = state['ast']
        self.code = CodeType(0, *state['code'])
        self._globals = state['lookup'].globals
 
    def __eq__(self, other):
    try:
        # We'd like to just set co_firstlineno, but it's readonly. So we need
        # to clone the code object while adjusting the line number
        return CodeType(0, code.co_nlocals, code.co_stacksize,
                        code.co_flags | 0x0040, code.co_code, code.co_consts,
                        code.co_names, code.co_varnames, filename, name,
                        lineno, code.co_lnotab, (), ())

src/d/e/Dejavu-1.5.0/dejavu/logic.py   Dejavu(Download)
 
from compiler.consts import *
import sys
from types import CodeType, FunctionType
 
# Globals which assist in unpickling. If they're not present (can't be
# imported), that's OK--someone might want to build an app which
    # code(argcount, nlocals, stacksize, flags, codestring,
    #      constants, names, varnames,
    #      filename, name, firstlineno, lnotab[, freevars[, cellvars]])
    co = CodeType(1, 1, 2, 67, ''.join(map(chr, co)),
                  tuple(consts), tuple(names), ('x', ),
                  '', '<lambda>', 1, '')
    func = FunctionType(co, {})
    # code(argcount, nlocals, stacksize, flags, codestring,
    #      constants, names, varnames,
    #      filename, name, firstlineno, lnotab[, freevars[, cellvars]])
    co = CodeType(1, 1, 2, co_flags, ''.join(map(chr, co)),
                  consts, names, ('x',), '', '<lambda>', 1, '')
    func = FunctionType(co, {})
    return Expression(func, earlybind=False)

src/b/y/bytecode-hack-HEAD/bytecode_tracer/bytecode_tracer.py   bytecode-hack(Download)
import opcode
import os
import re
 
from types import CodeType, MethodType
 
import code_rewriting_importer
            new_consts.append(rewrite_lnotab(const))
        else:
            new_consts.append(const)
    return CodeType(code.co_argcount, code.co_nlocals, code.co_stacksize,
        code.co_flags, code.co_code, tuple(new_consts), code.co_names,
        code.co_varnames, code.co_filename, code.co_name, 0, new_lnotab,
        code.co_freevars, code.co_cellvars)

src/b/y/byteplay-HEAD/byteplay3.py   byteplay(Download)
import opcode
from sys import version_info
from dis import findlabels
from types import CodeType
class Opcode(int):__str__=__repr__=lambda s:opname[s]
opmap = {name.replace('+','_'):Opcode(code) for name,code in opcode.opmap.items()}
opname = {code:name for name,code in opmap.items()}
			if co_code[pos] in hasjrel:jump-=pos+3
			if jump>0xFFFF:raise NotImplementedError,"Extended jumps not implemented"
			arg+=jump&0xFF,jump>>8&0xFF
		return CodeType(co_argcount,self.kwonly,len(co_varnames),co_stacksize,co_flags,co_code%tuple(arg),tuple(co_consts),tuple(co_names),tuple(co_varnames),self.filename,self.name,self.firstlineno,co_lnotab,co_freevars,tuple(co_cellvars))
 

src/i/r/ironruby-HEAD/External.LCA_RESTRICTED/Languages/IronPython/27/Lib/new.py   ironruby(Download)
from types import MethodType as instancemethod
from types import ModuleType as module
 
from types import CodeType as code
 

src/i/r/ironruby-HEAD/External.LCA_RESTRICTED/Languages/CPython/27/Lib/new.py   ironruby(Download)
from types import MethodType as instancemethod
from types import ModuleType as module
 
from types import CodeType as code
 

src/j/y/jython-HEAD/sandbox/tobias/jython/CPythonLib/new.py   jython(Download)
 
# CodeType is not accessible in restricted execution mode
try:
    from types import CodeType as code
except ImportError:
    pass
 

  1 | 2 | 3 | 4 | 5 | 6  Next