On Thu, Nov 16, 2006 at 09:20:17AM +0100, Jean-Marc Lasgouttes wrote:
> >>>>> "Enrico" == Enrico Forestieri <[EMAIL PROTECTED]> writes:
>
> Enrico> On Tue, Nov 14, 2006 at 11:18:47PM +0000, José Matos wrote:
> >> On Tuesday 14 November 2006 6:05 pm, Enrico Forestieri wrote:
> >> > >
> >> > > I should prepare a patch for 1.4.
> >> >
> >> > I could do it, if you don't mind.
> >>
> >> Thank you, go ahead. :-)
>
> Enrico> Patch attached. Jean-Marc, can this go in?
>
> I think so, although I'd rather have some input from some people who
> know python (josé?)
>
> Enrico> (this time I tested it on both Windows and Unix :)
>
> Did you test with python 2.2.x?
Good point. I tested it on debian etch, which carries python from 2.1
to 2.4, and got:
Traceback (most recent call last):
File "/usr/local/src/lyx/lyx-1.4.x/lib/configure.py", line 17, in ?
__builtin__.True = (1 == 1)
NameError: name '__builtin__' is not defined
I had trusted José, but it seems he made a typo ;-)
New patch attached. Tested with python 2.2.3.
--
Enrico
Index: lib/scripts/lyxpreview_tools.py
===================================================================
--- lib/scripts/lyxpreview_tools.py (revision 15946)
+++ lib/scripts/lyxpreview_tools.py (working copy)
@@ -17,9 +17,9 @@
import os, re, string, sys, tempfile
# compatibility with python 2.2
-if sys.version_info[:3] == (2, 2, 0):
- __builtin__.True = (1 == 1)
- __builtin__.False = (1 == 0)
+if sys.version_info[:2] == (2, 2):
+ __builtins__.True = (1 == 1)
+ __builtins__.False = (1 == 0)
def bool(value):
"""Demote a value to 0 or 1, depending on its truth value
@@ -27,7 +27,7 @@ if sys.version_info[:3] == (2, 2, 0):
way too hard to duplicate in 2.1 to be worth the trouble.
"""
return not not value
- __builtin__.bool = bool
+ __builtins__.bool = bool
del bool
# end compatibility chunk
Index: lib/scripts/fig_copy.py
===================================================================
--- lib/scripts/fig_copy.py (revision 15946)
+++ lib/scripts/fig_copy.py (working copy)
@@ -21,9 +21,9 @@
import os, sys
# compatibility with python 2.2
-if sys.version_info[:3] == (2, 2, 0):
- __builtin__.True = (1 == 1)
- __builtin__.False = (1 == 0)
+if sys.version_info[:2] == (2, 2):
+ __builtins__.True = (1 == 1)
+ __builtins__.False = (1 == 0)
def bool(value):
"""Demote a value to 0 or 1, depending on its truth value
@@ -31,7 +31,7 @@ if sys.version_info[:3] == (2, 2, 0):
way too hard to duplicate in 2.1 to be worth the trouble.
"""
return not not value
- __builtin__.bool = bool
+ __builtins__.bool = bool
del bool
# end compatibility chunk
Index: lib/scripts/TeXFiles.py
===================================================================
--- lib/scripts/TeXFiles.py (revision 15946)
+++ lib/scripts/TeXFiles.py (working copy)
@@ -49,9 +49,9 @@ bib_files = 'bibFiles.lst'
try:
os.walk
except AttributeError:
- if sys.version_info[:3] == (2, 2, 0):
- __builtin__.True = (1 == 1)
- __builtin__.False = (1 == 0)
+ if sys.version_info[:2] == (2, 2):
+ __builtins__.True = (1 == 1)
+ __builtins__.False = (1 == 0)
def bool(value):
"""Demote a value to 0 or 1, depending on its truth value
@@ -59,7 +59,7 @@ except AttributeError:
way too hard to duplicate in 2.1 to be worth the trouble.
"""
return not not value
- __builtin__.bool = bool
+ __builtins__.bool = bool
del bool
def walk(top, topdown=True, onerror=None):
Index: lib/configure.py
===================================================================
--- lib/configure.py (revision 15946)
+++ lib/configure.py (working copy)
@@ -12,6 +12,21 @@
import sys, os, re, shutil, glob
+# compatibility with python 2.2
+if sys.version_info[:2] == (2, 2):
+ __builtins__.True = (1 == 1)
+ __builtins__.False = (1 == 0)
+ def bool(value):
+ """Demote a value to 0 or 1, depending on its truth value
+
+ This is not to be confused with types.BooleanType, which is
+ way too hard to duplicate in 2.1 to be worth the trouble.
+ """
+ return not not value
+ __builtins__.bool = bool
+ del bool
+# end compatibility chunk
+
class Tee:
''' Writing to a Tee object will write to all file objects it keeps.
@@ -185,15 +200,15 @@ def checkDTLtools():
if ((os.name == 'nt' or sys.platform == 'cygwin') and
checkProg('DVI to DTL converter', ['dv2dt']) != ['', ''] and
checkProg('DTL to DVI converter', ['dt2dv']) != ['', '']):
- dtl_tools = 'true'
+ dtl_tools = True
else:
- dtl_tools = 'false'
+ dtl_tools = False
return dtl_tools
def checkLatex(dtl_tools):
''' Check latex, return lyx_check_config '''
- if (dtl_tools == 'true'):
+ if dtl_tools:
# Windows only: DraftDVI
converter_entry = r'''\converter latex dvi2 "%%" "latex"
\converter dvi2 dvi "python -tt $$s/scripts/clean_dvi.py $$i $$o"
""'''
@@ -280,7 +295,7 @@ def checkFormatEntries(dtl_tools):
#
checkViewer('a DVI previewer', ['xdvi', 'kdvi'],
rc_entry = [r'\Format dvi dvi DVI D
"%%" ""'])
- if (dtl_tools == 'true'):
+ if dtl_tools:
# Windows only: DraftDVI
addToRC(r'\Format dvi2 dvi DraftDVI "" ""
""')
#