bluebird75 / winpdb

Fork of the official winpdb with improvements
Other
91 stars 24 forks source link

DeprecationWarning from rpdb2.py #7

Closed pourhouse closed 6 years ago

pourhouse commented 7 years ago

This warning is a little annoying, particularly when I am scanning/testing for the absence of stderr output:

>>> import rpdb2
rpdb2.py:308: DeprecationWarning: the sets module is deprecated
  import sets
rpdb2.py:313: DeprecationWarning: The popen2 module is deprecated.  Use the subprocess module.
  import popen2

Here is a fix. Note - this may be needed only for 2.6, as I do not see the DeprecationWarning for the CPython 2.7 and 3.4 versions I have tried the original on

--- rpdb2.py.orig   2010-08-17 15:12:52.000000000 -0400
+++ rpdb2.py    2017-06-29 21:01:06.751002237 -0400
@@ -305,14 +305,21 @@

 try:
     import compiler
-    import sets
 except:
     pass

-try:
-    import popen2
-except:
-    pass
+if sys.version_info[:2] >= (2, 6):
+    import warnings
+    with warnings.catch_warnings():
+        warnings.filterwarnings("ignore", category=DeprecationWarning)
+        import sets
+        import popen2
+else:
+    try:
+        import sets
+        import popen2
+    except:
+        pass

 try:
     from Crypto.Cipher import DES
bluebird75 commented 7 years ago

Hi,

Thanks for the feedback.

This is already implemented in the git version, see : https://github.com/bluebird75/winpdb/blob/master/rpdb2.py#L307

Use this version in preference to the packaged version, you will get a few more bug fixes.

Cheers,

Philippe

pourhouse commented 7 years ago

Cool, thanks!

I guess I shouldn't rely on the copyright and version info in rpdb2.py :)