Issue 160 in sfepy: Test for "basestring" instead of "str"

0 views
Skip to first unread message

sf...@googlecode.com

unread,
Dec 20, 2011, 5:27:08 AM12/20/11
to sfepy-...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 160 by torsten....@gmail.com: Test for "basestring" instead
of "str"
http://code.google.com/p/sfepy/issues/detail?id=160

Please replace occurences of isinstance(something, str) by
isinstance(something, basestring). This is an easy change, and it makes it
more convenient to use SfePy with

from __future__ import unicode_literals

Otherwise, you have to say e.g.

mesh = Mesh.from_file(b'rectangle_tri.mesh')

(The "b" would become superfluous.)


sf...@googlecode.com

unread,
Dec 20, 2011, 8:15:55 AM12/20/11
to sfepy-...@googlegroups.com
Updates:
Labels: EasyToFix

Comment #1 on issue 160 by robert.c...@gmail.com: Test for "basestring"

Looks like a good thing to do, thanks for creating the issue.

Do you have other ideas to python 3 compatibility?

sf...@googlecode.com

unread,
Dec 20, 2011, 8:28:00 AM12/20/11
to sfepy-...@googlegroups.com

Comment #2 on issue 160 by torsten....@gmail.com: Test for "basestring"

Import as many future statemens as feasible
("division", "absolute_imports", "unicode_literals", "print_function") in
every module. "division" and "absolute_imports" are especially interesting
in my opinion.

Replace % with .format().

By the way, for Python 3, the "basestring" has got to be re-changed
to "str". But this will be done by 2to3 automatically.


sf...@googlecode.com

unread,
Dec 21, 2011, 6:12:07 AM12/21/11
to sfepy-...@googlegroups.com

Comment #3 on issue 160 by robert.c...@gmail.com: Test for "basestring"

I would like to have a way that would work both for python 2 with "from
__future__ import unicode_literals" and python 3. Would using
types.StringType help?

I do not have a working python 3 installation yet, still using 2.6.6... I
can try 2.7. and use -3 flag to simulate it, right?

I will create a new issue for python 3 porting to discuss this.

sf...@googlecode.com

unread,
Dec 21, 2011, 7:03:30 AM12/21/11
to sfepy-...@googlegroups.com

Comment #4 on issue 160 by torsten....@gmail.com: Test for "basestring"

You can start the modules with

try:
basestring
except:
basestring = str


sf...@googlecode.com

unread,
Dec 21, 2011, 7:39:46 AM12/21/11
to sfepy-...@googlegroups.com
Updates:
Status: Started

Comment #5 on issue 160 by robert.c...@gmail.com: Test for "basestring"

Could you test using "git clone git://github.com/rc/sfepy.git"?


sf...@googlecode.com

unread,
Dec 21, 2011, 10:20:21 AM12/21/11
to sfepy-...@googlegroups.com

Comment #6 on issue 160 by torsten....@gmail.com: Test for "basestring"

Sorry, not this year. I don't use Git but the plain release. I'll look
into it on the first days of the new year.

sf...@googlecode.com

unread,
Dec 22, 2011, 6:15:17 AM12/22/11
to sfepy-...@googlegroups.com

Comment #7 on issue 160 by robert.c...@gmail.com: Test for "basestring"

Ok, thanks! As a sidenote: using git is not that difficult, and you get
fresh fixes easily, see [1].

[1] http://docs.sfepy.org/doc-devel/dev/gitwash/index.html#using-git

sf...@googlecode.com

unread,
Jan 2, 2012, 11:17:51 AM1/2/12
to sfepy-...@googlegroups.com

Comment #8 on issue 160 by torsten....@gmail.com: Test for "basestring"

Yes, it has worked. No "b" was necessary anymore. Thank you!

sf...@googlecode.com

unread,
Jan 2, 2012, 11:21:54 AM1/2/12
to sfepy-...@googlegroups.com
Updates:
Status: Fixed

Comment #9 on issue 160 by robert.c...@gmail.com: Test for "basestring"

Thanks for verifying, let's close this.

sf...@googlecode.com

unread,
Jan 30, 2012, 8:31:53 AM1/30/12
to sfepy-...@googlegroups.com
Updates:
Status: Migrated

Comment #10 on issue 160 by robert.c...@gmail.com: Test for "basestring"
instead of "str"
http://code.google.com/p/sfepy/issues/detail?id=160#c10

Migrated to http://github.com/sfepy/sfepy/issues/162

Reply all
Reply to author
Forward
0 new messages