The fact that this was failing and went unnoticed so long seems like a good argument for being able to enable and disble py3kwarnings through Python.
import tempfile
from warnings import warnpy3k
-warnpy3k("in 3.x, mimetools has been removed in favor of the email package")
+warnpy3k("in 3.x, mimetools has been removed in favor of the email package",
+ stacklevel=2)
__all__ = ["Message","choose_boundary","encode","decode","copyliteral",
"copybinary"]
error='Audio_mac.error'
from warnings import warnpy3k
-warnpy3k("In 3.x, the Play_Audio_mac module is removed.")
+warnpy3k("In 3.x, the Play_Audio_mac module is removed.", stacklevel=2)
class Play_Audio_mac:
warnings.filterwarnings("ignore", "", FutureWarning, ".*MacTextEditor")
from warnings import warnpy3k
-warnpy3k("In 3.x, Carbon is removed.")
+warnpy3k("In 3.x, Carbon is removed.", stacklevel=2)
"""
from warnings import warnpy3k
-warnpy3k("In 3.x, the EasyDialogs module is removed.")
+warnpy3k("In 3.x, the EasyDialogs module is removed.", stacklevel=2)
from Carbon.Dlg import GetNewDialog, SetDialogItemText, GetDialogItemText, ModalDialog
from Carbon import Qd
DEBUG=0
from warnings import warnpy3k
-warnpy3k("In 3.x, the FrameWork module is removed.")
+warnpy3k("In 3.x, the FrameWork module is removed.", stacklevel=2)
import MacOS
import traceback
"""
from warnings import warnpy3k
-warnpy3k("In 3.x, the MiniAEFrame module is removed.")
+warnpy3k("In 3.x, the MiniAEFrame module is removed.", stacklevel=2)
import traceback
import MacOS
from warnings import warnpy3k
-warnpy3k("In 3.x, the PixMapWrapper module is removed.")
+warnpy3k("In 3.x, the PixMapWrapper module is removed.", stacklevel=2)
from Carbon import Qd
from Carbon import QuickDraw
#
from warnings import warnpy3k
-warnpy3k("In 3.x, the aepack module is removed.")
+warnpy3k("In 3.x, the aepack module is removed.", stacklevel=2)
import struct
import types
from warnings import warnpy3k
-warnpy3k("In 3.x, the aetools module is removed.")
+warnpy3k("In 3.x, the aetools module is removed.", stacklevel=2)
from types import *
from Carbon import AE
"""aetypes - Python objects representing various AE types."""
from warnings import warnpy3k
-warnpy3k("In 3.x, the aetypes module is removed.")
+warnpy3k("In 3.x, the aetypes module is removed.", stacklevel=2)
from Carbon.AppleEvents import *
import struct
"""
from warnings import warnpy3k
-warnpy3k("In 3.x, the applesingle module is removed.")
+warnpy3k("In 3.x, the applesingle module is removed.", stacklevel=2)
import struct
import sys
#
from warnings import warnpy3k
-warnpy3k("In 3.x, the appletrawmain module is removed.")
+warnpy3k("In 3.x, the appletrawmain module is removed.", stacklevel=2)
import argvemulator
import os
# we are not running in a framework build.
from warnings import warnpy3k
-warnpy3k("In 3.x, appletrunner is removed.")
+warnpy3k("In 3.x, appletrunner is removed.", stacklevel=2)
import os
import sys
"""
from warnings import warnpy3k
-warnpy3k("In 3.x, the argvemulator module is removed.")
+warnpy3k("In 3.x, the argvemulator module is removed.", stacklevel=2)
import sys
import traceback
import os
from warnings import warnpy3k
-warnpy3k("In 3.x, the bgenlocations module is removed.")
+warnpy3k("In 3.x, the bgenlocations module is removed.", stacklevel=2)
Error = "bgenlocations.Error"
#
"""tools for BuildApplet and BuildApplication"""
import warnings
-warnings.warn("the buildtools module is deprecated and is removed in 3.0",
- DeprecationWarning, 2)
+warnings.warnpy3k("the buildtools module is deprecated and is removed in 3.0",
+ stacklevel=2)
import sys
import os
from warnings import warnpy3k
-warnpy3k("In 3.x, the bundlebuilder module is removed.")
+warnpy3k("In 3.x, the bundlebuilder module is removed.", stacklevel=2)
import sys
import os, errno, shutil
__author__ = "jvr"
import warnings
-warnings.warn("the cfmfile module is deprecated and is removed in 3,0",
- DeprecationWarning, 2)
+warnings.warnpy3k("the cfmfile module is deprecated and is removed in 3,0",
+ stacklevel=2)
import Carbon.File
import struct
"""
from warnings import warnpy3k
-warnpy3k("In 3.x, the findertools module is removed.")
+warnpy3k("In 3.x, the findertools module is removed.", stacklevel=2)
import Finder
from Carbon import AppleEvents
"""
from warnings import warnpy3k
-warnpy3k("In 3.x, the gensuitemodule module is removed.")
+warnpy3k("In 3.x, the gensuitemodule module is removed.", stacklevel=2)
import MacOS
import EasyDialogs
"""IC wrapper module, based on Internet Config 1.3"""
from warnings import warnpy3k
-warnpy3k("In 3.x, the ic module is removed.")
+warnpy3k("In 3.x, the ic module is removed.", stacklevel=2)
import icglue
import string
"""
from warnings import warnpy3k
-warnpy3k("In 3.x, the icopen module is removed.")
+warnpy3k("In 3.x, the icopen module is removed.", stacklevel=2)
import __builtin__
"""
from warnings import warnpy3k
-warnpy3k("In 3.x, the CodeWarrior package is removed.")
+warnpy3k("In 3.x, the CodeWarrior package is removed.", stacklevel=2)
import aetools
Error = aetools.Error
"""
from warnings import warnpy3k
-warnpy3k("In 3.x, the Explorer module is removed.")
+warnpy3k("In 3.x, the Explorer module is removed.", stacklevel=2)
import aetools
Error = aetools.Error
"""
from warnings import warnpy3k
-warnpy3k("In 3.x, the Finder package is removed.")
+warnpy3k("In 3.x, the Finder package is removed.", stacklevel=2)
import aetools
Error = aetools.Error
"""
from warnings import warnpy3k
-warnpy3k("In 3.x, the Netscape package is removed.")
+warnpy3k("In 3.x, the Netscape package is removed.", stacklevel=2)
import aetools
Error = aetools.Error
"""
from warnings import warnpy3k
-warnpy3k("In 3.x, the StdSuites package is removed.")
+warnpy3k("In 3.x, the StdSuites package is removed.", stacklevel=2)
import aetools
Error = aetools.Error
"""
from warnings import warnpy3k
-warnpy3k("In 3.x, the SystemEvents package is removed.")
+warnpy3k("In 3.x, the SystemEvents package is removed.", stacklevel=2)
import aetools
Error = aetools.Error
"""
from warnings import warnpy3k
-warnpy3k("In 3.x, the Terminal module is removed.")
+warnpy3k("In 3.x, the Terminal module is removed.", stacklevel=2)
import aetools
Error = aetools.Error
"""
from warnings import warnpy3k
-warnpy3k("In 3.x, the _builtinSuites module is removed.")
+warnpy3k("In 3.x, the _builtinSuites module is removed.", stacklevel=2)
import aetools
import builtin_Suite
# -coding=latin1-
from warnings import warnpy3k
-warnpy3k("In 3.x, the macerrors module is removed.")
+warnpy3k("In 3.x, the macerrors module is removed.", stacklevel=2)
svTempDisable = -32768 #svTempDisable
svDisabled = -32640 #Reserve range -32640 to -32768 for Apple temp disables.
"""
from warnings import warnpy3k
-warnpy3k("In 3.x, the macostools module is removed.")
+warnpy3k("In 3.x, the macostools module is removed.", stacklevel=2)
from Carbon import Res
from Carbon import File, Files
"""macresource - Locate and open the resources needed for a script."""
from warnings import warnpy3k
-warnpy3k("In 3.x, the macresource module is removed.")
+warnpy3k("In 3.x, the macresource module is removed.", stacklevel=2)
from Carbon import Res
import os
"""
from warnings import warnpy3k
-warnpy3k("In 3.x, the pimp module is removed.")
+warnpy3k("In 3.x, the pimp module is removed.", stacklevel=2)
import sys
import os
#
from warnings import warnpy3k
-warnpy3k("In 3.x, the terminalcommand module is removed.")
+warnpy3k("In 3.x, the terminalcommand module is removed.", stacklevel=2)
import time
import os
#
from warnings import warnpy3k
-warnpy3k("In 3.x, the videoreader module is removed.")
+warnpy3k("In 3.x, the videoreader module is removed.", stacklevel=2)
import sys
import time
from warnings import warnpy3k
-warnpy3k("in 3.x, rfc822 has been removed in favor of the email package")
+warnpy3k("in 3.x, rfc822 has been removed in favor of the email package",
+ stacklevel=2)
__all__ = ["Message","AddressList","parsedate","parsedate_tz","mktime_tz"]
TestSkipped, run_unittest)
import warnings
+from contextlib import nested
+
if not sys.py3kwarning:
raise TestSkipped('%s must be run with the -3 flag' % __name__)
'Explorer', 'Finder', 'Netscape',
'StdSuites', 'SystemEvents', 'Terminal',
'cfmfile', 'bundlebuilder', 'buildtools',
- 'ColorPicker'),
+ 'ColorPicker', 'Audio_mac'),
'sunos5' : ('sunaudiodev', 'SUNAUDIODEV'),
}
optional_modules = ('bsddb185', 'Canvas', 'dl', 'linuxaudiodev', 'imageop',
def check_removal(self, module_name, optional=False):
"""Make sure the specified module, when imported, raises a
DeprecationWarning and specifies itself in the message."""
- with CleanImport(module_name):
- with catch_warning(record=False):
- warnings.filterwarnings("error", ".+ removed",
- DeprecationWarning)
- try:
- __import__(module_name, level=0)
- except DeprecationWarning as exc:
- self.assert_(module_name in exc.args[0],
- "%s warning didn't contain module name"
- % module_name)
- except ImportError:
- if not optional:
- self.fail("Non-optional module {0} raised an "
- "ImportError.".format(module_name))
- else:
- self.fail("DeprecationWarning not raised for {0}"
- .format(module_name))
+ with nested(CleanImport(module_name), catch_warning(record=False)):
+ warnings.filterwarnings("error", ".+ removed",
+ DeprecationWarning, __name__)
+ try:
+ __import__(module_name, level=0)
+ except DeprecationWarning as exc:
+ self.assert_(module_name in exc.args[0],
+ "%s warning didn't contain module name"
+ % module_name)
+ except ImportError:
+ if not optional:
+ self.fail("Non-optional module {0} raised an "
+ "ImportError.".format(module_name))
+ else:
+ self.fail("DeprecationWarning not raised for {0}"
+ .format(module_name))
def test_platform_independent_removals(self):
# Make sure that the modules that are available on all platforms raise