Re: BUG #15827: Unable to connect on Windows using pg_services.conf using Python psycopg2
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jorge Gustavo Rocha <jgr@geomaster.pt>
Cc: pgsql-bugs@lists.postgresql.org
Date: 2019-06-19T20:44:58Z
Lists: pgsql-bugs
Jorge Gustavo Rocha <jgr@geomaster.pt> writes: > The error I was facing in QGIS is because the application changes the > default fopen mode to binary mode. So, every file is opened in binary > mode and so is pg_services.conf. Ah-hah! That explains much. So a non-invasive fix would be to force parseServiceFile to open the file in text mode; I think this would work for that: - f = fopen(serviceFile, "r"); + f = fopen(serviceFile, "rt"); I don't think that that's really a good solution, because it does little to prevent the same problem from reappearing elsewhere. But if we wanted the smallest possible fix that might do. > In my humble opinion, we could make pg_services.conf agnostic in terms > of \r, just by filtering them, if present. I think we should have it go further and ignore any trailing isspace() characters, so that trailing spaces don't cause problems either. But in any case, the real stumbling block here is to get a project-wide convention as to how to do it. regards, tom lane
Commits
-
Fix failures to ignore \r when reading Windows-style newlines.
- 8c52b77ddea7 9.4.24 landed
- 6266654db7fa 9.5.19 landed
- ba27151d1eb0 9.6.15 landed
- cb65b454f87b 10.10 landed
- 11a0a4db3cdb 11.5 landed
- c58cf97f2fc4 12.0 landed
- b654714f9bcf 13.0 landed