Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_xmlrpc fails with non-ascii path #51957

Closed
florentx mannequin opened this issue Jan 15, 2010 · 3 comments
Closed

test_xmlrpc fails with non-ascii path #51957

florentx mannequin opened this issue Jan 15, 2010 · 3 comments
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@florentx
Copy link
Mannequin

florentx mannequin commented Jan 15, 2010

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']

    @florentx
    Copy link
    Mannequin Author

    florentx mannequin commented Jan 15, 2010

    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)

    @florentx florentx mannequin added tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels Jan 15, 2010
    @vstinner
    Copy link
    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)?

    @vstinner
    Copy link
    Member

    This issue is a duplicate of bpo-7606.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant