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

Regression: non-ASCII login breaks connection since 1.30.3 #155

Closed
radioxoma opened this issue Apr 28, 2024 · 2 comments
Closed

Regression: non-ASCII login breaks connection since 1.30.3 #155

radioxoma opened this issue Apr 28, 2024 · 2 comments

Comments

@radioxoma
Copy link

radioxoma commented Apr 28, 2024

Hello! Looks like commit 796cd01 breaks connection if login contains non-ASCII symbols.

  File "test_pg.py", line 118, in test_version
    con = pg8000.native.Connection(**config)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "venv/lib/python3.12/site-packages/pg8000/native.py", line 195, in __init__
    super().__init__(*args, **kwargs)
  File "venv/lib/python3.12/site-packages/pg8000/core.py", line 383, in __init__
    self.message_types[code](_read(self._sock, data_len - 4), context)
  File "venv/lib/python3.12/site-packages/pg8000/core.py", line 853, in handle_PARAMETER_STATUS
    key, value = data[:pos].decode("ascii"), data[pos + 1 : -1].decode("ascii")
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 1: ordinal not in range(128)

An parameter_statuses example from last working version 1.30.3:

data = deque(
    [
        (b"application_name", b""),
        (b"client_encoding", b"UTF8"),
        (b"DateStyle", b"ISO, DMY"),
        (b"integer_datetimes", b"on"),
        (b"IntervalStyle", b"postgres"),
        (b"is_superuser", b"off"),
        (b"server_encoding", b"UTF8"),
        (b"server_version", b"10.23 (Ubuntu 10.23-0ubuntu0.18.04.2)"),
        (
            b"session_authorization",
            b'\xd0\xa0\xd1\x8b\xd0\xb6\xd0\xb8\xd0\xb9',  # An redhead "Рыжий"
        ),
        (b"standard_conforming_strings", b"on"),
        (b"TimeZone", b"Europe/Moscow"),
    ],
    maxlen=100,
)
@radioxoma radioxoma changed the title Regression: non-ASCIII login breaks connection since 1.30.3 Regression: non-ASCII login breaks connection since 1.30.3 Apr 28, 2024
@tlocke
Copy link
Owner

tlocke commented Apr 28, 2024

Thanks for the bug report @radioxoma, that should be fixed now in version 1.31.2

@radioxoma
Copy link
Author

Thank you for a fast response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants