Issue 1379: reloading imported modules sometimes fail with 'parent not in sys.modules' error (original) (raw)

Issue1379

Created on 2007-11-03 16:51 by _doublep, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
reloading-fix.diff _doublep,2007-11-03 16:51
Messages (3)
msg57085 - (view) Author: Paul Pogonyshev (_doublep) Date: 2007-11-03 16:51
This is apparently because sys.modules contains Unicode (str) keys, while 'parentname' is an old-style string. Attached patch seems to fix it, but I have no idea if it is correct in principle
msg57095 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2007-11-04 12:10
Why are you using PyUnicode_AsUTF32String(parentname)? PyUnicode_AsString() is the correct method (although it's not yet in the docs). The rest looks fine. PyModule_GetName() returns a char* from PyUnicode_AsString(). Fixed in r58838.
msg57096 - (view) Author: Paul Pogonyshev (_doublep) Date: 2007-11-04 12:30
Thank you for the commit. I just had a problem with my package, and since I was not sure if it was a bug in Py3k or the package, I went to debugging the former and found this. I just didn't know how to work with Unicode strings properly.
History
Date User Action Args
2022-04-11 14:56:27 admin set github: 45720
2008-01-06 22:29:45 admin set keywords: - py3kversions: Python 3.0
2007-11-04 12:30:48 _doublep set messages: +
2007-11-04 12:10:35 christian.heimes set status: open -> closedkeywords: + py3kresolution: fixedmessages: + nosy: + christian.heimes
2007-11-03 17:30:39 loewis set keywords: + patch
2007-11-03 16:51:43 _doublep create