summaryrefslogtreecommitdiffstats
path: root/Lib/pickle.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-07-29 09:27:14 (GMT)
committerGitHub <noreply@github.com>2024-07-29 09:27:14 (GMT)
commitc26dd270f7c7301636b23d70afaaeabb2f52eedf (patch)
tree2325586beff512513708a31f7d12f2f5eaf1fe4a /Lib/pickle.py
parentd113359341374a0d7e956aaf13f1659440851aa6 (diff)
downloadcpython-c26dd270f7c7301636b23d70afaaeabb2f52eedf.zip
cpython-c26dd270f7c7301636b23d70afaaeabb2f52eedf.tar.gz
cpython-c26dd270f7c7301636b23d70afaaeabb2f52eedf.tar.bz2
[3.13] gh-122311: Fix some error messages in pickle (GH-122386) (GH-122387)
(cherry picked from commit 3b034d26eb8480f8d12ae11f42d038d24cf8498a) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/pickle.py')
-rw-r--r--Lib/pickle.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py
index 0c6b177..ab63cb2 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -314,16 +314,17 @@ class _Unframer:
# Tools used for pickling.
def _getattribute(obj, name):
+ top = obj
for subpath in name.split('.'):
if subpath == '<locals>':
raise AttributeError("Can't get local attribute {!r} on {!r}"
- .format(name, obj))
+ .format(name, top))
try:
parent = obj
obj = getattr(obj, subpath)
except AttributeError:
raise AttributeError("Can't get attribute {!r} on {!r}"
- .format(name, obj)) from None
+ .format(name, top)) from None
return obj, parent
def whichmodule(obj, name):
@@ -832,7 +833,7 @@ class _Pickler:
if _HAVE_PICKLE_BUFFER:
def save_picklebuffer(self, obj):
if self.proto < 5:
- raise PicklingError("PickleBuffer can only pickled with "
+ raise PicklingError("PickleBuffer can only be pickled with "
"protocol >= 5")
with obj.raw() as m:
if not m.contiguous: