Am 24.10.2015 um 20:26 schrieb davecortesi:
> Looking at the updated imphookapi.py and also the hook-six.moves,
> there is something that puzzles me. You say that the typical use of
> the add_runtime_module() method would be,
>
> >   api.add_runtime_module(api.module_name)
>
> and that is how the six.moves hook uses it. What I don't get is,
> aip.module_name has already been imported, no? It is the same as the
> name of the hook file, and the reason why the hook is being executed.
>
> So why does the name of the imported module need to be added?

 1. Pre Safe Import Hooks are performed *prior* to importing the module.
    When running the hook, the modules parent package has already been
    imported and ti's `__path__` is set up. But the module is just about
    to be imported.


 2. Our typical usecase of the hook is for replacing the module for
    which the hook is for by a runtime-module (aka dummy module). Eg.
    hook-gi.repository.GObject.py should replace
    "gi.repository.GObject". so these two lines are equivalent:

        api.add_runtime_module(api.module_name)
        api.add_runtime_module("gi.repository.GObject")


    Yes, the name is the same as the filename (except of the `hook-`
    prefix).

    I decided to use the first, since it eases creating new hooks. One
    only needs to copy an existing ony, since the module-name is in the
    filename, but not in the code (which would be redundant).


 3. The name needs to be added to allow other modules, too. See the last
    line in hook-six.moves.

 4. Do you suggest changing the method's signature into

        api.add_runtime_module(module_name=None)


    And if `None`, use the api.module_name? IMHO this would make sense.
    Martin, what do you think?


-- 

Schönen Gruß
Hartmut Goebel
Dipl.-Informatiker (univ), CISSP, CSSLP
Information Security Management, Security Governance, Secure Software
Development

Goebel Consult, Landshut
http://www.goebel-consult.de

Blog:
http://www.goebel-consult.de/blog/fortbildung-iso-27001-lead-implementer
Kolumne:
http://www.cissp-gefluester.de/2010-11-it-sicherheit-im-unternehmen-eine-interne-oder-externe-angelegenheit


-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/d/optout.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to