{"action":"created","comment":{"url":"https://api.github.com/repos/scrapy/scrapely/pulls/comments/25688111","id":25688111,"diff_hunk":"@@ -33,11 +35,12 @@ def train_from_htmlpage(self, htmlpage, data):\n         assert data, \"Cannot train with empty data\"\n         tm = TemplateMaker(htmlpage)\n         for field, values in data.items():\n-            if not hasattr(values, '__iter__'):\n+            if (isinstance(values, bytes) or\n+                    not hasattr(values, '__iter__')):\n                 values = [values]\n             for value in values:\n-                if isinstance(value, str):\n-                    value = value.decode(htmlpage.encoding or 'utf-8')\n+                if isinstance(value, bytes):\n+                    value = str_to_unicode(value, htmlpage.encoding)","path":"scrapely/__init__.py","position":21,"original_position":21,"commit_id":"834cf7e56d6d777a03b9c30a88b7f275b6c00a0d","original_commit_id":"834cf7e56d6d777a03b9c30a88b7f275b6c00a0d","user":{"login":"kmike","id":107893,"avatar_url":"https://avatars.githubusercontent.com/u/107893?v=3","gravatar_id":"","url":"https://api.github.com/users/kmike","html_url":"https://github.com/kmike","followers_url":"https://api.github.com/users/kmike/followers","following_url":"https://api.github.com/users/kmike/following{/other_user}","gists_url":"https://api.github.com/users/kmike/gists{/gist_id}","starred_url":"https://api.github.com/users/kmike/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kmike/subscriptions","organizations_url":"https://api.github.com/users/kmike/orgs","repos_url":"https://api.github.com/users/kmike/repos","events_url":"https://api.github.com/users/kmike/events{/privacy}","received_events_url":"https://api.github.com/users/kmike/received_events","type":"User","site_admin":false},"body":"Actually my main issue was str_to_unicode function :) There are many ways to write such function; with .decode() it is clear what's going on. But it could be just a style preference.","created_at":"2015-03-03T13:52:28Z","updated_at":"2015-03-03T13:52:28Z","html_url":"https://github.com/scrapy/scrapely/pull/67#discussion_r25688111","pull_request_url":"https://api.github.com/repos/scrapy/scrapely/pulls/67","_links":{"self":{"href":"https://api.github.com/repos/scrapy/scrapely/pulls/comments/25688111"},"html":{"href":"https://github.com/scrapy/scrapely/pull/67#discussion_r25688111"},"pull_request":{"href":"https://api.github.com/repos/scrapy/scrapely/pulls/67"}}},"pull_request":{"url":"https://api.github.com/repos/scrapy/scrapely/pulls/67","id":24146140,"html_url":"https://github.com/scrapy/scrapely/pull/67","diff_url":"https://github.com/scrapy/scrapely/pull/67.diff","patch_url":"https://github.com/scrapy/scrapely/pull/67.patch","issue_url":"https://api.github.com/repos/scrapy/scrapely/issues/67","number":67,"state":"open","locked":false,"title":"Add python 3 support","user":{"login":"ruairif","id":6472969,"avatar_url":"https://avatars.githubusercontent.com/u/6472969?v=3","gravatar_id":"","url":"https://api.github.com/users/ruairif","html_url":"https://github.com/ruairif","followers_url":"https://api.github.com/users/ruairif/followers","following_url":"https://api.github.com/users/ruairif/following{/other_user}","gists_url":"https://api.github.com/users/ruairif/gists{/gist_id}","starred_url":"https://api.github.com/users/ruairif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruairif/subscriptions","organizations_url":"https://api.github.com/users/ruairif/orgs","repos_url":"https://api.github.com/users/ruairif/repos","events_url":"https://api.github.com/users/ruairif/events{/privacy}","received_events_url":"https://api.github.com/users/ruairif/received_events","type":"User","site_admin":false},"body":"","created_at":"2014-11-10T13:20:59Z","updated_at":"2015-03-03T13:52:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"83d75b42c3b50d9f0f2c0ca59c45e7d35a352eec","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/scrapy/scrapely/pulls/67/commits","review_comments_url":"https://api.github.com/repos/scrapy/scrapely/pulls/67/comments","review_comment_url":"https://api.github.com/repos/scrapy/scrapely/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scrapy/scrapely/issues/67/comments","statuses_url":"https://api.github.com/repos/scrapy/scrapely/statuses/834cf7e56d6d777a03b9c30a88b7f275b6c00a0d","head":{"label":"ruairif:master","ref":"master","sha":"834cf7e56d6d777a03b9c30a88b7f275b6c00a0d","user":{"login":"ruairif","id":6472969,"avatar_url":"https://avatars.githubusercontent.com/u/6472969?v=3","gravatar_id":"","url":"https://api.github.com/users/ruairif","html_url":"https://github.com/ruairif","followers_url":"https://api.github.com/users/ruairif/followers","following_url":"https://api.github.com/users/ruairif/following{/other_user}","gists_url":"https://api.github.com/users/ruairif/gists{/gist_id}","starred_url":"https://api.github.com/users/ruairif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruairif/subscriptions","organizations_url":"https://api.github.com/users/ruairif/orgs","repos_url":"https://api.github.com/users/ruairif/repos","events_url":"https://api.github.com/users/ruairif/events{/privacy}","received_events_url":"https://api.github.com/users/ruairif/received_events","type":"User","site_admin":false},"repo":{"id":26436703,"name":"scrapely","full_name":"ruairif/scrapely","owner":{"login":"ruairif","id":6472969,"avatar_url":"https://avatars.githubusercontent.com/u/6472969?v=3","gravatar_id":"","url":"https://api.github.com/users/ruairif","html_url":"https://github.com/ruairif","followers_url":"https://api.github.com/users/ruairif/followers","following_url":"https://api.github.com/users/ruairif/following{/other_user}","gists_url":"https://api.github.com/users/ruairif/gists{/gist_id}","starred_url":"https://api.github.com/users/ruairif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruairif/subscriptions","organizations_url":"https://api.github.com/users/ruairif/orgs","repos_url":"https://api.github.com/users/ruairif/repos","events_url":"https://api.github.com/users/ruairif/events{/privacy}","received_events_url":"https://api.github.com/users/ruairif/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ruairif/scrapely","description":"A pure-python HTML screen-scraping library","fork":true,"url":"https://api.github.com/repos/ruairif/scrapely","forks_url":"https://api.github.com/repos/ruairif/scrapely/forks","keys_url":"https://api.github.com/repos/ruairif/scrapely/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ruairif/scrapely/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ruairif/scrapely/teams","hooks_url":"https://api.github.com/repos/ruairif/scrapely/hooks","issue_events_url":"https://api.github.com/repos/ruairif/scrapely/issues/events{/number}","events_url":"https://api.github.com/repos/ruairif/scrapely/events","assignees_url":"https://api.github.com/repos/ruairif/scrapely/assignees{/user}","branches_url":"https://api.github.com/repos/ruairif/scrapely/branches{/branch}","tags_url":"https://api.github.com/repos/ruairif/scrapely/tags","blobs_url":"https://api.github.com/repos/ruairif/scrapely/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ruairif/scrapely/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ruairif/scrapely/git/refs{/sha}","trees_url":"https://api.github.com/repos/ruairif/scrapely/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ruairif/scrapely/statuses/{sha}","languages_url":"https://api.github.com/repos/ruairif/scrapely/languages","stargazers_url":"https://api.github.com/repos/ruairif/scrapely/stargazers","contributors_url":"https://api.github.com/repos/ruairif/scrapely/contributors","subscribers_url":"https://api.github.com/repos/ruairif/scrapely/subscribers","subscription_url":"https://api.github.com/repos/ruairif/scrapely/subscription","commits_url":"https://api.github.com/repos/ruairif/scrapely/commits{/sha}","git_commits_url":"https://api.github.com/repos/ruairif/scrapely/git/commits{/sha}","comments_url":"https://api.github.com/repos/ruairif/scrapely/comments{/number}","issue_comment_url":"https://api.github.com/repos/ruairif/scrapely/issues/comments{/number}","contents_url":"https://api.github.com/repos/ruairif/scrapely/contents/{+path}","compare_url":"https://api.github.com/repos/ruairif/scrapely/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ruairif/scrapely/merges","archive_url":"https://api.github.com/repos/ruairif/scrapely/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ruairif/scrapely/downloads","issues_url":"https://api.github.com/repos/ruairif/scrapely/issues{/number}","pulls_url":"https://api.github.com/repos/ruairif/scrapely/pulls{/number}","milestones_url":"https://api.github.com/repos/ruairif/scrapely/milestones{/number}","notifications_url":"https://api.github.com/repos/ruairif/scrapely/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ruairif/scrapely/labels{/name}","releases_url":"https://api.github.com/repos/ruairif/scrapely/releases{/id}","created_at":"2014-11-10T13:07:14Z","updated_at":"2015-03-03T09:31:19Z","pushed_at":"2015-03-03T09:31:19Z","git_url":"git://github.com/ruairif/scrapely.git","ssh_url":"git@github.com:ruairif/scrapely.git","clone_url":"https://github.com/ruairif/scrapely.git","svn_url":"https://github.com/ruairif/scrapely","homepage":"","size":448,"stargazers_count":0,"watchers_count":0,"language":"HTML","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":"scrapy:master","ref":"master","sha":"9644da3df000a8370625b275ac80147db52bc086","user":{"login":"scrapy","id":733635,"avatar_url":"https://avatars.githubusercontent.com/u/733635?v=3","gravatar_id":"","url":"https://api.github.com/users/scrapy","html_url":"https://github.com/scrapy","followers_url":"https://api.github.com/users/scrapy/followers","following_url":"https://api.github.com/users/scrapy/following{/other_user}","gists_url":"https://api.github.com/users/scrapy/gists{/gist_id}","starred_url":"https://api.github.com/users/scrapy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scrapy/subscriptions","organizations_url":"https://api.github.com/users/scrapy/orgs","repos_url":"https://api.github.com/users/scrapy/repos","events_url":"https://api.github.com/users/scrapy/events{/privacy}","received_events_url":"https://api.github.com/users/scrapy/received_events","type":"Organization","site_admin":false},"repo":{"id":1632998,"name":"scrapely","full_name":"scrapy/scrapely","owner":{"login":"scrapy","id":733635,"avatar_url":"https://avatars.githubusercontent.com/u/733635?v=3","gravatar_id":"","url":"https://api.github.com/users/scrapy","html_url":"https://github.com/scrapy","followers_url":"https://api.github.com/users/scrapy/followers","following_url":"https://api.github.com/users/scrapy/following{/other_user}","gists_url":"https://api.github.com/users/scrapy/gists{/gist_id}","starred_url":"https://api.github.com/users/scrapy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scrapy/subscriptions","organizations_url":"https://api.github.com/users/scrapy/orgs","repos_url":"https://api.github.com/users/scrapy/repos","events_url":"https://api.github.com/users/scrapy/events{/privacy}","received_events_url":"https://api.github.com/users/scrapy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scrapy/scrapely","description":"A pure-python HTML screen-scraping library","fork":false,"url":"https://api.github.com/repos/scrapy/scrapely","forks_url":"https://api.github.com/repos/scrapy/scrapely/forks","keys_url":"https://api.github.com/repos/scrapy/scrapely/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scrapy/scrapely/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scrapy/scrapely/teams","hooks_url":"https://api.github.com/repos/scrapy/scrapely/hooks","issue_events_url":"https://api.github.com/repos/scrapy/scrapely/issues/events{/number}","events_url":"https://api.github.com/repos/scrapy/scrapely/events","assignees_url":"https://api.github.com/repos/scrapy/scrapely/assignees{/user}","branches_url":"https://api.github.com/repos/scrapy/scrapely/branches{/branch}","tags_url":"https://api.github.com/repos/scrapy/scrapely/tags","blobs_url":"https://api.github.com/repos/scrapy/scrapely/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scrapy/scrapely/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scrapy/scrapely/git/refs{/sha}","trees_url":"https://api.github.com/repos/scrapy/scrapely/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scrapy/scrapely/statuses/{sha}","languages_url":"https://api.github.com/repos/scrapy/scrapely/languages","stargazers_url":"https://api.github.com/repos/scrapy/scrapely/stargazers","contributors_url":"https://api.github.com/repos/scrapy/scrapely/contributors","subscribers_url":"https://api.github.com/repos/scrapy/scrapely/subscribers","subscription_url":"https://api.github.com/repos/scrapy/scrapely/subscription","commits_url":"https://api.github.com/repos/scrapy/scrapely/commits{/sha}","git_commits_url":"https://api.github.com/repos/scrapy/scrapely/git/commits{/sha}","comments_url":"https://api.github.com/repos/scrapy/scrapely/comments{/number}","issue_comment_url":"https://api.github.com/repos/scrapy/scrapely/issues/comments{/number}","contents_url":"https://api.github.com/repos/scrapy/scrapely/contents/{+path}","compare_url":"https://api.github.com/repos/scrapy/scrapely/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scrapy/scrapely/merges","archive_url":"https://api.github.com/repos/scrapy/scrapely/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scrapy/scrapely/downloads","issues_url":"https://api.github.com/repos/scrapy/scrapely/issues{/number}","pulls_url":"https://api.github.com/repos/scrapy/scrapely/pulls{/number}","milestones_url":"https://api.github.com/repos/scrapy/scrapely/milestones{/number}","notifications_url":"https://api.github.com/repos/scrapy/scrapely/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scrapy/scrapely/labels{/name}","releases_url":"https://api.github.com/repos/scrapy/scrapely/releases{/id}","created_at":"2011-04-18T22:38:56Z","updated_at":"2015-03-03T08:24:04Z","pushed_at":"2015-01-26T16:30:08Z","git_url":"git://github.com/scrapy/scrapely.git","ssh_url":"git@github.com:scrapy/scrapely.git","clone_url":"https://github.com/scrapy/scrapely.git","svn_url":"https://github.com/scrapy/scrapely","homepage":"","size":1115,"stargazers_count":806,"watchers_count":806,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":119,"mirror_url":null,"open_issues_count":15,"forks":119,"open_issues":15,"watchers":806,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scrapy/scrapely/pulls/67"},"html":{"href":"https://github.com/scrapy/scrapely/pull/67"},"issue":{"href":"https://api.github.com/repos/scrapy/scrapely/issues/67"},"comments":{"href":"https://api.github.com/repos/scrapy/scrapely/issues/67/comments"},"review_comments":{"href":"https://api.github.com/repos/scrapy/scrapely/pulls/67/comments"},"review_comment":{"href":"https://api.github.com/repos/scrapy/scrapely/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scrapy/scrapely/pulls/67/commits"},"statuses":{"href":"https://api.github.com/repos/scrapy/scrapely/statuses/834cf7e56d6d777a03b9c30a88b7f275b6c00a0d"}}}}