{"action":"created","comment":{"url":"https://api.github.com/repos/numpy/numpy/pulls/comments/37866653","id":37866653,"diff_hunk":"@@ -509,8 +509,12 @@ _convert_from_array_descr(PyObject *obj, int align)\n                  && (PyUString_Check(title) || PyUnicode_Check(title))\n #endif\n                  && (PyDict_GetItem(fields, title) != NULL))) {\n-            PyErr_SetString(PyExc_ValueError,\n-                    \"two fields with the same name\");\n+#if defined(NPY_PY3K)\n+            name = PyUnicode_AsUTF8String(name);\n+            Py_DECREF(name);","path":"numpy/core/src/multiarray/descriptor.c","position":8,"original_position":8,"commit_id":"70f51f10391d4d3fa9a9a52c41af84dafad53853","original_commit_id":"70f51f10391d4d3fa9a9a52c41af84dafad53853","user":{"login":"jaimefrio","id":3343990,"avatar_url":"https://avatars.githubusercontent.com/u/3343990?v=3","gravatar_id":"","url":"https://api.github.com/users/jaimefrio","html_url":"https://github.com/jaimefrio","followers_url":"https://api.github.com/users/jaimefrio/followers","following_url":"https://api.github.com/users/jaimefrio/following{/other_user}","gists_url":"https://api.github.com/users/jaimefrio/gists{/gist_id}","starred_url":"https://api.github.com/users/jaimefrio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaimefrio/subscriptions","organizations_url":"https://api.github.com/users/jaimefrio/orgs","repos_url":"https://api.github.com/users/jaimefrio/repos","events_url":"https://api.github.com/users/jaimefrio/events{/privacy}","received_events_url":"https://api.github.com/users/jaimefrio/received_events","type":"User","site_admin":false},"body":"This will not work: once you decref `next`, it could be garbage collected before you call `PyString_AsString` on it. What I had in mind on my other comment was something like:\r\n\r\n```\r\n#if defined(NPY_PY3K)\r\n            name = PyUnicode_AsUTF8String(name);\r\n#endif\r\n            PyErr_Format(PyExc_ValueError,\r\n                    \"field '%s' occurs more than once\", PyString_AsString(name));\r\n#if defined(NPY_PY3K)\r\n            Py_DECREF(next);\r\n#endif\r\n            goto fail;\r\n```\r\n\r\nIt ain't pretty, but neither was the previous version, and at least it puts all the weirdness in the Python 3 code path, and leaves the Python 2 one nice and clean.","created_at":"2015-08-25T13:51:18Z","updated_at":"2015-08-25T13:51:18Z","html_url":"https://github.com/numpy/numpy/pull/6242#discussion_r37866653","pull_request_url":"https://api.github.com/repos/numpy/numpy/pulls/6242","_links":{"self":{"href":"https://api.github.com/repos/numpy/numpy/pulls/comments/37866653"},"html":{"href":"https://github.com/numpy/numpy/pull/6242#discussion_r37866653"},"pull_request":{"href":"https://api.github.com/repos/numpy/numpy/pulls/6242"}}},"pull_request":{"url":"https://api.github.com/repos/numpy/numpy/pulls/6242","id":43224617,"html_url":"https://github.com/numpy/numpy/pull/6242","diff_url":"https://github.com/numpy/numpy/pull/6242.diff","patch_url":"https://github.com/numpy/numpy/pull/6242.patch","issue_url":"https://api.github.com/repos/numpy/numpy/issues/6242","number":6242,"state":"open","locked":false,"title":"BUG: Added field name to error message. Closes #6232","user":{"login":"yashmehrotra","id":5863972,"avatar_url":"https://avatars.githubusercontent.com/u/5863972?v=3","gravatar_id":"","url":"https://api.github.com/users/yashmehrotra","html_url":"https://github.com/yashmehrotra","followers_url":"https://api.github.com/users/yashmehrotra/followers","following_url":"https://api.github.com/users/yashmehrotra/following{/other_user}","gists_url":"https://api.github.com/users/yashmehrotra/gists{/gist_id}","starred_url":"https://api.github.com/users/yashmehrotra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yashmehrotra/subscriptions","organizations_url":"https://api.github.com/users/yashmehrotra/orgs","repos_url":"https://api.github.com/users/yashmehrotra/repos","events_url":"https://api.github.com/users/yashmehrotra/events{/privacy}","received_events_url":"https://api.github.com/users/yashmehrotra/received_events","type":"User","site_admin":false},"body":"Changed error message (Added field name occurring more than once) as discussed in #6232 \r\n\r\n![screenshot from 2015-08-25 03 02 05](https://cloud.githubusercontent.com/assets/5863972/9453106/b1915de4-4ad5-11e5-9d83-0286817a82fd.png)\r\n","created_at":"2015-08-24T21:33:23Z","updated_at":"2015-08-25T13:51:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2168a65e5cf80c0f91c8d600bd3cf8a9ad2e9285","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/numpy/numpy/pulls/6242/commits","review_comments_url":"https://api.github.com/repos/numpy/numpy/pulls/6242/comments","review_comment_url":"https://api.github.com/repos/numpy/numpy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/numpy/numpy/issues/6242/comments","statuses_url":"https://api.github.com/repos/numpy/numpy/statuses/70f51f10391d4d3fa9a9a52c41af84dafad53853","head":{"label":"yashmehrotra:dtype-field-name","ref":"dtype-field-name","sha":"70f51f10391d4d3fa9a9a52c41af84dafad53853","user":{"login":"yashmehrotra","id":5863972,"avatar_url":"https://avatars.githubusercontent.com/u/5863972?v=3","gravatar_id":"","url":"https://api.github.com/users/yashmehrotra","html_url":"https://github.com/yashmehrotra","followers_url":"https://api.github.com/users/yashmehrotra/followers","following_url":"https://api.github.com/users/yashmehrotra/following{/other_user}","gists_url":"https://api.github.com/users/yashmehrotra/gists{/gist_id}","starred_url":"https://api.github.com/users/yashmehrotra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yashmehrotra/subscriptions","organizations_url":"https://api.github.com/users/yashmehrotra/orgs","repos_url":"https://api.github.com/users/yashmehrotra/repos","events_url":"https://api.github.com/users/yashmehrotra/events{/privacy}","received_events_url":"https://api.github.com/users/yashmehrotra/received_events","type":"User","site_admin":false},"repo":{"id":41327120,"name":"numpy","full_name":"yashmehrotra/numpy","owner":{"login":"yashmehrotra","id":5863972,"avatar_url":"https://avatars.githubusercontent.com/u/5863972?v=3","gravatar_id":"","url":"https://api.github.com/users/yashmehrotra","html_url":"https://github.com/yashmehrotra","followers_url":"https://api.github.com/users/yashmehrotra/followers","following_url":"https://api.github.com/users/yashmehrotra/following{/other_user}","gists_url":"https://api.github.com/users/yashmehrotra/gists{/gist_id}","starred_url":"https://api.github.com/users/yashmehrotra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yashmehrotra/subscriptions","organizations_url":"https://api.github.com/users/yashmehrotra/orgs","repos_url":"https://api.github.com/users/yashmehrotra/repos","events_url":"https://api.github.com/users/yashmehrotra/events{/privacy}","received_events_url":"https://api.github.com/users/yashmehrotra/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yashmehrotra/numpy","description":"Numpy main repository","fork":true,"url":"https://api.github.com/repos/yashmehrotra/numpy","forks_url":"https://api.github.com/repos/yashmehrotra/numpy/forks","keys_url":"https://api.github.com/repos/yashmehrotra/numpy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yashmehrotra/numpy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yashmehrotra/numpy/teams","hooks_url":"https://api.github.com/repos/yashmehrotra/numpy/hooks","issue_events_url":"https://api.github.com/repos/yashmehrotra/numpy/issues/events{/number}","events_url":"https://api.github.com/repos/yashmehrotra/numpy/events","assignees_url":"https://api.github.com/repos/yashmehrotra/numpy/assignees{/user}","branches_url":"https://api.github.com/repos/yashmehrotra/numpy/branches{/branch}","tags_url":"https://api.github.com/repos/yashmehrotra/numpy/tags","blobs_url":"https://api.github.com/repos/yashmehrotra/numpy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yashmehrotra/numpy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yashmehrotra/numpy/git/refs{/sha}","trees_url":"https://api.github.com/repos/yashmehrotra/numpy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yashmehrotra/numpy/statuses/{sha}","languages_url":"https://api.github.com/repos/yashmehrotra/numpy/languages","stargazers_url":"https://api.github.com/repos/yashmehrotra/numpy/stargazers","contributors_url":"https://api.github.com/repos/yashmehrotra/numpy/contributors","subscribers_url":"https://api.github.com/repos/yashmehrotra/numpy/subscribers","subscription_url":"https://api.github.com/repos/yashmehrotra/numpy/subscription","commits_url":"https://api.github.com/repos/yashmehrotra/numpy/commits{/sha}","git_commits_url":"https://api.github.com/repos/yashmehrotra/numpy/git/commits{/sha}","comments_url":"https://api.github.com/repos/yashmehrotra/numpy/comments{/number}","issue_comment_url":"https://api.github.com/repos/yashmehrotra/numpy/issues/comments{/number}","contents_url":"https://api.github.com/repos/yashmehrotra/numpy/contents/{+path}","compare_url":"https://api.github.com/repos/yashmehrotra/numpy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yashmehrotra/numpy/merges","archive_url":"https://api.github.com/repos/yashmehrotra/numpy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yashmehrotra/numpy/downloads","issues_url":"https://api.github.com/repos/yashmehrotra/numpy/issues{/number}","pulls_url":"https://api.github.com/repos/yashmehrotra/numpy/pulls{/number}","milestones_url":"https://api.github.com/repos/yashmehrotra/numpy/milestones{/number}","notifications_url":"https://api.github.com/repos/yashmehrotra/numpy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yashmehrotra/numpy/labels{/name}","releases_url":"https://api.github.com/repos/yashmehrotra/numpy/releases{/id}","created_at":"2015-08-24T21:08:20Z","updated_at":"2015-08-24T21:08:24Z","pushed_at":"2015-08-25T09:50:41Z","git_url":"git://github.com/yashmehrotra/numpy.git","ssh_url":"git@github.com:yashmehrotra/numpy.git","clone_url":"https://github.com/yashmehrotra/numpy.git","svn_url":"https://github.com/yashmehrotra/numpy","homepage":"http://www.numpy.org/","size":40978,"stargazers_count":0,"watchers_count":0,"language":"C","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":"numpy:master","ref":"master","sha":"60df9b1eb6375e3decf12ba7506404c46af0469a","user":{"login":"numpy","id":288276,"avatar_url":"https://avatars.githubusercontent.com/u/288276?v=3","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,"name":"numpy","full_name":"numpy/numpy","owner":{"login":"numpy","id":288276,"avatar_url":"https://avatars.githubusercontent.com/u/288276?v=3","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},"private":false,"html_url":"https://github.com/numpy/numpy","description":"Numpy main repository","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}","created_at":"2010-09-13T23:02:39Z","updated_at":"2015-08-24T15:48:02Z","pushed_at":"2015-08-25T12:16:07Z","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":"http://www.numpy.org/","size":83995,"stargazers_count":2144,"watchers_count":2144,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1101,"mirror_url":null,"open_issues_count":960,"forks":1101,"open_issues":960,"watchers":2144,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/numpy/numpy/pulls/6242"},"html":{"href":"https://github.com/numpy/numpy/pull/6242"},"issue":{"href":"https://api.github.com/repos/numpy/numpy/issues/6242"},"comments":{"href":"https://api.github.com/repos/numpy/numpy/issues/6242/comments"},"review_comments":{"href":"https://api.github.com/repos/numpy/numpy/pulls/6242/comments"},"review_comment":{"href":"https://api.github.com/repos/numpy/numpy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/numpy/numpy/pulls/6242/commits"},"statuses":{"href":"https://api.github.com/repos/numpy/numpy/statuses/70f51f10391d4d3fa9a9a52c41af84dafad53853"}}}}