]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-99325: Remove unused `NameError` handling (#99326)
authorNikita Sobolev <mail@sobolevn.me>
Fri, 11 Nov 2022 09:56:57 +0000 (12:56 +0300)
committerGitHub <noreply@github.com>
Fri, 11 Nov 2022 09:56:57 +0000 (09:56 +0000)
Lib/copyreg.py
Lib/tarfile.py

index c8a52a2dc63a27ef4b4be3099355231ca3179712..578392409b403c0a07a81c2dfdaa1e35971785b1 100644 (file)
@@ -25,16 +25,10 @@ def constructor(object):
 
 # Example: provide pickling support for complex numbers.
 
-try:
-    complex
-except NameError:
-    pass
-else:
+def pickle_complex(c):
+    return complex, (c.real, c.imag)
 
-    def pickle_complex(c):
-        return complex, (c.real, c.imag)
-
-    pickle(complex, pickle_complex, complex)
+pickle(complex, pickle_complex, complex)
 
 def pickle_union(obj):
     import functools, operator
index a08f247f496b3d2c3f007c0a68db5c6488a6091e..42100e9a39436e229f4c9e6cd2bb3f9b28595217 100755 (executable)
@@ -57,13 +57,9 @@ except ImportError:
     grp = None
 
 # os.symlink on Windows prior to 6.0 raises NotImplementedError
-symlink_exception = (AttributeError, NotImplementedError)
-try:
-    # OSError (winerror=1314) will be raised if the caller does not hold the
-    # SeCreateSymbolicLinkPrivilege privilege
-    symlink_exception += (OSError,)
-except NameError:
-    pass
+# OSError (winerror=1314) will be raised if the caller does not hold the
+# SeCreateSymbolicLinkPrivilege privilege
+symlink_exception = (AttributeError, NotImplementedError, OSError)
 
 # from tarfile import *
 __all__ = ["TarFile", "TarInfo", "is_tarfile", "TarError", "ReadError",