This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: String with encode causing addition of 'b' in the beginning
Type: behavior Stage: resolved
Components: Versions: Python 3.8
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: SilentGhost, Srinivas Sampath
Priority: normal Keywords:

Created on 2020-06-26 05:07 by Srinivas Sampath, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ex_12_informatica.py Srinivas Sampath, 2020-06-26 05:07
Messages (3)
msg372408 - (view) Author: Srinivas Sampath (Srinivas Sampath) Date: 2020-06-26 05:07
I am trying to run the attached code.  when hard-coding the string in the URL and doing .encode, then the code works.  However since i am requesting user input, i cannot hard-code and the code seem to add the 'b' character in the beginning causing the request to fail with output like this

Enter Hostname    :
hostname cannot be empty
Enter Port Number :
before invokingGET http://psglx73:24670/coreservices/DomainService HTTP/1.1


after encode
b'GET http://psglx73:24670/coreservices/DomainService HTTP/1.1\r\n\r\n'
HTTP/1.1 400 Bad Request
Transfer-Encoding: chunked
Date: Fri, 26 Jun 2020 05:06:21 GMT
Connection: close
Server: Informatica

0

i cannot pass without .encode to the socket communication.  is this reported problem ?
msg372410 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2020-06-26 05:37
Your request is likely failing for entirely different reasons.

What you've done is encoded a str object into bytes object, which is represented with as literal using b prefix. It isn't being sent over the socket.
msg372411 - (view) Author: Srinivas Sampath (Srinivas Sampath) Date: 2020-06-26 05:53
if you look at my code, couple of lines below the print, i am actually
doing the send over the socket.  It took me awhile to figure out why the
socket is failing.  I understand that the byte array is represented with a
'b' infront as part of encode function being called, and troubleshooting
the code it was the first obvious difference that made me thing it was an
issue.

Thanks for your help

On Thu, Jun 25, 2020 at 10:37 PM SilentGhost <report@bugs.python.org> wrote:

>
> SilentGhost <ghost.adh@runbox.com> added the comment:
>
> Your request is likely failing for entirely different reasons.
>
> What you've done is encoded a str object into bytes object, which is
> represented with as literal using b prefix. It isn't being sent over the
> socket.
>
> ----------
> nosy: +SilentGhost
> resolution:  -> not a bug
> stage:  -> resolved
> status: open -> closed
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue41124>
> _______________________________________
>

-- 
With Regards,

Srinivas Sampath
History
Date User Action Args
2022-04-11 14:59:32adminsetgithub: 85296
2020-06-26 05:53:12Srinivas Sampathsetmessages: + msg372411
2020-06-26 05:37:07SilentGhostsetstatus: open -> closed

nosy: + SilentGhost
messages: + msg372410

resolution: not a bug
stage: resolved
2020-06-26 05:07:19Srinivas Sampathcreate