-4

When I have a python shared object file (.so) in my sys.path, I can simply do :

import _ctypes

And it will import python2.7/lib-dynload/_ctypes.so.

However, if I use a zipfile called tmp.zip that contains :

Hello/_World.so

with world.so containing a well formatted init_World function, then :

Python 2.7.10 (default, Jun  1 2015, 18:05:38)
[GCC 4.9.2] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.insert(0, 'tmp.zip')
>>> import _World
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
zipimport.ZipImportError: can't find module _World

I read it was impossible to load shared object files outside a filesystem in C.
Does this mean what I’m trying to achieve is impossible and that _World.soshould be extracted from the archive ?

I’m only interested about doing it directly with thezipimport. I know there are other ways of doing it like extracting the archive manually and create files.

user2284570
  • 2,891
  • 3
  • 26
  • 74
  • 2
    You asked about this in chat. Please list all your arbitrary restrictions as you had stated that you can't use `ctypes` and some other modules in chat. –  Aug 05 '16 at 00:00
  • @tristan : i’d like to explain how the tags you removed are relevant in chat. – user2284570 Aug 05 '16 at 00:22
  • That's okay, you have an answer to your question (via the documentation) and more visibility onto this question is likely going to be the opposite of helpful to others in the future. –  Aug 05 '16 at 00:22
  • @tristan : thanks for trying to help me. but basically, I was trying to escape a sandbox that runs on a website for testing python code. There are lot of other details. But it seems you ban peoples in the python chat room without preventing/or asking to stop. – user2284570 Aug 05 '16 at 00:27
  • 2
    We have a set of room rules that you're welcome to read. I rolled back the tags you added as none of that is explained or relevant _in the content you have provided here_. –  Aug 05 '16 at 00:40
  • @tristan : I don’t want Windows or osx specific answers. – user2284570 Aug 05 '16 at 01:02
  • Then write a more specific question that explains what you're actually trying to do, what limitations exist in your platform (if any), and at least skim the documentation before posting and you'll have a better experience next time. –  Aug 05 '16 at 01:06
  • @tristan : to make short, the remote environment is well a known paas. the question wouldn’t have any value if I had the specific tag directly *(it would violate the [tos](http://stackexchange.com/legal/terms-of-service]))*. So I can’t add too much details. But I agree some tags are irrelevant. – user2284570 Aug 05 '16 at 01:17
  • These are details that go in the question. When you ask a question on StackOverflow, multiple people spend effort trying to help you. The harder you make it to figure out what you're asking and need, the more time others spend. –  Aug 05 '16 at 01:34

1 Answers1

-3

It seems I have definitely huge problems at reading texts entirely :

This module adds the ability to import Python modules (*.py, *.py[co]) and packages from ZIP-format archives..

So the answer is clear, I’m trying to achieve something impossible… There’s no way to do escape the python sandbox with that since it can’t be done even with a normal environment.

user2284570
  • 2,891
  • 3
  • 26
  • 74