fix: decode bytes from conn.info.get_parameters() to avoid TypeError on macOS#1598
Closed
xxiaoxiong wants to merge 1 commit into
Closed
fix: decode bytes from conn.info.get_parameters() to avoid TypeError on macOS#1598xxiaoxiong wants to merge 1 commit into
xxiaoxiong wants to merge 1 commit into
Conversation
…on macOS (Python 3.13+)
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Member
|
Hello. Thanks for your contribution. But did you actually reproduce the bug on your machine? Or is this just you blinding running your AI agent on pgcli amongst dozens of projects? Co-maintainers: A user actually made some inquiry about this bug here. I find that more promising than this pull request. I'll try to in the coming |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
pgclicrashes on startup on macOS (Homebrew, Python 3.13+/3.14+) with:And in the completion refresher thread:
Root Cause
psycopg.Connection.info.get_parameters()can return a dictionary withbytesvalues instead ofstron certain platforms (macOS with Homebrew psycopg, Python 3.13+). This occurs because psycopg's parameter_status returns raw bytes from the PostgreSQL protocol, andget_parameters()passes them through without decoding.When
hostisb'localhost'instead of'localhost', downstream code inmain.py'sget_prompt()callsstring.replace("\\H", self.pgexecute.host)which raisesTypeErrorbecausestr.replace()requires str arguments.Similarly,
search_path()returns raw cursor results that can be bytes, causingpgcompleter.py'sescape_name()to fail withTypeError: cannot use a string pattern on a bytes-like object.Changes
pgcli/pgexecute.py -
connect()method: After callingconn.info.get_parameters(), decode anybytesvalues tostrusing.decode().pgcli/pgexecute.py -
search_path()method: Decode individual schema name values frombytestostrif needed.Closes
Closes #1518