From: Josip <jo...@pi...> - 2013-02-24 18:57:24
|
-------- Original Message -------- Subject: Re: [Gramps-devel] Error in gramps40 Date: Sun, 24 Feb 2013 19:16:02 +0100 From: Josip <jo...@pi...> To: John Ralls <jr...@ce...> On 24.02.2013 17:49, John Ralls wrote: > > On Feb 24, 2013, at 8:36 AM, John Ralls <jr...@ce...> wrote: > >> >> On Feb 24, 2013, at 8:16 AM, Enno Borgsteede <enn...@gm...> wrote: >> >>> Hi John, >>>> On Feb 24, 2013, at 6:28 AM, Nick Hall <nic...@ho...> wrote: >>>> >>>>> Devs, >>>>> >>>>> Every time I start gramps40, I get the following warning: >>>>> >>>>> "WARNING: could not parse file, recreating it:" >>>>> >>>>> with the files gramps.ini and Dashboard_dashboardview.ini >>>>> >>>>> Also when exiting Gramps I get the error: >>>>> >>>>> TypeError: must be unicode, not str >>>>> >>>>> on line 1185 of grampletpane.py >>>>> >>>>> Has anyone made a change recently that could have caused this? >>>>> >>>> Yes, I backported the new localization code to trunk yesterday, and it replaced the "open" on the ini files with io.open(encoding="utf-8"). >>>> >>>> I thought that I'd gotten all of the grampletpane Typeerrors, but I missed the final "NL", and for reasons that escape me python didn't complain about it when I tested it. >>>> >>>> Here's the underlying issue: In Python3, the open() builtin is an alias for io.open(), and Py3 expects to find utf-8. To make it consistent, I set Py2 to do the same thing, but that causes the parse errors the first time the files are opened, which isn't so good. >>>> >>>> I think the solution is to try opening the file to read as utf-8, try to read a line and if that raises, catch the exception and re-open the file as ascii. Writing should always be in utf-8 so that users don't have to use English strings in their preferences. >>> I just added a cuni call around that final NL, and got rid of the error >>> on exit. That's in todays trunk, with Python 2.7.3. See below: >>> >>> Index: gramps/gui/widgets/grampletpane.py >>> =================================================================== >>> --- gramps/gui/widgets/grampletpane.py (revision 21432) >>> +++ gramps/gui/widgets/grampletpane.py (working copy) >>> @@ -1182,7 +1182,7 @@ >>> fp.write(cuni(("column_count=%d" + NL) % self.column_count)) >>> fp.write(cuni(("pane_position=%d" + NL) % self.pane_position)) >>> fp.write(cuni(("pane_orientation=%s" + NL) % >>> self.pane_orientation)) >>> - fp.write(NL) >>> + fp.write(cuni(NL)) >>> # showing gramplets: >>> for col in range(self.column_count): >>> row = 0 >>> >>> Now, here's my thought. If the error on exit is corrected, the file will >>> exist next time Gramps is started, so the warning on start should also >>> go away, right? I don't see it in trunk anymore. >> >> Ah, is that true? The failure to parse comes at the *second* invocation of Gramps, not from trying to read an older ini file? > > Anyway, committed in r21434 (gramps40) and 21435 (trunk). > > Regards, > John Ralls > Something is still broken, i can't even run it with python2.7 [jole@myhost gramps40]$ python2 Gramps.py WARNING: could not parse file, recreating it: /home/jole/.gramps/gramps40/gramps.ini 2013-02-24 19:09:02.792: ERROR: grampsapp.py: line 113: Unhandled exception Traceback (most recent call last): File "/home/jole/svn/gramps/gramps40/gramps/gui/grampsgui.py", line 319, in __startgramps from .logger import RotateHandler, GtkHandler File "/home/jole/svn/gramps/gramps40/gramps/gui/logger/__init__.py", line 67, in <module> from ._gtkhandler import GtkHandler File "/home/jole/svn/gramps/gramps40/gramps/gui/logger/_gtkhandler.py", line 26, in <module> from ._errorview import ErrorView File "/home/jole/svn/gramps/gramps40/gramps/gui/logger/_errorview.py", line 38, in <module> from ._errorreportassistant import ErrorReportAssistant File "/home/jole/svn/gramps/gramps40/gramps/gui/logger/_errorreportassistant.py", line 42, in <module> import bsddb File "/usr/lib/python2.7/bsddb/__init__.py", line 67, in <module> import _bsddb ImportError: No module named _bsddb [jole@myhost gramps40]$ svnversion 21437 BTW IMHO checking bsddb by python version or hardcoding that in config is insane. -- Josip |