Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit faf7dfa

Browse files
authoredNov 11, 2022
pythongh-99325: Remove unused NameError handling (python#99326)
1 parent e00d730 commit faf7dfa

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed
 

‎Lib/copyreg.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,10 @@ def constructor(object):
2525

2626
# Example: provide pickling support for complex numbers.
2727

28-
try:
29-
complex
30-
except NameError:
31-
pass
32-
else:
28+
def pickle_complex(c):
29+
return complex, (c.real, c.imag)
3330

34-
def pickle_complex(c):
35-
return complex, (c.real, c.imag)
36-
37-
pickle(complex, pickle_complex, complex)
31+
pickle(complex, pickle_complex, complex)
3832

3933
def pickle_union(obj):
4034
import functools, operator

‎Lib/tarfile.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,9 @@
5757
grp = None
5858

5959
# os.symlink on Windows prior to 6.0 raises NotImplementedError
60-
symlink_exception = (AttributeError, NotImplementedError)
61-
try:
62-
# OSError (winerror=1314) will be raised if the caller does not hold the
63-
# SeCreateSymbolicLinkPrivilege privilege
64-
symlink_exception += (OSError,)
65-
except NameError:
66-
pass
60+
# OSError (winerror=1314) will be raised if the caller does not hold the
61+
# SeCreateSymbolicLinkPrivilege privilege
62+
symlink_exception = (AttributeError, NotImplementedError, OSError)
6763

6864
# from tarfile import *
6965
__all__ = ["TarFile", "TarInfo", "is_tarfile", "TarError", "ReadError",

0 commit comments

Comments
 (0)
Please sign in to comment.