[Jython-checkins] jython: Fix Python issue 7994: object.__format__ should reject format strings.

nicholas.riley jython-checkins at python.org
Wed Mar 21 21:14:27 CET 2012


http://hg.python.org/jython/rev/f1ee1288c03c
changeset:   6458:f1ee1288c03c
user:        Nicholas Riley <njriley at illinois.edu>
date:        Wed Mar 21 16:14:19 2012 -0400
summary:
  Fix Python issue 7994: object.__format__ should reject format strings.

http://bugs.python.org/issue7994

files:
  src/org/python/core/PyObject.java |  2 ++
  1 files changed, 2 insertions(+), 0 deletions(-)


diff --git a/src/org/python/core/PyObject.java b/src/org/python/core/PyObject.java
--- a/src/org/python/core/PyObject.java
+++ b/src/org/python/core/PyObject.java
@@ -1716,6 +1716,8 @@
 
     @ExposedMethod(doc = BuiltinDocs.object___format___doc)
     final PyObject object___format__(PyObject formatSpec) {
+        if (formatSpec != null && formatSpec instanceof PyString && !((PyString)formatSpec).getString().isEmpty())
+            Py.warning(Py.PendingDeprecationWarning, "object.__format__ with a non-empty format string is deprecated");
         return __str__().__format__(formatSpec);
     }
 

-- 
Repository URL: http://hg.python.org/jython


More information about the Jython-checkins mailing list