Kaydet (Commit) fbe28de6 authored tarafından David Bolen's avatar David Bolen Kaydeden (comit) Stephan Bergmann

fdo#66025: Simplify new ImportError logic

Signed-off-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 6c098943
...@@ -279,15 +279,14 @@ def _uno_import( name, *optargs, **kwargs ): ...@@ -279,15 +279,14 @@ def _uno_import( name, *optargs, **kwargs ):
d = mod.__dict__ d = mod.__dict__
RuntimeException = pyuno.getClass( "com.sun.star.uno.RuntimeException" ) RuntimeException = pyuno.getClass( "com.sun.star.uno.RuntimeException" )
unknown = object() # unknown/missing sentinel
for x in fromlist: for x in fromlist:
if x not in d: if x not in d:
d[x] = unknown failed = False
if x.startswith( "typeOf" ): if x.startswith( "typeOf" ):
try: try:
d[x] = pyuno.getTypeByName( name + "." + x[6:len(x)] ) d[x] = pyuno.getTypeByName( name + "." + x[6:len(x)] )
except RuntimeException: except RuntimeException:
pass failed = True
else: else:
try: try:
# check for structs, exceptions or interfaces # check for structs, exceptions or interfaces
...@@ -301,12 +300,9 @@ def _uno_import( name, *optargs, **kwargs ): ...@@ -301,12 +300,9 @@ def _uno_import( name, *optargs, **kwargs ):
try: try:
d[x] = getConstantByName( name + "." + x ) d[x] = getConstantByName( name + "." + x )
except RuntimeException: except RuntimeException:
pass failed = True
if d[x] is unknown:
# Remove unknown placeholder we created
del d[x]
if failed:
# This can be a bad uno reference, or it can just result from any # This can be a bad uno reference, or it can just result from any
# python import failure (in a "from xxx import yyy" statement). # python import failure (in a "from xxx import yyy" statement).
# Synthesize a general purpose exception, reusing the original # Synthesize a general purpose exception, reusing the original
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment