Skip to content

Expose callback API in readline module #44935

Closed

Description

@strank
mannequin
BPO 1713877
Nosy @birkenfeld, @tiran
Superseder
  • bpo-1744456: Expose non-blocking callbackAPI in readline module
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2010-07-10.10:26:25.297>
    created_at = <Date 2007-05-06.18:07:07.000>
    labels = ['type-feature', 'library']
    title = 'Expose callback API in readline module'
    updated_at = <Date 2010-07-10.10:26:25.291>
    user = 'https://bugs.python.org/strank'

    bugs.python.org fields:

    activity = <Date 2010-07-10.10:26:25.291>
    actor = 'georg.brandl'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-07-10.10:26:25.297>
    closer = 'georg.brandl'
    components = ['Library (Lib)']
    creation = <Date 2007-05-06.18:07:07.000>
    creator = 'strank'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 1713877
    keywords = []
    message_count = 5.0
    messages = ['55104', '59362', '59435', '109839', '109842']
    nosy_count = 4.0
    nosy_names = ['georg.brandl', 'christian.heimes', 'strank', 'BreamoreBoy']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = None
    status = 'closed'
    superseder = '1744456'
    type = 'enhancement'
    url = 'https://bugs.python.org/issue1713877'
    versions = ['Python 3.1', 'Python 2.7']

    Activity

    1. strank commented on May 6, 2007

      strankmannequin
      MannequinAuthor

      This is a request to expose the callback API_ of GNU readline in the readline module in the Python library.

      .. _callback API: http://cnswww.cns.cwru.edu/php/chet/readline/readline.html#SEC41

      This interface is suitable for asynchronous use, such as with twisted.

      It is possible to expose the functions on Unix with ctypes::

        import readline
        import ctypes
      
        rl_lib = ctypes.cdll.LoadLibrary("libreadline.so.5")
      
        readline.callback_handler_remove = rl_lib.rl_callback_handler_remove
        readline.callback_read_char = rl_lib.rl_callback_read_char
        # the callback needs special treatment:
        rlcallbackfunctype = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_char_p)
        def setcallbackfunc(prompt, thefunc):
            rl_lib.rl_callback_handler_install(prompt, rlcallbackfunctype(thefunc))
        readline.callback_handler_install = setcallbackfunc

      but it would be much better to expose them "officially".

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-featureA feature request or enhancement
      on May 6, 2007
    3. tiran commented on Jan 6, 2008

      @tiran
      Member

      A patch is always welcome

    4. strank commented on Jan 7, 2008

      strankmannequin
      MannequinAuthor

      I am pretty sure I posted a patch in the sf patch tracker... oh yes,
      here it is: http://bugs.python.org/issue1744456

      I think it still needs some work if you want to make it impossible for
      users of the API to wreck the interactive prompt. If this possibility is
      considered ok (it does not make sense to use the callback api from the
      interactive prompt anyway), I think it's ok.

      But someone with more readline experience should probably look at it... :-)

    5. BreamoreBoy commented on Jul 10, 2010

      BreamoreBoymannequin
      Mannequin

      Can this be closed as a duplicate as bpo-1744456 has a patch?

    6. birkenfeld commented on Jul 10, 2010

      @birkenfeld
      Member

      Yes, that makes sense (the two issues come from the SourceForge era, where bugs and patches had different trackers).

    7. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions