Author Steven.Barker
Recipients BreamoreBoy, Steven.Barker, antox, brett.cannon, rbcollins
Date 2015-10-01.18:35:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1443724553.05.0.145990084922.issue23447@psf.upfronthosting.co.za>
In-reply-to
Content
Thanks for looking at the issue Brett.

I think you're right that your patch has incorrect semantics, since it doesn't save the value to the provided namespace if it had to go through the special path to find the name. I think my patch got that part right (though I definitely missed one PyUnicode_Check).

I've just noticed that our patches may not always do the right thing in all error situations. They may return -1 without setting an exception (or perhaps passing on a strange one from an internal call) if there's something weird going on like `__name__` not existing or not being a string.

I'm attaching a new version of my patch that moves the PyErr_Format call down to the later check for `value == NULL`. This handles both the basic case where nothing strange goes on but the requested name is not found, and the weird cases where unexpected stuff goes wrong. It will replace any errors raised by the earlier code with an ImportError. I think an ImportError is the appropriate exception for most error cases, but perhaps some internal errors should not be overwritten and more complicated error logic is needed.

I also notice that the code in the "import_from" function (from which I borrowed heavily for my patch) was changed in one of the 3.5rc patches to have new error handling (it raises ImportError more often I think). I don't see an obvious way to copy its new error logic to import_all_from, but my C coding skills are rather rusty so I could be missing an easy approach.
History
Date User Action Args
2015-10-01 18:35:53Steven.Barkersetrecipients: + Steven.Barker, brett.cannon, rbcollins, BreamoreBoy, antox
2015-10-01 18:35:53Steven.Barkersetmessageid: <1443724553.05.0.145990084922.issue23447@psf.upfronthosting.co.za>
2015-10-01 18:35:53Steven.Barkerlinkissue23447 messages
2015-10-01 18:35:52Steven.Barkercreate