[issue24676] Error in pickle using cProfile

2015-07-20 Thread Erick Fonseca

New submission from Erick Fonseca:

cPickle raises a PicklingError when trying to pickle an instance of a class 
defined in a module being profiled with cProfile.

Example code:

import cPickle

class A(object):
pass

a = A()
with open('file.dat', 'wb') as f:
cPickle.dump(a, f)

Running the above example with python -m cProfile resulted in 

cPickle.PicklingError: Can't pickle class '__main__.A': attribute lookup 
__main__.A failed

I'm not sure if this is the intended behavior (I suppose __main__ in this case 
refers to the cProfile module file), but I googled it and couldn't find 
anything. I noticed this problem in Ubuntu 14.04 and Windows 8.1, both with 
Python 2.7.

--
components: Extension Modules
messages: 247006
nosy: Erick Fonseca
priority: normal
severity: normal
status: open
title: Error in pickle using cProfile
type: crash
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24676
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24676] Error in pickle using cProfile

2015-07-20 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The same is with profile, pickle and in 3.x. May be profile should set 
sys.modules['__main__']?

--
components: +Library (Lib) -Extension Modules
nosy: +georg.brandl, serhiy.storchaka
type: crash - behavior
versions: +Python 3.4, Python 3.5, Python 3.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24676
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24676] Error in pickle using cProfile

2015-07-20 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This looks as duplicate of issue9914.

--
resolution:  - duplicate
status: open - closed
superseder:  - trace/profile conflict with the use of sys.modules[__name__]

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24676
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com