This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author brett.cannon
Recipients benjamin.peterson, brett.cannon
Date 2008-08-20.22:03:07
SpamBayes Score 2.9060088e-13
Marked as misclassified No
Message-id <bbaeab100808201503j761acdeau9136d9b7f2bca80c@mail.gmail.com>
In-reply-to <1afaf6160808201453q17838e17t5c9b807eafe470d9@mail.gmail.com>
Content
On Wed, Aug 20, 2008 at 2:53 PM, Benjamin Peterson
<report@bugs.python.org> wrote:
>
> Benjamin Peterson <musiccomposition@gmail.com> added the comment:
>
> On Wed, Aug 20, 2008 at 4:51 PM, Brett Cannon <report@bugs.python.org> wrote:
>>
>> Brett Cannon <brett@python.org> added the comment:
>>
>> On Wed, Aug 20, 2008 at 10:29 AM, Benjamin Peterson
>> <report@bugs.python.org> wrote:
>>>
>>> Benjamin Peterson <musiccomposition@gmail.com> added the comment:
>>>
>>> I don't think the using argument should live in warnings; it's too test
>>> specific. I recommend we still keep a catch_warning in test_support (or
>>> even just test_warnings since this seems to be the only use-case).
>>>
>>
>> But decoupling from the core code of the context manager for this is
>> not straight-forward without mucking around in sys.modules and that is
>> always a risky thing to do.
>
> Why would you have to much around in sys.modules?
>>

Well, the bulk of the code needs to live in 'warnings' for it to exist
if the 'test' package is missing. So any differences need to come from
the test.support version. Now the module argument is so that you can
control exactly what module has its showwarnings() implementation
changed without worrying about what 'warnings' is set in sys.modules
and really mucking up the interpreter. But if this argument is missing
then warnings.catchwarnings() will have to set warnings.showwarnings()
blindly since it doesn't know what module object is being tested. So
if I want that change to happen on another module, I need to change
what module is in sys.modules, call the context manager, and then put
it all back so that what I want happen occurs.

That's why you would have to mess with sys.modules. =) The argument
could be renamed '_using', but that just seems silly. And with it
being considered keyword-only (and I will make it the last argument
listed, then most people won't ever run into it.
History
Date User Action Args
2008-08-20 22:03:08brett.cannonsetrecipients: + brett.cannon, benjamin.peterson
2008-08-20 22:03:07brett.cannonlinkissue3602 messages
2008-08-20 22:03:07brett.cannoncreate