From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 43CA63858402 for ; Tue, 30 Nov 2021 12:15:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 43CA63858402 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-348-V4sLXRDSNS6yd5ojTRfCWg-1; Tue, 30 Nov 2021 07:15:19 -0500 X-MC-Unique: V4sLXRDSNS6yd5ojTRfCWg-1 Received: by mail-wm1-f70.google.com with SMTP id p12-20020a05600c1d8c00b0033a22e48203so12741844wms.6 for ; Tue, 30 Nov 2021 04:15:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=PvOwUU1OF/7xrJT4QonNrHI8YDHDQn3ZD5AdBmUG3T8=; b=xcMiRCfDwiDsgWQEs4KHhci9yroo4hszz810eaQNcYcAzLh0T5+fEc7nTXaYxyVW5+ 3HYCwIIYc9wmK8wGLF0sgvOZuNvrq5ABaqewOAt2Pl8NbHN+Lqx446Xn6lct7WxtPZmk Wh+Lt8Zn5NHqad2t5zOT78vaiDbfnje2hiMGnqz//80XhamUnaj19EKjH0EwCAJalsiZ yCseMRHzoDpKdhSY1KMs8xeepztOJU4n1KR8Q4s0svXpncOQCiM51PkxA+Dc6QObBj/G zxFzHABqghby/p8Yhmv2saPCifWk8A1bj2+DoA3d0PAAMSYW8wtgY8SifiwRFg2wf+0b H+LA== X-Gm-Message-State: AOAM531PUlq9tGFRchqKWgMskpNOYKn/KmF768NsGoTf5S/xv1S38hsw e9/biF92p58MuddWWVSagqzIStXwQP5FEKUYLH6CRYwICnNup+2tjZIZQXk6VT7aSjYo52QH/iO ShrG1n53odPjH3trYBangfw== X-Received: by 2002:a05:6000:cd:: with SMTP id q13mr40208759wrx.488.1638274518476; Tue, 30 Nov 2021 04:15:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJzdoRvwFDJ3vFPCR9Uh7JLwZifBafD2DYKzPhABAW6SsdlnA2JMH3HUwezTl5CaiWL+UVyhoA== X-Received: by 2002:a05:6000:cd:: with SMTP id q13mr40208729wrx.488.1638274518229; Tue, 30 Nov 2021 04:15:18 -0800 (PST) Received: from localhost (host86-134-238-138.range86-134.btcentralplus.com. [86.134.238.138]) by smtp.gmail.com with ESMTPSA id n13sm16707967wrt.44.2021.11.30.04.15.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 04:15:17 -0800 (PST) Date: Tue, 30 Nov 2021 12:15:16 +0000 From: Andrew Burgess To: Simon Marchi Cc: gdb-patches@sourceware.org Subject: Re: [PATCHv6 3/3] gdb/python: add gdb.RemoteTargetConnection.send_packet Message-ID: <20211130121516.GW2662946@redhat.com> References: <1ee3ff1661f4e29adb8cf1daf90f88bd7c282a77.1636997240.git.aburgess@redhat.com> <20211116124847.GJ2352@redhat.com> <30f85ce3-b785-d7e7-5356-30b8822225a4@simark.ca> MIME-Version: 1.0 In-Reply-To: <30f85ce3-b785-d7e7-5356-30b8822225a4@simark.ca> X-Operating-System: Linux/5.8.18-100.fc31.x86_64 (x86_64) X-Uptime: 12:14:54 up 11 days, 1:13, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Nov 2021 12:15:22 -0000 * Simon Marchi [2021-11-16 10:10:23 -0500]: > On 2021-11-16 7:48 a.m., Andrew Burgess via Gdb-patches wrote: > > Simon, Eli, > > > > Thanks for the feedback, I think I've addressed everything in this > > update. > > > > Simon, sorry for not quite getting your point the first time through. > > I believe that this revision should address your concerns. I have not > > been as restrictive as you suggested, but hopefully this should still > > be acceptable. > > > > So, you can still pass a string, but the documentation is specific > > that it must be possible to convert the string to a bytes object using > > the ascii codec. This allows for what I assume would be the most > > common use case: > > > > conn.send_packet("some_ascii_text") > > > > But if we revisit your example, we now get: > > > > res = conn.send_packet('X555555558028,4:\xff\x03\x02\xff') > > UnicodeEncodeError: 'ascii' codec can't encode character '\xff' in position 10: ordinal not in range(128) > > > > In which case, the solution is, as your suggest, to pass a bytes > > object: > > > > res = conn.send_packet(b'X555555558028,4:\xff\x03\x02\xff') > > print(res) > > b'OK' > > > > I've tested this code with Python 3.7 and Python 2.7 and it seems to > > work fine. I've extended the test to include your example and related > > cases, hopefully that should cover what I've said above. > > > > Let me know what you think, > > If I had done it myself, I would have accepted just "bytes" objects, to > be more straightforward in the implementation and the doc. But I am > still happy with what you have, the user won't have sneaky encoding > bugs. So, +1 from me. Thanks for all the reviewing. I've now pushed this series. Thanks, Andrew