{"action":"created","comment":{"url":"https://api.github.com/repos/dropbox/pyston/pulls/comments/24947497","id":24947497,"diff_hunk":"@@ -623,6 +625,65 @@ static PyObject* slot_tp_iternext(PyObject* self) noexcept {\n     return call_method(self, \"next\", &next_str, \"()\");\n }\n \n+static PyObject* slot_tp_getattro(PyObject* self, PyObject* name) {\n+    static PyObject* getattribute_str = NULL;\n+    return call_method(self, \"__getattribute__\", &getattribute_str, \"(O)\", name);\n+}\n+\n+static PyObject* call_attribute(PyObject* self, PyObject* attr, PyObject* name) {\n+    PyObject* res, * descr = NULL;\n+    descrgetfunc f = Py_TYPE(attr)->tp_descr_get;\n+\n+    if (f != NULL) {\n+        descr = f(attr, self, (PyObject*)(Py_TYPE(self)));\n+        if (descr == NULL)\n+            return NULL;\n+        else\n+            attr = descr;\n+    }\n+    res = runtimeCall(attr, ArgPassSpec(1, 0, true, true), name, NULL, NULL, NULL, NULL);\n+    Py_XDECREF(descr);\n+    return res;\n+}\n+\n+static PyObject* slot_tp_getattr_hook(PyObject* self, PyObject* name) {\n+    PyObject* getattr, *getattribute, * res = NULL;\n+    static PyObject* getattribute_str = NULL;\n+    static PyObject* getattr_str = NULL;\n+\n+    /* speed hack: we could use lookup_maybe, but that would resolve the\n+         method fully for each attribute lookup for classes with\n+         __getattr__, even when the attribute is present. So we use\n+         _PyType_Lookup and create the method only when needed, with\n+         call_attribute. */\n+    getattr = typeLookup(self->cls, _getattr_str, NULL);\n+    if (getattr == NULL) {\n+        /* No __getattr__ hook: use a simpler dispatcher */\n+        self->cls->tp_getattro = slot_tp_getattro;\n+        return slot_tp_getattro(self, name);\n+    }\n+    /* speed hack: we could use lookup_maybe, but that would resolve the\n+         method fully for each attribute lookup for classes with\n+         __getattr__, even when self has the default __getattribute__\n+         method. So we use _PyType_Lookup and create the method only when\n+         needed, with call_attribute. */\n+    getattribute = typeLookup(self->cls, _getattribute_str, NULL);\n+    try {\n+        if (getattribute == NULL\n+            || (Py_TYPE(getattribute) == wrapperdescr_cls\n+                && ((BoxedWrapperDescriptor*)getattribute)->wrapped == (void*)PyObject_GenericGetAttr)) {\n+            res = PyObject_GenericGetAttr(self, name);\n+        } else {\n+            res = call_attribute(self, getattribute, name);","path":"src/capi/typeobject.cpp","position":62,"original_position":62,"commit_id":"b7a8a92343114bb6f990d0db772177167dcc98ff","original_commit_id":"b7a8a92343114bb6f990d0db772177167dcc98ff","user":{"login":"kmod","id":271916,"avatar_url":"https://avatars.githubusercontent.com/u/271916?v=3","gravatar_id":"","url":"https://api.github.com/users/kmod","html_url":"https://github.com/kmod","followers_url":"https://api.github.com/users/kmod/followers","following_url":"https://api.github.com/users/kmod/following{/other_user}","gists_url":"https://api.github.com/users/kmod/gists{/gist_id}","starred_url":"https://api.github.com/users/kmod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kmod/subscriptions","organizations_url":"https://api.github.com/users/kmod/orgs","repos_url":"https://api.github.com/users/kmod/repos","events_url":"https://api.github.com/users/kmod/events{/privacy}","received_events_url":"https://api.github.com/users/kmod/received_events","type":"User","site_admin":false},"body":"If call_attribute uses Pyston-style exceptions, we should probably have the try-catch just around that, and make sure to do PyErr_Clear after the PyObject_GenericGetAttr case (which throws a CAPI exception).","created_at":"2015-02-18T22:28:32Z","updated_at":"2015-02-18T22:28:32Z","html_url":"https://github.com/dropbox/pyston/pull/295#discussion_r24947497","pull_request_url":"https://api.github.com/repos/dropbox/pyston/pulls/295","_links":{"self":{"href":"https://api.github.com/repos/dropbox/pyston/pulls/comments/24947497"},"html":{"href":"https://github.com/dropbox/pyston/pull/295#discussion_r24947497"},"pull_request":{"href":"https://api.github.com/repos/dropbox/pyston/pulls/295"}}},"pull_request":{"url":"https://api.github.com/repos/dropbox/pyston/pulls/295","id":29136114,"html_url":"https://github.com/dropbox/pyston/pull/295","diff_url":"https://github.com/dropbox/pyston/pull/295.diff","patch_url":"https://github.com/dropbox/pyston/pull/295.patch","issue_url":"https://api.github.com/repos/dropbox/pyston/issues/295","number":295,"state":"open","locked":false,"title":"add tp_getattr support, PyCFunction_NewEx, and most of PyNumber_Int's behavior","user":{"login":"toshok","id":24245,"avatar_url":"https://avatars.githubusercontent.com/u/24245?v=3","gravatar_id":"","url":"https://api.github.com/users/toshok","html_url":"https://github.com/toshok","followers_url":"https://api.github.com/users/toshok/followers","following_url":"https://api.github.com/users/toshok/following{/other_user}","gists_url":"https://api.github.com/users/toshok/gists{/gist_id}","starred_url":"https://api.github.com/users/toshok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toshok/subscriptions","organizations_url":"https://api.github.com/users/toshok/orgs","repos_url":"https://api.github.com/users/toshok/repos","events_url":"https://api.github.com/users/toshok/events{/privacy}","received_events_url":"https://api.github.com/users/toshok/received_events","type":"User","site_admin":false},"body":"the select module uses tp_getattr to implement the `poll` type, so add places where we need to call it.\r\n\r\nPyCFunction_NewEx was also needed (the tp_getattr implementation called it.)\r\n\r\nFinally, PyNumber_Int was needed to run the changes to select_test.py.\r\n","created_at":"2015-02-11T22:45:15Z","updated_at":"2015-02-18T22:28:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"90b0da81f59f2652fcc39e0709b2c26245a6631e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dropbox/pyston/pulls/295/commits","review_comments_url":"https://api.github.com/repos/dropbox/pyston/pulls/295/comments","review_comment_url":"https://api.github.com/repos/dropbox/pyston/pulls/comments/{number}","comments_url":"https://api.github.com/repos/dropbox/pyston/issues/295/comments","statuses_url":"https://api.github.com/repos/dropbox/pyston/statuses/b7a8a92343114bb6f990d0db772177167dcc98ff","head":{"label":"toshok:tp_getattr","ref":"tp_getattr","sha":"b7a8a92343114bb6f990d0db772177167dcc98ff","user":{"login":"toshok","id":24245,"avatar_url":"https://avatars.githubusercontent.com/u/24245?v=3","gravatar_id":"","url":"https://api.github.com/users/toshok","html_url":"https://github.com/toshok","followers_url":"https://api.github.com/users/toshok/followers","following_url":"https://api.github.com/users/toshok/following{/other_user}","gists_url":"https://api.github.com/users/toshok/gists{/gist_id}","starred_url":"https://api.github.com/users/toshok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toshok/subscriptions","organizations_url":"https://api.github.com/users/toshok/orgs","repos_url":"https://api.github.com/users/toshok/repos","events_url":"https://api.github.com/users/toshok/events{/privacy}","received_events_url":"https://api.github.com/users/toshok/received_events","type":"User","site_admin":false},"repo":{"id":26560265,"name":"pyston","full_name":"toshok/pyston","owner":{"login":"toshok","id":24245,"avatar_url":"https://avatars.githubusercontent.com/u/24245?v=3","gravatar_id":"","url":"https://api.github.com/users/toshok","html_url":"https://github.com/toshok","followers_url":"https://api.github.com/users/toshok/followers","following_url":"https://api.github.com/users/toshok/following{/other_user}","gists_url":"https://api.github.com/users/toshok/gists{/gist_id}","starred_url":"https://api.github.com/users/toshok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toshok/subscriptions","organizations_url":"https://api.github.com/users/toshok/orgs","repos_url":"https://api.github.com/users/toshok/repos","events_url":"https://api.github.com/users/toshok/events{/privacy}","received_events_url":"https://api.github.com/users/toshok/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/toshok/pyston","description":"An open-source Python implementation using JIT techniques. ","fork":true,"url":"https://api.github.com/repos/toshok/pyston","forks_url":"https://api.github.com/repos/toshok/pyston/forks","keys_url":"https://api.github.com/repos/toshok/pyston/keys{/key_id}","collaborators_url":"https://api.github.com/repos/toshok/pyston/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/toshok/pyston/teams","hooks_url":"https://api.github.com/repos/toshok/pyston/hooks","issue_events_url":"https://api.github.com/repos/toshok/pyston/issues/events{/number}","events_url":"https://api.github.com/repos/toshok/pyston/events","assignees_url":"https://api.github.com/repos/toshok/pyston/assignees{/user}","branches_url":"https://api.github.com/repos/toshok/pyston/branches{/branch}","tags_url":"https://api.github.com/repos/toshok/pyston/tags","blobs_url":"https://api.github.com/repos/toshok/pyston/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/toshok/pyston/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/toshok/pyston/git/refs{/sha}","trees_url":"https://api.github.com/repos/toshok/pyston/git/trees{/sha}","statuses_url":"https://api.github.com/repos/toshok/pyston/statuses/{sha}","languages_url":"https://api.github.com/repos/toshok/pyston/languages","stargazers_url":"https://api.github.com/repos/toshok/pyston/stargazers","contributors_url":"https://api.github.com/repos/toshok/pyston/contributors","subscribers_url":"https://api.github.com/repos/toshok/pyston/subscribers","subscription_url":"https://api.github.com/repos/toshok/pyston/subscription","commits_url":"https://api.github.com/repos/toshok/pyston/commits{/sha}","git_commits_url":"https://api.github.com/repos/toshok/pyston/git/commits{/sha}","comments_url":"https://api.github.com/repos/toshok/pyston/comments{/number}","issue_comment_url":"https://api.github.com/repos/toshok/pyston/issues/comments/{number}","contents_url":"https://api.github.com/repos/toshok/pyston/contents/{+path}","compare_url":"https://api.github.com/repos/toshok/pyston/compare/{base}...{head}","merges_url":"https://api.github.com/repos/toshok/pyston/merges","archive_url":"https://api.github.com/repos/toshok/pyston/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/toshok/pyston/downloads","issues_url":"https://api.github.com/repos/toshok/pyston/issues{/number}","pulls_url":"https://api.github.com/repos/toshok/pyston/pulls{/number}","milestones_url":"https://api.github.com/repos/toshok/pyston/milestones{/number}","notifications_url":"https://api.github.com/repos/toshok/pyston/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/toshok/pyston/labels{/name}","releases_url":"https://api.github.com/repos/toshok/pyston/releases{/id}","created_at":"2014-11-12T22:56:58Z","updated_at":"2015-02-18T18:38:17Z","pushed_at":"2015-02-18T18:38:17Z","git_url":"git://github.com/toshok/pyston.git","ssh_url":"git@github.com:toshok/pyston.git","clone_url":"https://github.com/toshok/pyston.git","svn_url":"https://github.com/toshok/pyston","homepage":"https://tech.dropbox.com/2014/04/introducing-pyston-an-upcoming-jit-based-python-implementation/","size":13832,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dropbox:master","ref":"master","sha":"0ba1cac67ca60a78272340ca392a33876c80114a","user":{"login":"dropbox","id":559357,"avatar_url":"https://avatars.githubusercontent.com/u/559357?v=3","gravatar_id":"","url":"https://api.github.com/users/dropbox","html_url":"https://github.com/dropbox","followers_url":"https://api.github.com/users/dropbox/followers","following_url":"https://api.github.com/users/dropbox/following{/other_user}","gists_url":"https://api.github.com/users/dropbox/gists{/gist_id}","starred_url":"https://api.github.com/users/dropbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dropbox/subscriptions","organizations_url":"https://api.github.com/users/dropbox/orgs","repos_url":"https://api.github.com/users/dropbox/repos","events_url":"https://api.github.com/users/dropbox/events{/privacy}","received_events_url":"https://api.github.com/users/dropbox/received_events","type":"Organization","site_admin":false},"repo":{"id":18320947,"name":"pyston","full_name":"dropbox/pyston","owner":{"login":"dropbox","id":559357,"avatar_url":"https://avatars.githubusercontent.com/u/559357?v=3","gravatar_id":"","url":"https://api.github.com/users/dropbox","html_url":"https://github.com/dropbox","followers_url":"https://api.github.com/users/dropbox/followers","following_url":"https://api.github.com/users/dropbox/following{/other_user}","gists_url":"https://api.github.com/users/dropbox/gists{/gist_id}","starred_url":"https://api.github.com/users/dropbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dropbox/subscriptions","organizations_url":"https://api.github.com/users/dropbox/orgs","repos_url":"https://api.github.com/users/dropbox/repos","events_url":"https://api.github.com/users/dropbox/events{/privacy}","received_events_url":"https://api.github.com/users/dropbox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dropbox/pyston","description":"An open-source Python implementation using JIT techniques. ","fork":false,"url":"https://api.github.com/repos/dropbox/pyston","forks_url":"https://api.github.com/repos/dropbox/pyston/forks","keys_url":"https://api.github.com/repos/dropbox/pyston/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dropbox/pyston/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dropbox/pyston/teams","hooks_url":"https://api.github.com/repos/dropbox/pyston/hooks","issue_events_url":"https://api.github.com/repos/dropbox/pyston/issues/events{/number}","events_url":"https://api.github.com/repos/dropbox/pyston/events","assignees_url":"https://api.github.com/repos/dropbox/pyston/assignees{/user}","branches_url":"https://api.github.com/repos/dropbox/pyston/branches{/branch}","tags_url":"https://api.github.com/repos/dropbox/pyston/tags","blobs_url":"https://api.github.com/repos/dropbox/pyston/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dropbox/pyston/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dropbox/pyston/git/refs{/sha}","trees_url":"https://api.github.com/repos/dropbox/pyston/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dropbox/pyston/statuses/{sha}","languages_url":"https://api.github.com/repos/dropbox/pyston/languages","stargazers_url":"https://api.github.com/repos/dropbox/pyston/stargazers","contributors_url":"https://api.github.com/repos/dropbox/pyston/contributors","subscribers_url":"https://api.github.com/repos/dropbox/pyston/subscribers","subscription_url":"https://api.github.com/repos/dropbox/pyston/subscription","commits_url":"https://api.github.com/repos/dropbox/pyston/commits{/sha}","git_commits_url":"https://api.github.com/repos/dropbox/pyston/git/commits{/sha}","comments_url":"https://api.github.com/repos/dropbox/pyston/comments{/number}","issue_comment_url":"https://api.github.com/repos/dropbox/pyston/issues/comments/{number}","contents_url":"https://api.github.com/repos/dropbox/pyston/contents/{+path}","compare_url":"https://api.github.com/repos/dropbox/pyston/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dropbox/pyston/merges","archive_url":"https://api.github.com/repos/dropbox/pyston/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dropbox/pyston/downloads","issues_url":"https://api.github.com/repos/dropbox/pyston/issues{/number}","pulls_url":"https://api.github.com/repos/dropbox/pyston/pulls{/number}","milestones_url":"https://api.github.com/repos/dropbox/pyston/milestones{/number}","notifications_url":"https://api.github.com/repos/dropbox/pyston/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dropbox/pyston/labels{/name}","releases_url":"https://api.github.com/repos/dropbox/pyston/releases{/id}","created_at":"2014-04-01T07:17:20Z","updated_at":"2015-02-18T21:24:47Z","pushed_at":"2015-02-18T21:24:47Z","git_url":"git://github.com/dropbox/pyston.git","ssh_url":"git@github.com:dropbox/pyston.git","clone_url":"https://github.com/dropbox/pyston.git","svn_url":"https://github.com/dropbox/pyston","homepage":"https://tech.dropbox.com/2014/04/introducing-pyston-an-upcoming-jit-based-python-implementation/","size":18472,"stargazers_count":2678,"watchers_count":2678,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":196,"mirror_url":null,"open_issues_count":65,"forks":196,"open_issues":65,"watchers":2678,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dropbox/pyston/pulls/295"},"html":{"href":"https://github.com/dropbox/pyston/pull/295"},"issue":{"href":"https://api.github.com/repos/dropbox/pyston/issues/295"},"comments":{"href":"https://api.github.com/repos/dropbox/pyston/issues/295/comments"},"review_comments":{"href":"https://api.github.com/repos/dropbox/pyston/pulls/295/comments"},"review_comment":{"href":"https://api.github.com/repos/dropbox/pyston/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/dropbox/pyston/pulls/295/commits"},"statuses":{"href":"https://api.github.com/repos/dropbox/pyston/statuses/b7a8a92343114bb6f990d0db772177167dcc98ff"}}}}