diff --git a/web/pgadmin/utils/driver/psycopg2/typecast.py b/web/pgadmin/utils/driver/psycopg2/typecast.py
index 8a10d8c75..31d043d71 100644
--- a/web/pgadmin/utils/driver/psycopg2/typecast.py
+++ b/web/pgadmin/utils/driver/psycopg2/typecast.py
@@ -187,7 +187,7 @@ def register_string_typecasters(connection):
                 return None
             return bytes(
                 value, encodings[cursor.connection.encoding]
-            ).decode(typecast_encoding, errors='replace')
+            ).decode(python_encoding, errors='replace')
 
         unicode_type = psycopg2.extensions.new_type(
             # "char", name, text, character, character varying
