Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Traceback (most recent call last): File "/home/marijn/Android/Sdk/ndk/25.1.8937393/prebuilt/linux-x86_64/bin/ndk-gdb.py", line 951, in <module> main() File "/home/marijn/Android/Sdk/ndk/25.1.8937393/prebuilt/linux-x86_64/bin/ndk-gdb.py", line 882, in main device.shell_nocheck(["run-as", pkg_name, "kill", "-9"] + kill_pids)TypeError: can only concatenate list (not "map") to listThis -gdb.py-gdb.pyis another Python 2 -> Python 3 conversion problem just like #1763: #304

Closed
Gadgetflow7 opened this issue Sep 28, 2022 · 1 comment

Comments

@Gadgetflow7
Copy link

    This is another Python 2 -> Python 3 conversion problem just like #1763:

The current code is as follows:

        kill_pids = map(str, kill_pids)
        if kill_pids:
            log("Killing processes: {}".format(", ".join(kill_pids)))
            device.shell_nocheck(["run-as", pkg_name, "kill", "-9"] + kill_pids)

In Python 2, map() returns a list which you can freely concatenate to another list. In Python 3 map() returns a lazy map object (a generator) and can't be immediately concatenated to a list. Besides, map() is discouraged in favour of generator expressions, or in this specific case a list comprehension:

kill_pids = [str(pid) for pid in kill_pids]

EDIT: You can however also use some_list.extend(<iterable, i.e. generator>) to let the list iterate a generator and append every individual item to itself.

Originally posted by @MarijnS95 in android/ndk#1764 (comment)

@neveruh442
Copy link

    This is another Python 2 -> Python 3 conversion problem just like #1763:

The current code is as follows:

        kill_pids = map(str, kill_pids)
        if kill_pids:
            log("Killing processes: {}".format(", ".join(kill_pids)))
            device.shell_nocheck(["run-as", pkg_name, "kill", "-9"] + kill_pids)

In Python 2, map() returns a list which you can freely concatenate to another list. In Python 3 map() returns a lazy map object (a generator) and can't be immediately concatenated to a list. Besides, map() is discouraged in favour of generator expressions, or in this specific case a list comprehension:

kill_pids = [str(pid) for pid in kill_pids]

EDIT: You can however also use some_list.extend(<iterable, i.e. generator>) to let the list iterate a generator and append every individual item to itself.

Originally posted by @MarijnS95 in android/ndk#1764 (comment)

> `[]()****`

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants