From: Benny M. <ben...@gm...> - 2013-02-19 16:39:51
|
2013/2/19 Enno Borgsteede <enn...@gm...> > Hi John, > > On Feb 18, 2013, at 2:17 PM, Enno Borgsteede <enn...@gm...> wrote: > > > >> On 18-02-13 21:30, John Ralls wrote: > >>> Then, so that it will work with both Py2 and Py3, the tests should be > if line == b"\xef\xbb" > >> Something weird here: The Python site says that the b prefix is ignored > in Python 2, but my experience shows that it definitely makes a difference > in 2.7.3. > > Really? > Yes. And I guess that's because of the types that are imported in > Gramps, like Benny said. That's why your experiments in a python shell, > and the ones I did here before, yield different results. > > The latest code that I run here opens all files as "rb", and still needs > those b's before string literals. It works OK on Windows files (PAF and > RM) and GEDCOM files created by Gramps itself, in Linux Mint. The only > thing that I haven't tested yet is importing a GEDCOM created by a > Windows Gramps (3.4.2). > > I must add that in order to test GEDCOM files written by Gramps trunk, I > first had to change the export code, like this: > > Index: gramps/plugins/export/exportgedcom.py > =================================================================== > --- gramps/plugins/export/exportgedcom.py (revision 21372) > +++ gramps/plugins/export/exportgedcom.py (working copy) > @@ -236,7 +236,7 @@ > """ > > self.dirname = os.path.dirname (filename) > - self.gedcom_file = io.open(filename, "w", encoding='utf-8') > + self.gedcom_file = open(filename, "w") > self._header(filename) > self._submitter() > self._individuals() > Hmm. It is not wrong of Gramps to create it's own output in a fixed known encoding, and utf-8 should be the one to use then. Benny > > Which puts me in a situation where I read all GEDCOMs as rb, and write > them as w. What logic is that? > > regards, > > Enno > > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_feb > _______________________________________________ > Gramps-devel mailing list > Gra...@li... > https://lists.sourceforge.net/lists/listinfo/gramps-devel > |