[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] objcreator.py: DeprecationWarning: 'U' mode is deprecated
From:       Valentin VALLS <valentin.valls () esrf ! fr>
Date:       2019-10-24 8:29:56
Message-ID: a4f49076-400b-aa4e-6973-72575a528463 () esrf ! fr
[Download RAW message or body]

> Patches are always welcome but they must work for all supported 
> versions of Python.
>
> Phil

Then, here is a patch. Hope the format is fone for you.

I don't think you have a public repository?

Regards


["fix_warning.diff" (text/plain)]

diff --git a/PyQt5/uic/objcreator.py b/PyQt5/uic/objcreator.py
index 921260250..8adc94017 100644
--- a/PyQt5/uic/objcreator.py
+++ b/PyQt5/uic/objcreator.py
@@ -37,7 +37,7 @@
 ##
 #############################################################################
 
-
+import sys
 import os.path
 
 from .exceptions import NoSuchWidgetError, WidgetPluginError
@@ -148,7 +148,11 @@ class QObjectCreator(object):
         loaded, or False if it wanted to be ignored.  Raise an exception if
         there was an error.
         """
-        plugin = open(filename, 'rU')
+        if sys.version_info < (3, ):
+            # Universal newline is not the default in python2
+            plugin = open(filename, 'rU')
+        else:
+            plugin = open(filename, 'r')
 
         try:
             exec(plugin.read(), plugin_globals, plugin_locals)

[Attachment #4 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic