[
https://issues.apache.org/jira/browse/IMPALA-11974?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17713305#comment-17713305
]
ASF subversion and git services commented on IMPALA-11974:
----------------------------------------------------------
Commit df2e03ce0bc54cfd142c39a4e48f8b555248c969 in impala's branch
refs/heads/master from Michael Smith
[ https://gitbox.apache.org/repos/asf?p=impala.git;h=df2e03ce0 ]
IMPALA-11974: Fix xrange, split in collect_diagnostics.py
Python3 deprecates xrange operator, this commit replaces it with the
range operator similar to earlier replacements in IMPALA-11974.
Adds universal_newlines to Popen so that we return text in Python 3.
Testing:
- Ran '$IMPALA_HOME/bin/diagnostics/collect_diagnostics.py --pid <pid>
--minidumps 2 1 --minidumps_dir $IMPALA_HOME/logs/cluster/minidumps
--stacks 2 1' with Python 2/3 and inspected the results.
Change-Id: I52f075825d47613293b106a7c50d4499c19cd3f4
Reviewed-on: http://gerrit.cloudera.org:8080/19746
Reviewed-by: Impala Public Jenkins <[email protected]>
Tested-by: Impala Public Jenkins <[email protected]>
> Fix range/xrange/map/filter/ifilter/zip/izip issues regarding iterators being
> lazy
> ----------------------------------------------------------------------------------
>
> Key: IMPALA-11974
> URL: https://issues.apache.org/jira/browse/IMPALA-11974
> Project: IMPALA
> Issue Type: Sub-task
> Components: Infrastructure
> Affects Versions: Impala 4.3.0
> Reporter: Joe McDonnell
> Assignee: Joe McDonnell
> Priority: Major
> Fix For: Impala 4.3.0
>
>
> Python 3 made map, range, zip, and filter lazy. That means that existing
> Python code that relies on this turning into a list immediately need
> adjustments:
> {noformat}
> # Python 2:
> range(5) == [0,1,2,3,4]
> True
> # Python 3:
> range(5) == [0,1,2,3,4]
> False
> # Python 3 fix:
> list(range(5)) == [0,1,2,3,4]
> True
> # Same deal with map, zip, filter, etc.{noformat}
> This example is basic, but this applies across the board.
> Since the ordinary operators like range, filter, etc are now lazy, the old
> lazy ones have been removed (xrange, ifilter, izip). Those need to be
> replaced, and the future package provides implementations of range, zip, map,
> filter, etc.
> See:
> [https://python-future.org/compatible_idioms.html#xrange]
> [https://python-future.org/compatible_idioms.html#range]
> [https://python-future.org/compatible_idioms.html#map]
> [https://python-future.org/compatible_idioms.html#imap]
> etc
> This corresponds to these pylint checks:
> xrange-builtin
> range-builtin-not-iterating
> map-builtin-not-iterating
> zip-builtin-not-iterating
> filter-builtin-not-iterating
> reduce-builtin
> deprecated-itertools-function
> Futurize has some tools to help:
> libfuturize.fixes.fix_xrange_with_import
> lib2to3.fixes.fix_map
> lib2to3.fixes.fix_filter
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]