File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,6 +50,10 @@ def command(argv = sys.argv):
5050 else :
5151 cat = None
5252
53+ trace_file = None
54+ if co .pq_trace is not None :
55+ trace_file = open (co .pq_trace , 'a' )
56+
5357 try :
5458 need_prompt = False
5559 cond = None
@@ -67,6 +71,8 @@ def command(argv = sys.argv):
6771 raise SystemExit (1 )
6872 connector = pg_driver .fit (category = cat , ** cond )
6973 connection = connector ()
74+ if trace_file is not None :
75+ connection .tracer = trace_file .write
7076 connection .connect ()
7177 except pg_exc .ClientCannotConnectError as err :
7278 for att in connection .failures :
@@ -104,13 +110,8 @@ def command(argv = sys.argv):
104110 builtins_d = __builtins__
105111 restore = {k : builtins_d .get (k ) for k in builtin_overload }
106112
107- trace_file = None
108- if co .pq_trace is not None :
109- trace_file = open (co .pq_trace , 'a' )
110113 builtins_d .update (builtin_overload )
111114 try :
112- if trace_file is not None :
113- connection .tracer = trace_file .write
114115 with connection :
115116 rv = pythonexec (
116117 context = pycmd .postmortem (os .environ .get ('PYTHON_POSTMORTEM' ))
Original file line number Diff line number Diff line change @@ -1964,6 +1964,8 @@ def connect(self):
19641964 sf , self .connector ._startup_parameters ,
19651965 password = self .connector ._password ,
19661966 )
1967+ if hasattr (self , 'tracer' ):
1968+ pq .tracer = self .tracer
19671969 # Grab the negotiation transaction before
19681970 # connecting as it will be needed later if successful.
19691971 neg = pq .xact
You can’t perform that action at this time.
0 commit comments