classification
Title: cPickle looking for non-existent package copyreg
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 2.7, Python 2.6
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: alexandre.vassalotti, amaury.forgeotdarc, georg.brandl, joequant
Priority: high Keywords: easy, patch

Created on 2009-10-14 16:12 by joequant, last changed 2009-11-24 18:07 by alexandre.vassalotti. This issue is now closed.

Files
File name Uploaded Description Edit
cpickle_restricted.patch amaury.forgeotdarc, 2009-10-15 21:29
remove_copyreg_str.diff alexandre.vassalotti, 2009-11-21 18:02
Messages (8)
msg94004 - (view) Author: Joseph C Wang (joequant) Date: 2009-10-14 16:12
When running cPickle in restricted mode, the module tries to import
copyreg which does not appear to exist anywhere.  The problem is in
cPickle.c 

 2980 	if (PyEval_GetRestricted()) {
 2981 		/* Restricted execution, get private tables */
 2982 		PyObject *m = PyImport_Import(copyreg_str);
 2983 
 2984 		if (m == NULL)
 2985 			goto err;
 2986 		self->dispatch_table = PyObject_GetAttr(m, dispatch_table_str);
 2987 		Py_DECREF(m);
 2988 		if (self->dispatch_table == NULL)
 2989 			goto err;
 2990 	}
 2991 	else {
 2992 		self->dispatch_table = dispatch_table;
 2993 		Py_INCREF(dispatch_table);
 2994 	}

copyreg_str should probably be copy_reg_str
msg94110 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-10-15 21:29
Here is a test+patch.
This does not apply to py3k: restricted mode does not exist there.
msg94208 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-10-18 08:13
Probably the whole of r63042 should be undone.
msg95577 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2009-11-21 05:53
But, that change was undone already, no? In fact, it is you, Georg, that
reverted my mess in r63493. ;-)
msg95578 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-11-21 13:25
Now I'm confused. So the only thing left to do is the patch attached here?
msg95587 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2009-11-21 18:02
Yes. But, I would remove the ugly copy_reg_str variable from cPickle as
the patch.
msg95655 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-11-23 20:24
Patch looks ok to me, do you want to apply it?
msg95693 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2009-11-24 18:07
Thanks you!

Committed in r76499 and backported to 2.6 in r76500.
History
Date User Action Args
2009-11-24 18:07:41alexandre.vassalottisetstatus: open -> closed
resolution: accepted
messages: + msg95693

stage: needs patch -> resolved
2009-11-23 20:24:22georg.brandlsetmessages: + msg95655
2009-11-21 18:02:53alexandre.vassalottisetfiles: + remove_copyreg_str.diff

messages: + msg95587
2009-11-21 13:25:35georg.brandlsetmessages: + msg95578
2009-11-21 05:53:02alexandre.vassalottisetnosy: + alexandre.vassalotti
messages: + msg95577
2009-10-18 08:13:14georg.brandlsetnosy: + georg.brandl
messages: + msg94208
2009-10-15 21:29:49amaury.forgeotdarcsetfiles: + cpickle_restricted.patch

nosy: + amaury.forgeotdarc
messages: + msg94110

keywords: + patch
2009-10-14 22:31:59pitrousetpriority: high
keywords: + easy
stage: needs patch
versions: + Python 2.7
2009-10-14 16:12:33joequantcreate