{"action":"created","issue":{"url":"https://api.github.com/repos/rfk/pypyjs/issues/109","labels_url":"https://api.github.com/repos/rfk/pypyjs/issues/109/labels{/name}","comments_url":"https://api.github.com/repos/rfk/pypyjs/issues/109/comments","events_url":"https://api.github.com/repos/rfk/pypyjs/issues/109/events","html_url":"https://github.com/rfk/pypyjs/issues/109","id":77544454,"number":109,"title":"test import errors / which modules are importable?!?","user":{"login":"jedie","id":71315,"avatar_url":"https://avatars.githubusercontent.com/u/71315?v=3","gravatar_id":"","url":"https://api.github.com/users/jedie","html_url":"https://github.com/jedie","followers_url":"https://api.github.com/users/jedie/followers","following_url":"https://api.github.com/users/jedie/following{/other_user}","gists_url":"https://api.github.com/users/jedie/gists{/gist_id}","starred_url":"https://api.github.com/users/jedie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jedie/subscriptions","organizations_url":"https://api.github.com/users/jedie/orgs","repos_url":"https://api.github.com/users/jedie/repos","events_url":"https://api.github.com/users/jedie/events{/privacy}","received_events_url":"https://api.github.com/users/jedie/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-18T07:46:31Z","updated_at":"2015-05-21T14:21:49Z","closed_at":null,"body":"In my https://github.com/rfk/pypyjs/pull/96 i have a test about module imports.\r\n\r\nMany modules are in file system, but can't be imported, see complete list here: https://gist.github.com/jedie/8f302ddabd9876f5c927/\r\n\r\nI used a hackish way to get a list of all existing module files with this:\r\n```\r\n        libpath = website_path(\"js/pypy.js-0.3.0/lib/modules\")\r\n        module_names = [\r\n            os.path.splitext(item)[0]\r\n            for item in sorted(os.listdir(libpath))\r\n            if not item.startswith(\"_\") and item.endswith(\".py\")\r\n        ]\r\n```\r\n\r\nIMHO some of the existing files, are useless. e.g.: all *Server files like CGIHTTPServer\r\n\r\nAny idea what i should do with this test?!?\r\nIs there a way to get more information than ```No module named FooBar``` ?\r\n\r\nShould i only test a few modules? e.g.: module_bundler.BUILTIN_MODULES ?\r\n\r\nEDIT: Or should i parse https://github.com/rfk/pypyjs/blob/master/website/js/pypy.js-0.3.0/lib/modules/index.json ?"},"comment":{"url":"https://api.github.com/repos/rfk/pypyjs/issues/comments/104293782","html_url":"https://github.com/rfk/pypyjs/issues/109#issuecomment-104293782","issue_url":"https://api.github.com/repos/rfk/pypyjs/issues/109","id":104293782,"user":{"login":"jedie","id":71315,"avatar_url":"https://avatars.githubusercontent.com/u/71315?v=3","gravatar_id":"","url":"https://api.github.com/users/jedie","html_url":"https://github.com/jedie","followers_url":"https://api.github.com/users/jedie/followers","following_url":"https://api.github.com/users/jedie/following{/other_user}","gists_url":"https://api.github.com/users/jedie/gists{/gist_id}","starred_url":"https://api.github.com/users/jedie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jedie/subscriptions","organizations_url":"https://api.github.com/users/jedie/orgs","repos_url":"https://api.github.com/users/jedie/repos","events_url":"https://api.github.com/users/jedie/events{/privacy}","received_events_url":"https://api.github.com/users/jedie/received_events","type":"User","site_admin":false},"created_at":"2015-05-21T14:21:49Z","updated_at":"2015-05-21T14:21:49Z","body":"> In this case: match[0] will be: \"import random\\nprint random.file\"\r\n> The imports value in return Promise.resolve(imports); is: [[\"import random\\nprint random.file\"]]\r\n\r\nI have seen these output with:\r\n```\r\n--------------------- website/js/pypy.js-0.3.0/lib/pypy.js ---------------------\r\nindex d31bc2a..92fd4ca 100644\r\n@@ -686,10 +686,14 @@ PyPyJS.prototype._repl_loop = function _repl_loop(prmpt, ps1) {\r\n //\r\n var importStatementRE = /(from\\s+([a-zA-Z0-9_\\.]+)\\s+)?import\\s+\\(?\\s*([a-zA-Z0-9_\\.\\*]+(\\s+as\\s+[a-zA-Z0-9_]+)?\\s*,?\\s*)+\\s*\\)?/g\r\n PyPyJS.prototype.findImportedNames = function findImportedNames(code) {\r\n   var match = null;\r\n   var imports = [];\r\n   importStatementRE.lastIndex = 0;\r\n   while ((match = importStatementRE.exec(code)) !== null) {\r\n+    window.vm.stderr(\"Import code match[0]: [\"+JSON.stringify(match[0])+\"]\\n\");\r\n     var relmod = match[2];\r\n     if (relmod) {\r\n       relmod = relmod + \".\";\r\n@@ -697,6 +701,7 @@ PyPyJS.prototype.findImportedNames = function findImportedNames(code) {\r\n       relmod = \"\";\r\n     }\r\n     var submods = match[0].split(\"import\")[1];\r\n+    window.vm.stderr(\"submods 1: [\"+JSON.stringify(submods)+\"]\\n\");\r\n     while (submods && /[\\s(]/.test(submods.charAt(0))) {\r\n       submods = submods.substr(1);\r\n     }\r\n@@ -707,9 +712,12 @@ PyPyJS.prototype.findImportedNames = function findImportedNames(code) {\r\n     for (var i = 0; i < submods.length; i++) {\r\n       var submod = submods[i];\r\n       submod = submod.split(/\\s*as\\s*/)[0];\r\n+      window.vm.stderr(\"submods 2: [\"+JSON.stringify(submods)+\"]\\n\");\r\n+      window.vm.stderr(\"relmod + submod: [\"+JSON.stringify(relmod + submod)+\"]\\n\");\r\n       imports.push(relmod + submod);\r\n     }\r\n   }\r\n+  window.vm.stderr(\"imports: [\"+JSON.stringify(imports)+\"]\\n\");\r\n   return Promise.resolve(imports);\r\n }\r\n```"}}