homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author galun.guy
Recipients galun.guy
Date 2020年01月14日.15:47:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1579016858.37.0.175118756285.issue39331@roundup.psfhosted.org>
In-reply-to
Content
When encountering an import that should be removed in Python 3 (e.g. "from itertools import izip"), 2to3 changes it a blank line, which may cause a runtime error if that import was indented:
error: module importing failed: expected an indented block (ptypes.py, line 10)
 File "temp.py", line 1, in <module>
 File "./lldbmacros/xnu.py", line 771, in <module>
 from memory import *
 File "./lldbmacros/memory.py", line 11, in <module>
 import macho
 File "./lldbmacros/macho.py", line 3, in <module>
 from macholib import MachO as macho
 File "./lldbmacros/macholib/MachO.py", line 10, in <module>
 from .mach_o import MH_FILETYPE_SHORTNAMES, LC_DYSYMTAB, LC_SYMTAB
 File "./lldbmacros/macholib/mach_o.py", line 16, in <module>
 from macholib.ptypes import p_uint32, p_uint64, Structure, p_long, pypackable
Relevant section before 2to3:
try:
 from itertools import izip, imap
except ImportError:
 izip, imap = zip, map
from itertools import chain, starmap
And after 2to3:
try:
 
except ImportError:
 izip, imap = zip, map
from itertools import chain, starmap
* Side note:
This specific case may only be problematic with scripts that are partially aware of Python 3, otherwise they wouldn't try-catch that import.
* Proposed solution:
In case of that kind of import being the single line of an indented block, change it to "pass" instead of a blank line.
History
Date User Action Args
2020年01月14日 15:47:38galun.guysetrecipients: + galun.guy
2020年01月14日 15:47:38galun.guysetmessageid: <1579016858.37.0.175118756285.issue39331@roundup.psfhosted.org>
2020年01月14日 15:47:38galun.guylinkissue39331 messages
2020年01月14日 15:47:38galun.guycreate

AltStyle によって変換されたページ (->オリジナル) /