{"action":"created","comment":{"url":"https://api.github.com/repos/django/django/pulls/comments/31740103","id":31740103,"diff_hunk":"@@ -2380,13 +2380,19 @@ def get_internal_type(self):\n         return \"UUIDField\"\n \n     def get_db_prep_value(self, value, connection, prepared=False):\n-        if isinstance(value, six.string_types):\n-            value = uuid.UUID(value)\n-        if isinstance(value, uuid.UUID):\n-            if connection.features.has_native_uuid_field:\n-                return value\n-            return value.hex\n-        return value\n+        if value is None:\n+            return None\n+        if not isinstance(value, uuid.UUID):\n+            try:\n+                value = uuid.UUID(value)\n+            except (ValueError, TypeError):\n+                raise\n+            except:","path":"django/db/models/fields/__init__.py","position":18,"original_position":18,"commit_id":"8aae68949ce23c0b09d3b40c97aa941f3ccb4e86","original_commit_id":"8aae68949ce23c0b09d3b40c97aa941f3ccb4e86","user":{"login":"cole","id":134694,"avatar_url":"https://avatars.githubusercontent.com/u/134694?v=3","gravatar_id":"","url":"https://api.github.com/users/cole","html_url":"https://github.com/cole","followers_url":"https://api.github.com/users/cole/followers","following_url":"https://api.github.com/users/cole/following{/other_user}","gists_url":"https://api.github.com/users/cole/gists{/gist_id}","starred_url":"https://api.github.com/users/cole/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cole/subscriptions","organizations_url":"https://api.github.com/users/cole/orgs","repos_url":"https://api.github.com/users/cole/repos","events_url":"https://api.github.com/users/cole/events{/privacy}","received_events_url":"https://api.github.com/users/cole/received_events","type":"User","site_admin":false},"body":"UUID throws `AttributeError` when you do `uuid.UUID({})`, so that. I hadn't thought of `KeyboardInterrupt` though. I'll change it to `except AttributeError`.","created_at":"2015-06-04T16:51:24Z","updated_at":"2015-06-04T16:51:24Z","html_url":"https://github.com/django/django/pull/4758#discussion_r31740103","pull_request_url":"https://api.github.com/repos/django/django/pulls/4758","_links":{"self":{"href":"https://api.github.com/repos/django/django/pulls/comments/31740103"},"html":{"href":"https://github.com/django/django/pull/4758#discussion_r31740103"},"pull_request":{"href":"https://api.github.com/repos/django/django/pulls/4758"}}},"pull_request":{"url":"https://api.github.com/repos/django/django/pulls/4758","id":36935941,"html_url":"https://github.com/django/django/pull/4758","diff_url":"https://github.com/django/django/pull/4758.diff","patch_url":"https://github.com/django/django/pull/4758.patch","issue_url":"https://api.github.com/repos/django/django/issues/4758","number":4758,"state":"open","locked":false,"title":"Fixed #24859 -- Make UUID field raise TypeError on bad value","user":{"login":"cole","id":134694,"avatar_url":"https://avatars.githubusercontent.com/u/134694?v=3","gravatar_id":"","url":"https://api.github.com/users/cole","html_url":"https://github.com/cole","followers_url":"https://api.github.com/users/cole/followers","following_url":"https://api.github.com/users/cole/following{/other_user}","gists_url":"https://api.github.com/users/cole/gists{/gist_id}","starred_url":"https://api.github.com/users/cole/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cole/subscriptions","organizations_url":"https://api.github.com/users/cole/orgs","repos_url":"https://api.github.com/users/cole/repos","events_url":"https://api.github.com/users/cole/events{/privacy}","received_events_url":"https://api.github.com/users/cole/received_events","type":"User","site_admin":false},"body":"For consistency with AutoField. I'm not entirely sure `get_prep_value` is the best place to do this validation, please advise if not.","created_at":"2015-06-04T13:51:41Z","updated_at":"2015-06-04T16:51:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3cc97bf182b795d3c548b58cbad0157df9fad717","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/django/django/pulls/4758/commits","review_comments_url":"https://api.github.com/repos/django/django/pulls/4758/comments","review_comment_url":"https://api.github.com/repos/django/django/pulls/comments{/number}","comments_url":"https://api.github.com/repos/django/django/issues/4758/comments","statuses_url":"https://api.github.com/repos/django/django/statuses/8aae68949ce23c0b09d3b40c97aa941f3ccb4e86","head":{"label":"cole:master","ref":"master","sha":"8aae68949ce23c0b09d3b40c97aa941f3ccb4e86","user":{"login":"cole","id":134694,"avatar_url":"https://avatars.githubusercontent.com/u/134694?v=3","gravatar_id":"","url":"https://api.github.com/users/cole","html_url":"https://github.com/cole","followers_url":"https://api.github.com/users/cole/followers","following_url":"https://api.github.com/users/cole/following{/other_user}","gists_url":"https://api.github.com/users/cole/gists{/gist_id}","starred_url":"https://api.github.com/users/cole/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cole/subscriptions","organizations_url":"https://api.github.com/users/cole/orgs","repos_url":"https://api.github.com/users/cole/repos","events_url":"https://api.github.com/users/cole/events{/privacy}","received_events_url":"https://api.github.com/users/cole/received_events","type":"User","site_admin":false},"repo":{"id":36867395,"name":"django","full_name":"cole/django","owner":{"login":"cole","id":134694,"avatar_url":"https://avatars.githubusercontent.com/u/134694?v=3","gravatar_id":"","url":"https://api.github.com/users/cole","html_url":"https://github.com/cole","followers_url":"https://api.github.com/users/cole/followers","following_url":"https://api.github.com/users/cole/following{/other_user}","gists_url":"https://api.github.com/users/cole/gists{/gist_id}","starred_url":"https://api.github.com/users/cole/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cole/subscriptions","organizations_url":"https://api.github.com/users/cole/orgs","repos_url":"https://api.github.com/users/cole/repos","events_url":"https://api.github.com/users/cole/events{/privacy}","received_events_url":"https://api.github.com/users/cole/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cole/django","description":"The Web framework for perfectionists with deadlines.","fork":true,"url":"https://api.github.com/repos/cole/django","forks_url":"https://api.github.com/repos/cole/django/forks","keys_url":"https://api.github.com/repos/cole/django/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cole/django/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cole/django/teams","hooks_url":"https://api.github.com/repos/cole/django/hooks","issue_events_url":"https://api.github.com/repos/cole/django/issues/events{/number}","events_url":"https://api.github.com/repos/cole/django/events","assignees_url":"https://api.github.com/repos/cole/django/assignees{/user}","branches_url":"https://api.github.com/repos/cole/django/branches{/branch}","tags_url":"https://api.github.com/repos/cole/django/tags","blobs_url":"https://api.github.com/repos/cole/django/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cole/django/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cole/django/git/refs{/sha}","trees_url":"https://api.github.com/repos/cole/django/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cole/django/statuses/{sha}","languages_url":"https://api.github.com/repos/cole/django/languages","stargazers_url":"https://api.github.com/repos/cole/django/stargazers","contributors_url":"https://api.github.com/repos/cole/django/contributors","subscribers_url":"https://api.github.com/repos/cole/django/subscribers","subscription_url":"https://api.github.com/repos/cole/django/subscription","commits_url":"https://api.github.com/repos/cole/django/commits{/sha}","git_commits_url":"https://api.github.com/repos/cole/django/git/commits{/sha}","comments_url":"https://api.github.com/repos/cole/django/comments{/number}","issue_comment_url":"https://api.github.com/repos/cole/django/issues/comments{/number}","contents_url":"https://api.github.com/repos/cole/django/contents/{+path}","compare_url":"https://api.github.com/repos/cole/django/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cole/django/merges","archive_url":"https://api.github.com/repos/cole/django/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cole/django/downloads","issues_url":"https://api.github.com/repos/cole/django/issues{/number}","pulls_url":"https://api.github.com/repos/cole/django/pulls{/number}","milestones_url":"https://api.github.com/repos/cole/django/milestones{/number}","notifications_url":"https://api.github.com/repos/cole/django/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cole/django/labels{/name}","releases_url":"https://api.github.com/repos/cole/django/releases{/id}","created_at":"2015-06-04T11:53:55Z","updated_at":"2015-06-04T11:54:09Z","pushed_at":"2015-06-04T14:07:31Z","git_url":"git://github.com/cole/django.git","ssh_url":"git@github.com:cole/django.git","clone_url":"https://github.com/cole/django.git","svn_url":"https://github.com/cole/django","homepage":"https://www.djangoproject.com/","size":140254,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"django:master","ref":"master","sha":"3e9b5bfd9c3e16c968278f7d050f52739690eb29","user":{"login":"django","id":27804,"avatar_url":"https://avatars.githubusercontent.com/u/27804?v=3","gravatar_id":"","url":"https://api.github.com/users/django","html_url":"https://github.com/django","followers_url":"https://api.github.com/users/django/followers","following_url":"https://api.github.com/users/django/following{/other_user}","gists_url":"https://api.github.com/users/django/gists{/gist_id}","starred_url":"https://api.github.com/users/django/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/django/subscriptions","organizations_url":"https://api.github.com/users/django/orgs","repos_url":"https://api.github.com/users/django/repos","events_url":"https://api.github.com/users/django/events{/privacy}","received_events_url":"https://api.github.com/users/django/received_events","type":"Organization","site_admin":false},"repo":{"id":4164482,"name":"django","full_name":"django/django","owner":{"login":"django","id":27804,"avatar_url":"https://avatars.githubusercontent.com/u/27804?v=3","gravatar_id":"","url":"https://api.github.com/users/django","html_url":"https://github.com/django","followers_url":"https://api.github.com/users/django/followers","following_url":"https://api.github.com/users/django/following{/other_user}","gists_url":"https://api.github.com/users/django/gists{/gist_id}","starred_url":"https://api.github.com/users/django/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/django/subscriptions","organizations_url":"https://api.github.com/users/django/orgs","repos_url":"https://api.github.com/users/django/repos","events_url":"https://api.github.com/users/django/events{/privacy}","received_events_url":"https://api.github.com/users/django/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/django/django","description":"The Web framework for perfectionists with deadlines.","fork":false,"url":"https://api.github.com/repos/django/django","forks_url":"https://api.github.com/repos/django/django/forks","keys_url":"https://api.github.com/repos/django/django/keys{/key_id}","collaborators_url":"https://api.github.com/repos/django/django/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/django/django/teams","hooks_url":"https://api.github.com/repos/django/django/hooks","issue_events_url":"https://api.github.com/repos/django/django/issues/events{/number}","events_url":"https://api.github.com/repos/django/django/events","assignees_url":"https://api.github.com/repos/django/django/assignees{/user}","branches_url":"https://api.github.com/repos/django/django/branches{/branch}","tags_url":"https://api.github.com/repos/django/django/tags","blobs_url":"https://api.github.com/repos/django/django/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/django/django/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/django/django/git/refs{/sha}","trees_url":"https://api.github.com/repos/django/django/git/trees{/sha}","statuses_url":"https://api.github.com/repos/django/django/statuses/{sha}","languages_url":"https://api.github.com/repos/django/django/languages","stargazers_url":"https://api.github.com/repos/django/django/stargazers","contributors_url":"https://api.github.com/repos/django/django/contributors","subscribers_url":"https://api.github.com/repos/django/django/subscribers","subscription_url":"https://api.github.com/repos/django/django/subscription","commits_url":"https://api.github.com/repos/django/django/commits{/sha}","git_commits_url":"https://api.github.com/repos/django/django/git/commits{/sha}","comments_url":"https://api.github.com/repos/django/django/comments{/number}","issue_comment_url":"https://api.github.com/repos/django/django/issues/comments{/number}","contents_url":"https://api.github.com/repos/django/django/contents/{+path}","compare_url":"https://api.github.com/repos/django/django/compare/{base}...{head}","merges_url":"https://api.github.com/repos/django/django/merges","archive_url":"https://api.github.com/repos/django/django/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/django/django/downloads","issues_url":"https://api.github.com/repos/django/django/issues{/number}","pulls_url":"https://api.github.com/repos/django/django/pulls{/number}","milestones_url":"https://api.github.com/repos/django/django/milestones{/number}","notifications_url":"https://api.github.com/repos/django/django/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/django/django/labels{/name}","releases_url":"https://api.github.com/repos/django/django/releases{/id}","created_at":"2012-04-28T02:47:18Z","updated_at":"2015-06-04T15:06:57Z","pushed_at":"2015-06-04T16:48:06Z","git_url":"git://github.com/django/django.git","ssh_url":"git@github.com:django/django.git","clone_url":"https://github.com/django/django.git","svn_url":"https://github.com/django/django","homepage":"https://www.djangoproject.com/","size":306686,"stargazers_count":14499,"watchers_count":14499,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5792,"mirror_url":null,"open_issues_count":91,"forks":5792,"open_issues":91,"watchers":14499,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/django/django/pulls/4758"},"html":{"href":"https://github.com/django/django/pull/4758"},"issue":{"href":"https://api.github.com/repos/django/django/issues/4758"},"comments":{"href":"https://api.github.com/repos/django/django/issues/4758/comments"},"review_comments":{"href":"https://api.github.com/repos/django/django/pulls/4758/comments"},"review_comment":{"href":"https://api.github.com/repos/django/django/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/django/django/pulls/4758/commits"},"statuses":{"href":"https://api.github.com/repos/django/django/statuses/8aae68949ce23c0b09d3b40c97aa941f3ccb4e86"}}}}