[issue13938] 2to3 fails to convert types.StringTypes appropriately

Mark Hammond report at bugs.python.org
Sat Feb 4 06:31:33 CET 2012


New submission from Mark Hammond <skippy.hammond at gmail.com>:

test_types.py converts "types.StringTypes" to "str" - but types.StringTypes is a tuple, so expressions like "type(x) in type.StringTypes" fails after conversion with "TypeError: argument of type 'type' is not iterable"

Attaching a fix and test.

Note that the fixer still seems "strange" after this fix - types.StringType gets converted to "bytes" but types.StringTypes uses str.  This means the expression "type.StringType in type.StringTypes" evaluates to True in 2.x but False once converted - however, that should probably be tackled in a different bug - the fact the expression now causes a TypeError once converted is more blatantly wrong and the focus of this bug.

----------
components: 2to3 (2.x to 3.x conversion tool)
files: fix_stringtypes_fixer.patch
keywords: patch
messages: 152592
nosy: mhammond
priority: normal
severity: normal
status: open
title: 2to3 fails to convert types.StringTypes appropriately
versions: Python 3.2, Python 3.3, Python 3.4
Added file: http://bugs.python.org/file24415/fix_stringtypes_fixer.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13938>
_______________________________________


More information about the Python-bugs-list mailing list