Skip to content

test_xmlrpc fails with non-ascii path #51957

Closed

Description

@florentx
mannequin
BPO 7708
Nosy @vstinner, @ezio-melotti, @florentx
Files
  • xmlrpc_server_ascii_traceback.patch
  • 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-01-31.02:31:19.579>
    created_at = <Date 2010-01-15.17:20:36.875>
    labels = ['type-bug', 'tests']
    title = 'test_xmlrpc fails with non-ascii path'
    updated_at = <Date 2010-01-31.02:31:19.578>
    user = 'https://github.com/florentx'

    bugs.python.org fields:

    activity = <Date 2010-01-31.02:31:19.578>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-01-31.02:31:19.579>
    closer = 'vstinner'
    components = ['Tests']
    creation = <Date 2010-01-15.17:20:36.875>
    creator = 'flox'
    dependencies = []
    files = ['15958']
    hgrepos = []
    issue_num = 7708
    keywords = ['patch', 'buildbot']
    message_count = 3.0
    messages = ['97827', '98091', '98592']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'ezio.melotti', 'flox']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'test needed'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue7708'
    versions = ['Python 3.2']

    Activity

    1. florentx commented on Jan 15, 2010

      florentxmannequin
      MannequinAuthor

      Another buildbot failure (repeated on AMD64 Ubuntu wide).

      test_xmlrpc
      ----------------------------------------

      Exception happened during processing of request from ('127.0.0.1', 59299)
      Traceback (most recent call last):
        File "/home/buildbot/cpython-ucs4-nonascii-€/3.x.pitrou-ubuntu-wide/build/Lib/xmlrpc/server.py", line 474, in do_POST
          size_remaining = int(self.headers["content-length"])
      ValueError: invalid literal for int() with base 10: 'I am broken'
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "/home/buildbot/cpython-ucs4-nonascii-€/3.x.pitrou-ubuntu-wide/build/Lib/socketserver.py", line 282, in _handle_request_noblock
          self.process_request(request, client_address)
        File "/home/buildbot/cpython-ucs4-nonascii-€/3.x.pitrou-ubuntu-wide/build/Lib/socketserver.py", line 308, in process_request
          self.finish_request(request, client_address)
        File "/home/buildbot/cpython-ucs4-nonascii-€/3.x.pitrou-ubuntu-wide/build/Lib/socketserver.py", line 321, in finish_request
          self.RequestHandlerClass(request, client_address, self)
        File "/home/buildbot/cpython-ucs4-nonascii-€/3.x.pitrou-ubuntu-wide/build/Lib/socketserver.py", line 637, in __init__
          self.handle()
        File "/home/buildbot/cpython-ucs4-nonascii-€/3.x.pitrou-ubuntu-wide/build/Lib/http/server.py", line 360, in handle
          self.handle_one_request()
        File "/home/buildbot/cpython-ucs4-nonascii-€/3.x.pitrou-ubuntu-wide/build/Lib/http/server.py", line 348, in handle_one_request
          method()
        File "/home/buildbot/cpython-ucs4-nonascii-€/3.x.pitrou-ubuntu-wide/build/Lib/xmlrpc/server.py", line 502, in do_POST
          self.send_header("X-traceback", traceback.format_exc())
        File "/home/buildbot/cpython-ucs4-nonascii-€/3.x.pitrou-ubuntu-wide/build/Lib/http/server.py", line 418, in send_header
          self.wfile.write(("%s: %s\r\n" % (keyword, value)).encode('ASCII', 'strict'))
      UnicodeEncodeError: 'ascii' codec can't encode character '\u20ac' in position 93: ordinal not in range(128)
    2. added
      testsTests in the Lib/test dir
      type-bugAn unexpected behavior, bug, or error
      on Jan 15, 2010
    3. vstinner commented on Jan 21, 2010

      @vstinner
      Member

      SimpleXMLRPCRequestHandler.do_POST() writes the traceback in the HTTP header "X-traceback". But an HTTP header value is ASCII only, whereas a traceback can contain any character (eg. an non-ASCII character from a directory name for this issue).

      A simple fix would be to use the ASCII charset with the backslashreplace error handler. Attached patch uses:

         trace = str(trace.encode('ASCII', 'backslashreplace'), 'ASCII')

      Is there an easier method to escape non-ASCII characters without double conversion (unicode->bytes and bytes->unicode)?

    4. vstinner commented on Jan 31, 2010

      @vstinner
      Member

      This issue is a duplicate of bpo-7606.

    5. 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

      testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions