Re: objcreator.py: DeprecationWarning: 'U' mode is deprecated
Valentin VALLS <[email protected]>
| Newsgroups | gmane.comp.python.pyqt-pykde |
|---|---|
| Organization | ESRF |
| Message-ID | <[email protected]> |
> 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 _______________________________________________ PyQt mailing list [email protected] https://www.riverbankcomputing.com/mailman/listinfo/pyqt
fix_warning.diff
(text/plain, 844 B)
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)