Opened 14 years ago
Closed 14 years ago
#360 closed defect (fixed)
StringType and unicode
Reported by: | wilsonr | Owned by: | ole |
---|---|---|---|
Priority: | low | Milestone: | |
Component: | Other | Version: | |
Severity: | normal | Keywords: | unicode StringType |
Cc: |
Description
Using the 'json' module in run_tsudat.py allows the injection of unicode strings into ANUGA. This highlights a shortcoming in type testing.
The code fragment:
if type(my_string) == type(types.StringType):
will not do what is required if my_string is a unicode string. What should be done is the more future-proof:
if isinstance(my_string, basestring):
which handles normal strings as well as unicode strings correctly.
Change History (2)
comment:1 Changed 14 years ago by wilsonr
comment:2 Changed 14 years ago by wilsonr
- Resolution set to fixed
- Status changed from new to closed
Made changes suggested above.
Also changed uses of types.ListType to list, etc.
Removed import of types module where possible.
Note: See
TracTickets for help on using
tickets.
See http://docs.python.org/library/functions.html#basestring for the gospel.