console.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:isf 作者: w3h 项目源码 文件源码
def install_readline(hook):
    '''Set up things for the interpreter to call 
    our function like GNU readline.'''
    global readline_hook, readline_ref
    # save the hook so the wrapper can call it
    readline_hook = hook
    # get the address of PyOS_ReadlineFunctionPointer so we can update it
    PyOS_RFP = c_void_p.from_address(Console.GetProcAddress(sys.dllhandle,
                           "PyOS_ReadlineFunctionPointer".encode('ascii')))
    # save a reference to the generated C-callable so it doesn't go away
    if sys.version < '2.3':
        readline_ref = HOOKFUNC22(hook_wrapper)
    else:
        readline_ref = HOOKFUNC23(hook_wrapper_23)
    # get the address of the function
    func_start = c_void_p.from_address(addressof(readline_ref)).value
    # write the function address into PyOS_ReadlineFunctionPointer
    PyOS_RFP.value = func_start
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号