diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2021-07-20 11:48:09 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2021-07-20 11:48:09 +0200 |
commit | 1ce05b86ce32a3109e1aaec09ef9e1b60e5ae45c (patch) | |
tree | 5d1b2ed52125f54578215c5a1ffa759cdc80af0f | |
parent | 8e1bfe7f8d0da9b69510b1a0e6aa287023b84059 (diff) | |
download | cython-1ce05b86ce32a3109e1aaec09ef9e1b60e5ae45c.tar.gz |
Refactor function to make it less verbose and simpler to change: error cases first, then special cases, then normal behaviour.
-rw-r--r-- | Cython/Compiler/PyrexTypes.py | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index d36e19950..4345bfdb2 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -389,20 +389,15 @@ def public_decl(base_code, dll_linkage): else: return base_code -def create_typedef_type(name, base_type, cname, is_external=0, namespace=None): - is_fused = base_type.is_fused - if base_type.is_complex or is_fused: - if is_external: - if is_fused: - msg = "Fused" - else: - msg = "Complex" - - raise ValueError("%s external typedefs not supported" % msg) +def create_typedef_type(name, base_type, cname, is_external=0, namespace=None): + if is_external: + if base_type.is_complex or base_type.is_fused: + raise ValueError("%s external typedefs not supported" % ( + "Fused" if base_type.is_fused else "Complex")) + if base_type.is_complex or base_type.is_fused: return base_type - else: - return CTypedefType(name, base_type, cname, is_external, namespace) + return CTypedefType(name, base_type, cname, is_external, namespace) class CTypedefType(BaseType): |