[Jython-checkins] jython (2.5): Check for BaseString so unicode is legal.

Philip Jenvey pjenvey at underboss.org
Wed Jul 18 17:46:57 CEST 2012


You actually don't want to change all these checks in class/function to match CPython 2.7.

On Jul 18, 2012, at 8:21 AM, frank.wierzbicki wrote:

> http://hg.python.org/jython/rev/aa13e5d9a23f
> changeset:   6799:aa13e5d9a23f
> branch:      2.5
> parent:      6790:36e6f6a4f476
> user:        Frank Wierzbicki <fwierzbicki at gmail.com>
> date:        Tue Jul 17 10:35:51 2012 -0700
> summary:
>  Check for BaseString so unicode is legal.
> 
> files:
>  src/org/python/core/PyClass.java    |  4 ++--
>  src/org/python/core/PyFunction.java |  2 +-
>  src/org/python/core/imp.java        |  2 +-
>  3 files changed, 4 insertions(+), 4 deletions(-)
> 
> 
> diff --git a/src/org/python/core/PyClass.java b/src/org/python/core/PyClass.java
> --- a/src/org/python/core/PyClass.java
> +++ b/src/org/python/core/PyClass.java
> @@ -42,7 +42,7 @@
>     }
> 
>     public static PyObject classobj___new__(PyObject name, PyObject bases, PyObject dict) {
> -        if (!name.getType().isSubType(PyString.TYPE)) {
> +        if (!name.getType().isSubType(PyBaseString.TYPE)) {
>             throw Py.TypeError("PyClass_New: name must be a string");
>         }
>         if (!(dict instanceof PyStringMap || dict instanceof PyDictionary)) {
> @@ -278,7 +278,7 @@
>     }
> 
>     public void setName(PyObject value) {
> -        if (value == null || !Py.isInstance(value, PyString.TYPE)) {
> +        if (value == null || !Py.isInstance(value, PyBaseString.TYPE)) {
>             throw Py.TypeError("__name__ must be a string object");
>         }
>         String name = value.toString();
> diff --git a/src/org/python/core/PyFunction.java b/src/org/python/core/PyFunction.java
> --- a/src/org/python/core/PyFunction.java
> +++ b/src/org/python/core/PyFunction.java
> @@ -104,7 +104,7 @@
>             throw Py.TypeError("function() argument 1 must be code, not " +
>                                code.getType().fastGetName());
>         }
> -        if (name != Py.None && !Py.isInstance(name, PyString.TYPE)) {
> +        if (name != Py.None && !Py.isInstance(name, PyBaseString.TYPE)) {
>             throw Py.TypeError("arg 3 (name) must be None or string");
>         }
>         if (defaults != Py.None && !(defaults instanceof PyTuple)) {
> diff --git a/src/org/python/core/imp.java b/src/org/python/core/imp.java
> --- a/src/org/python/core/imp.java
> +++ b/src/org/python/core/imp.java
> @@ -869,7 +869,7 @@
> 
>             StringBuilder modNameBuffer = new StringBuilder(name);
>             for (PyObject item : fromlist.asIterable()) {
> -                if (!Py.isInstance(item, PyString.TYPE)) {
> +                if (!Py.isInstance(item, PyBaseString.TYPE)) {
>                     throw Py.TypeError("Item in ``from list'' not a string");
>                 }
>                 if (item.toString().equals("*")) {
> 
> -- 
> Repository URL: http://hg.python.org/jython
> _______________________________________________
> Jython-checkins mailing list
> Jython-checkins at python.org
> http://mail.python.org/mailman/listinfo/jython-checkins

--
Philip Jenvey



More information about the Jython-checkins mailing list