{"action":"created","comment":{"url":"https://api.github.com/repos/numpy/numpy/pulls/comments/245370203","pull_request_review_id":189460202,"id":245370203,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0NTM3MDIwMw==","diff_hunk":"@@ -63,6 +84,105 @@ raise_binary_type_reso_error(PyUFuncObject *ufunc, PyArrayObject **operands) {\n     return -1;\n }\n \n+/** Helper function to raise UFuncNoLoopError */\n+static int\n+raise_no_loop_found_error(PyUFuncObject *ufunc, PyObject *dtypes_tup) {\n+    static PyObject *exc_type = NULL;\n+    PyObject *exc_value;\n+\n+    npy_cache_import(\n+        \"numpy.core._exceptions\", \"UFuncNoLoopError\",\n+        &exc_type);\n+    if (exc_type == NULL) {\n+        return -1;\n+    }\n+\n+    exc_value = PyTuple_Pack(2, ufunc, dtypes_tup);\n+    Py_DECREF(dtypes_tup);\n+    if (exc_value == NULL){\n+        return -1;\n+    }\n+    PyErr_SetObject(exc_type, exc_value);\n+    Py_DECREF(exc_value);\n+\n+    return -1;\n+}\n+\n+static int\n+raise_casting_error(\n+        PyObject *exc_type,\n+        PyUFuncObject *ufunc,\n+        NPY_CASTING casting,\n+        PyArray_Descr *from,\n+        PyArray_Descr *to,\n+        npy_intp i)\n+{\n+    PyObject *exc_value;\n+    PyObject *casting_value;\n+\n+    casting_value = npy_casting_to_py_object(casting);\n+    if (casting_value == NULL) {\n+        return -1;\n+    }\n+\n+    exc_value = Py_BuildValue(\n+        \"ONOOi\",\n+        ufunc,\n+        casting_value,\n+        (PyObject *)from,\n+        (PyObject *)to,\n+        i\n+    );\n+    if (exc_value == NULL){\n+        return -1;\n+    }\n+    PyErr_SetObject(exc_type, exc_value);\n+    Py_DECREF(exc_value);\n+\n+    return -1;","path":"numpy/core/src/umath/ufunc_type_resolution.c","position":94,"original_position":94,"commit_id":"b638895b687a2664ef14d520fb3b71399b1b37cd","original_commit_id":"b638895b687a2664ef14d520fb3b71399b1b37cd","user":{"login":"mhvk","id":2789820,"node_id":"MDQ6VXNlcjI3ODk4MjA=","avatar_url":"https://avatars0.githubusercontent.com/u/2789820?v=4","gravatar_id":"","url":"https://api.github.com/users/mhvk","html_url":"https://github.com/mhvk","followers_url":"https://api.github.com/users/mhvk/followers","following_url":"https://api.github.com/users/mhvk/following{/other_user}","gists_url":"https://api.github.com/users/mhvk/gists{/gist_id}","starred_url":"https://api.github.com/users/mhvk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhvk/subscriptions","organizations_url":"https://api.github.com/users/mhvk/orgs","repos_url":"https://api.github.com/users/mhvk/repos","events_url":"https://api.github.com/users/mhvk/events{/privacy}","received_events_url":"https://api.github.com/users/mhvk/received_events","type":"User","site_admin":false},"body":"Oddly, I feel this should return 0, as it successfully raised the error. And then in the main code, just ignore the return value, and return -1.\r\n\r\nPartially this is for later expansion: other functions need to return `NULL` when they do not succeed, so the exception should not presume what the right value is.","created_at":"2019-01-04T17:47:19Z","updated_at":"2019-01-04T17:50:22Z","html_url":"https://github.com/numpy/numpy/pull/12593#discussion_r245370203","pull_request_url":"https://api.github.com/repos/numpy/numpy/pulls/12593","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/numpy/numpy/pulls/comments/245370203"},"html":{"href":"https://github.com/numpy/numpy/pull/12593#discussion_r245370203"},"pull_request":{"href":"https://api.github.com/repos/numpy/numpy/pulls/12593"}}},"pull_request":{"url":"https://api.github.com/repos/numpy/numpy/pulls/12593","id":239750418,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM5NzUwNDE4","html_url":"https://github.com/numpy/numpy/pull/12593","diff_url":"https://github.com/numpy/numpy/pull/12593.diff","patch_url":"https://github.com/numpy/numpy/pull/12593.patch","issue_url":"https://api.github.com/repos/numpy/numpy/issues/12593","number":12593,"state":"open","locked":false,"title":"ENH,WIP: Use richer exception types for ufunc type resolution errors","user":{"login":"eric-wieser","id":425260,"node_id":"MDQ6VXNlcjQyNTI2MA==","avatar_url":"https://avatars3.githubusercontent.com/u/425260?v=4","gravatar_id":"","url":"https://api.github.com/users/eric-wieser","html_url":"https://github.com/eric-wieser","followers_url":"https://api.github.com/users/eric-wieser/followers","following_url":"https://api.github.com/users/eric-wieser/following{/other_user}","gists_url":"https://api.github.com/users/eric-wieser/gists{/gist_id}","starred_url":"https://api.github.com/users/eric-wieser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eric-wieser/subscriptions","organizations_url":"https://api.github.com/users/eric-wieser/orgs","repos_url":"https://api.github.com/users/eric-wieser/repos","events_url":"https://api.github.com/users/eric-wieser/events{/privacy}","received_events_url":"https://api.github.com/users/eric-wieser/received_events","type":"User","site_admin":false},"body":"This might make it easier for users to implement `__array_ufunc__` with custom casting behavior.\r\n\r\nThe motivation for this was to be able to deprecate the broken casting behavior in `np.clip`, without resorting to inspecting error strings.\r\nThis also removes the need for gh-12178\r\nBefore:\r\n```\r\n>>> np.add(1, 1, out=np.empty((), str), casting='safe')\r\nTypeError: Cannot cast ufunc add output from dtype('<U1') to dtype('int32') with casting rule 'safe'\r\n>>> np.less(1, 'a', dtype=int)\r\nTypeError: Cannot cast ufunc less input from dtype('<U1') to dtype('int32') with casting rule 'same_kind'\r\n>>> np.add(1, 'a')\r\nTypeError: ufunc 'add' did not contain a loop with signature matching types dtype('<U11') dtype('<U11') dtype('<U11')\r\n```\r\nAfter, showing types, input/output argument numbers, and `->` in the signature:\r\n```\r\n>>> np.add(1, 1, out=np.empty((), str), casting='safe')\r\nUFuncOutputCastingTypeError: Cannot cast ufunc 'add' output from dtype('<U1') to dtype('int32') with casting rule 'safe'\r\n>>> np.less(1, 'a', dtype=int)\r\nUFuncInputCastingTypeError: Cannot cast ufunc 'less' input 1 from dtype('<U1') to dtype('int32') with casting rule 'same_kind'\r\n>>> np.add(1, 'a')\r\nUFuncNoLoopTypeError: ufunc 'add' did not contain a loop with signature matching types (dtype('<U11'), dtype('<U11')) -> dtype('<U11')\r\n```\r\n\r\nNeeds some more thought about the distinction between these error types.\r\n\r\nOne option would be to pretend that all the types are `TypeError` by setting `__name__`.","created_at":"2018-12-19T08:32:50Z","updated_at":"2019-01-04T17:50:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"90a2ccfc4d2284d386cd0e41df66816e2447dcd0","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":6359239,"node_id":"MDU6TGFiZWw2MzU5MjM5","url":"https://api.github.com/repos/numpy/numpy/labels/01%20-%20Enhancement","name":"01 - Enhancement","color":"fef2c0","default":false},{"id":959099844,"node_id":"MDU6TGFiZWw5NTkwOTk4NDQ=","url":"https://api.github.com/repos/numpy/numpy/labels/component:%20numpy.ufunc","name":"component: numpy.ufunc","color":"009800","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/numpy/numpy/pulls/12593/commits","review_comments_url":"https://api.github.com/repos/numpy/numpy/pulls/12593/comments","review_comment_url":"https://api.github.com/repos/numpy/numpy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/numpy/numpy/issues/12593/comments","statuses_url":"https://api.github.com/repos/numpy/numpy/statuses/b638895b687a2664ef14d520fb3b71399b1b37cd","head":{"label":"eric-wieser:ufunc-exceptions","ref":"ufunc-exceptions","sha":"b638895b687a2664ef14d520fb3b71399b1b37cd","user":{"login":"eric-wieser","id":425260,"node_id":"MDQ6VXNlcjQyNTI2MA==","avatar_url":"https://avatars3.githubusercontent.com/u/425260?v=4","gravatar_id":"","url":"https://api.github.com/users/eric-wieser","html_url":"https://github.com/eric-wieser","followers_url":"https://api.github.com/users/eric-wieser/followers","following_url":"https://api.github.com/users/eric-wieser/following{/other_user}","gists_url":"https://api.github.com/users/eric-wieser/gists{/gist_id}","starred_url":"https://api.github.com/users/eric-wieser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eric-wieser/subscriptions","organizations_url":"https://api.github.com/users/eric-wieser/orgs","repos_url":"https://api.github.com/users/eric-wieser/repos","events_url":"https://api.github.com/users/eric-wieser/events{/privacy}","received_events_url":"https://api.github.com/users/eric-wieser/received_events","type":"User","site_admin":false},"repo":{"id":57262933,"node_id":"MDEwOlJlcG9zaXRvcnk1NzI2MjkzMw==","name":"numpy","full_name":"eric-wieser/numpy","private":false,"owner":{"login":"eric-wieser","id":425260,"node_id":"MDQ6VXNlcjQyNTI2MA==","avatar_url":"https://avatars3.githubusercontent.com/u/425260?v=4","gravatar_id":"","url":"https://api.github.com/users/eric-wieser","html_url":"https://github.com/eric-wieser","followers_url":"https://api.github.com/users/eric-wieser/followers","following_url":"https://api.github.com/users/eric-wieser/following{/other_user}","gists_url":"https://api.github.com/users/eric-wieser/gists{/gist_id}","starred_url":"https://api.github.com/users/eric-wieser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eric-wieser/subscriptions","organizations_url":"https://api.github.com/users/eric-wieser/orgs","repos_url":"https://api.github.com/users/eric-wieser/repos","events_url":"https://api.github.com/users/eric-wieser/events{/privacy}","received_events_url":"https://api.github.com/users/eric-wieser/received_events","type":"User","site_admin":false},"html_url":"https://github.com/eric-wieser/numpy","description":"Numpy main repository","fork":true,"url":"https://api.github.com/repos/eric-wieser/numpy","forks_url":"https://api.github.com/repos/eric-wieser/numpy/forks","keys_url":"https://api.github.com/repos/eric-wieser/numpy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eric-wieser/numpy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eric-wieser/numpy/teams","hooks_url":"https://api.github.com/repos/eric-wieser/numpy/hooks","issue_events_url":"https://api.github.com/repos/eric-wieser/numpy/issues/events{/number}","events_url":"https://api.github.com/repos/eric-wieser/numpy/events","assignees_url":"https://api.github.com/repos/eric-wieser/numpy/assignees{/user}","branches_url":"https://api.github.com/repos/eric-wieser/numpy/branches{/branch}","tags_url":"https://api.github.com/repos/eric-wieser/numpy/tags","blobs_url":"https://api.github.com/repos/eric-wieser/numpy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eric-wieser/numpy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eric-wieser/numpy/git/refs{/sha}","trees_url":"https://api.github.com/repos/eric-wieser/numpy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eric-wieser/numpy/statuses/{sha}","languages_url":"https://api.github.com/repos/eric-wieser/numpy/languages","stargazers_url":"https://api.github.com/repos/eric-wieser/numpy/stargazers","contributors_url":"https://api.github.com/repos/eric-wieser/numpy/contributors","subscribers_url":"https://api.github.com/repos/eric-wieser/numpy/subscribers","subscription_url":"https://api.github.com/repos/eric-wieser/numpy/subscription","commits_url":"https://api.github.com/repos/eric-wieser/numpy/commits{/sha}","git_commits_url":"https://api.github.com/repos/eric-wieser/numpy/git/commits{/sha}","comments_url":"https://api.github.com/repos/eric-wieser/numpy/comments{/number}","issue_comment_url":"https://api.github.com/repos/eric-wieser/numpy/issues/comments{/number}","contents_url":"https://api.github.com/repos/eric-wieser/numpy/contents/{+path}","compare_url":"https://api.github.com/repos/eric-wieser/numpy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eric-wieser/numpy/merges","archive_url":"https://api.github.com/repos/eric-wieser/numpy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eric-wieser/numpy/downloads","issues_url":"https://api.github.com/repos/eric-wieser/numpy/issues{/number}","pulls_url":"https://api.github.com/repos/eric-wieser/numpy/pulls{/number}","milestones_url":"https://api.github.com/repos/eric-wieser/numpy/milestones{/number}","notifications_url":"https://api.github.com/repos/eric-wieser/numpy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eric-wieser/numpy/labels{/name}","releases_url":"https://api.github.com/repos/eric-wieser/numpy/releases{/id}","deployments_url":"https://api.github.com/repos/eric-wieser/numpy/deployments","created_at":"2016-04-28T02:09:21Z","updated_at":"2018-06-10T07:03:02Z","pushed_at":"2019-01-04T17:28:56Z","git_url":"git://github.com/eric-wieser/numpy.git","ssh_url":"git@github.com:eric-wieser/numpy.git","clone_url":"https://github.com/eric-wieser/numpy.git","svn_url":"https://github.com/eric-wieser/numpy","homepage":"http://www.numpy.org/","size":61453,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"numpy:master","ref":"master","sha":"aef982e4482773e802cc0ef076bf5e76ff650cf9","user":{"login":"numpy","id":288276,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4ODI3Ng==","avatar_url":"https://avatars2.githubusercontent.com/u/288276?v=4","gravatar_id":"","url":"https://api.github.com/users/numpy","html_url":"https://github.com/numpy","followers_url":"https://api.github.com/users/numpy/followers","following_url":"https://api.github.com/users/numpy/following{/other_user}","gists_url":"https://api.github.com/users/numpy/gists{/gist_id}","starred_url":"https://api.github.com/users/numpy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/numpy/subscriptions","organizations_url":"https://api.github.com/users/numpy/orgs","repos_url":"https://api.github.com/users/numpy/repos","events_url":"https://api.github.com/users/numpy/events{/privacy}","received_events_url":"https://api.github.com/users/numpy/received_events","type":"Organization","site_admin":false},"repo":{"id":908607,"node_id":"MDEwOlJlcG9zaXRvcnk5MDg2MDc=","name":"numpy","full_name":"numpy/numpy","private":false,"owner":{"login":"numpy","id":288276,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4ODI3Ng==","avatar_url":"https://avatars2.githubusercontent.com/u/288276?v=4","gravatar_id":"","url":"https://api.github.com/users/numpy","html_url":"https://github.com/numpy","followers_url":"https://api.github.com/users/numpy/followers","following_url":"https://api.github.com/users/numpy/following{/other_user}","gists_url":"https://api.github.com/users/numpy/gists{/gist_id}","starred_url":"https://api.github.com/users/numpy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/numpy/subscriptions","organizations_url":"https://api.github.com/users/numpy/orgs","repos_url":"https://api.github.com/users/numpy/repos","events_url":"https://api.github.com/users/numpy/events{/privacy}","received_events_url":"https://api.github.com/users/numpy/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/numpy/numpy","description":"The fundamental package for scientific computing with Python.","fork":false,"url":"https://api.github.com/repos/numpy/numpy","forks_url":"https://api.github.com/repos/numpy/numpy/forks","keys_url":"https://api.github.com/repos/numpy/numpy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/numpy/numpy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/numpy/numpy/teams","hooks_url":"https://api.github.com/repos/numpy/numpy/hooks","issue_events_url":"https://api.github.com/repos/numpy/numpy/issues/events{/number}","events_url":"https://api.github.com/repos/numpy/numpy/events","assignees_url":"https://api.github.com/repos/numpy/numpy/assignees{/user}","branches_url":"https://api.github.com/repos/numpy/numpy/branches{/branch}","tags_url":"https://api.github.com/repos/numpy/numpy/tags","blobs_url":"https://api.github.com/repos/numpy/numpy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/numpy/numpy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/numpy/numpy/git/refs{/sha}","trees_url":"https://api.github.com/repos/numpy/numpy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/numpy/numpy/statuses/{sha}","languages_url":"https://api.github.com/repos/numpy/numpy/languages","stargazers_url":"https://api.github.com/repos/numpy/numpy/stargazers","contributors_url":"https://api.github.com/repos/numpy/numpy/contributors","subscribers_url":"https://api.github.com/repos/numpy/numpy/subscribers","subscription_url":"https://api.github.com/repos/numpy/numpy/subscription","commits_url":"https://api.github.com/repos/numpy/numpy/commits{/sha}","git_commits_url":"https://api.github.com/repos/numpy/numpy/git/commits{/sha}","comments_url":"https://api.github.com/repos/numpy/numpy/comments{/number}","issue_comment_url":"https://api.github.com/repos/numpy/numpy/issues/comments{/number}","contents_url":"https://api.github.com/repos/numpy/numpy/contents/{+path}","compare_url":"https://api.github.com/repos/numpy/numpy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/numpy/numpy/merges","archive_url":"https://api.github.com/repos/numpy/numpy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/numpy/numpy/downloads","issues_url":"https://api.github.com/repos/numpy/numpy/issues{/number}","pulls_url":"https://api.github.com/repos/numpy/numpy/pulls{/number}","milestones_url":"https://api.github.com/repos/numpy/numpy/milestones{/number}","notifications_url":"https://api.github.com/repos/numpy/numpy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/numpy/numpy/labels{/name}","releases_url":"https://api.github.com/repos/numpy/numpy/releases{/id}","deployments_url":"https://api.github.com/repos/numpy/numpy/deployments","created_at":"2010-09-13T23:02:39Z","updated_at":"2019-01-04T17:12:20Z","pushed_at":"2019-01-04T17:29:00Z","git_url":"git://github.com/numpy/numpy.git","ssh_url":"git@github.com:numpy/numpy.git","clone_url":"https://github.com/numpy/numpy.git","svn_url":"https://github.com/numpy/numpy","homepage":"https://www.numpy.org/","size":63116,"stargazers_count":9129,"watchers_count":9129,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3225,"mirror_url":null,"archived":false,"open_issues_count":2014,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":3225,"open_issues":2014,"watchers":9129,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/numpy/numpy/pulls/12593"},"html":{"href":"https://github.com/numpy/numpy/pull/12593"},"issue":{"href":"https://api.github.com/repos/numpy/numpy/issues/12593"},"comments":{"href":"https://api.github.com/repos/numpy/numpy/issues/12593/comments"},"review_comments":{"href":"https://api.github.com/repos/numpy/numpy/pulls/12593/comments"},"review_comment":{"href":"https://api.github.com/repos/numpy/numpy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/numpy/numpy/pulls/12593/commits"},"statuses":{"href":"https://api.github.com/repos/numpy/numpy/statuses/b638895b687a2664ef14d520fb3b71399b1b37cd"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"mhvk"}}