[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14353] trunk/blender/release/scripts/ bpymodules/BPyRegistry.py: Potential fix for [#8113] Blender. Registry segfault when no permission to write
Martin Poirier
theeth at yahoo.com
Mon Apr 7 22:56:45 CEST 2008
Revision: 14353
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14353
Author: theeth
Date: 2008-04-07 22:56:45 +0200 (Mon, 07 Apr 2008)
Log Message:
-----------
Potential fix for [#8113] Blender.Registry segfault when no permission to write
This converts exceptions in Warning in selected points of the registry module.
While I couldn't reproduce the segfault ( I received the Py error as expected), this isn't a bad idea anyway, since the BPy C counterpart was discarding the error anyway, making it a warning is a bit more inline with its meaning.
The exception is not preventable nor fixable from a script's point of view, so better to silence it and print a warning to the console instead.
Modified Paths:
--------------
trunk/blender/release/scripts/bpymodules/BPyRegistry.py
Modified: trunk/blender/release/scripts/bpymodules/BPyRegistry.py
===================================================================
--- trunk/blender/release/scripts/bpymodules/BPyRegistry.py 2008-04-07 15:21:25 UTC (rev 14352)
+++ trunk/blender/release/scripts/bpymodules/BPyRegistry.py 2008-04-07 20:56:45 UTC (rev 14353)
@@ -193,14 +193,17 @@
if bsys.exists(fname): files.append(fname)
for p in files:
- f = file(p, 'r')
- lines = f.readlines()
- f.close()
- if lines: # Lines may be blank
- mainkey = lines[0].split('=')[0].strip()
- pysrc = "\n".join(lines)
- exec(pysrc)
- exec("Registry.SetKey('%s', %s)" % (str(mainkey), mainkey))
+ try:
+ f = file(p, 'r')
+ lines = f.readlines()
+ f.close()
+ if lines: # Lines may be blank
+ mainkey = lines[0].split('=')[0].strip()
+ pysrc = "\n".join(lines)
+ exec(pysrc)
+ exec("Registry.SetKey('%s', %s)" % (str(mainkey), mainkey))
+ except Exception, e:
+ raise Warning(e) # Resend exception as warning
def RemoveConfigData (key = None):
@@ -223,8 +226,11 @@
import os
- for p in files:
- os.remove(p) # remove the file(s)
+ try:
+ for p in files:
+ os.remove(p) # remove the file(s)
+ except Exception, e:
+ raise Warning(e) # Resend exception as warning
def SaveConfigData (key = None):
@@ -250,9 +256,12 @@
if not cfgdict: continue
- filename = bsys.join(_CFG_DIR, "%s%s" % (mainkey, _EXT))
- f = file(filename, 'w')
- output = _dict_to_str(mainkey, _sanitize(cfgdict))
- if output!='None':
- f.write(output)
- f.close()
+ try:
+ filename = bsys.join(_CFG_DIR, "%s%s" % (mainkey, _EXT))
+ f = file(filename, 'w')
+ output = _dict_to_str(mainkey, _sanitize(cfgdict))
+ if output!='None':
+ f.write(output)
+ f.close()
+ except Exception, e:
+ raise Warning(e) # Resend exception as warning
More information about the Bf-blender-cvs
mailing list