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

String with encode causing addition of 'b' in the beginning #85296

Closed
SrinivasSampath mannequin opened this issue Jun 26, 2020 · 3 comments
Closed

String with encode causing addition of 'b' in the beginning #85296

SrinivasSampath mannequin opened this issue Jun 26, 2020 · 3 comments
Labels
3.8 only security fixes type-bug An unexpected behavior, bug, or error

Comments

@SrinivasSampath
Copy link
Mannequin

SrinivasSampath mannequin commented Jun 26, 2020

BPO 41124
Files
  • ex_12_informatica.py
  • 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 2020-06-26.05:37:07.801>
    created_at = <Date 2020-06-26.05:07:19.071>
    labels = ['invalid', 'type-bug', '3.8']
    title = "String with encode causing addition of 'b' in the beginning"
    updated_at = <Date 2020-06-26.05:53:12.923>
    user = 'https://bugs.python.org/SrinivasSampath'

    bugs.python.org fields:

    activity = <Date 2020-06-26.05:53:12.923>
    actor = 'Srinivas Sampath'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-06-26.05:37:07.801>
    closer = 'SilentGhost'
    components = []
    creation = <Date 2020-06-26.05:07:19.071>
    creator = 'Srinivas Sampath'
    dependencies = []
    files = ['49264']
    hgrepos = []
    issue_num = 41124
    keywords = []
    message_count = 3.0
    messages = ['372408', '372410', '372411']
    nosy_count = 2.0
    nosy_names = ['SilentGhost', 'Srinivas Sampath']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue41124'
    versions = ['Python 3.8']

    @SrinivasSampath
    Copy link
    Mannequin Author

    SrinivasSampath mannequin commented Jun 26, 2020

    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 ?

    @SrinivasSampath SrinivasSampath mannequin added 3.8 only security fixes type-bug An unexpected behavior, bug, or error labels Jun 26, 2020
    @SilentGhost
    Copy link
    Mannequin

    SilentGhost mannequin commented Jun 26, 2020

    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.

    @SilentGhost SilentGhost mannequin closed this as completed Jun 26, 2020
    @SilentGhost SilentGhost mannequin added the invalid label Jun 26, 2020
    @SilentGhost SilentGhost mannequin closed this as completed Jun 26, 2020
    @SilentGhost SilentGhost mannequin added the invalid label Jun 26, 2020
    @SrinivasSampath
    Copy link
    Mannequin Author

    SrinivasSampath mannequin commented Jun 26, 2020

    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

    @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
    3.8 only security fixes type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    0 participants