{"action":"created","issue":{"url":"https://api.github.com/repos/pallets/flask/issues/2911","repository_url":"https://api.github.com/repos/pallets/flask","labels_url":"https://api.github.com/repos/pallets/flask/issues/2911/labels{/name}","comments_url":"https://api.github.com/repos/pallets/flask/issues/2911/comments","events_url":"https://api.github.com/repos/pallets/flask/issues/2911/events","html_url":"https://github.com/pallets/flask/issues/2911","id":360930219,"node_id":"MDU6SXNzdWUzNjA5MzAyMTk=","number":2911,"title":"Flaskr tutorial: auth.py raise a type error: tuple indices must be integers not str","user":{"login":"raindicky","id":36129561,"node_id":"MDQ6VXNlcjM2MTI5NTYx","avatar_url":"https://avatars2.githubusercontent.com/u/36129561?v=4","gravatar_id":"","url":"https://api.github.com/users/raindicky","html_url":"https://github.com/raindicky","followers_url":"https://api.github.com/users/raindicky/followers","following_url":"https://api.github.com/users/raindicky/following{/other_user}","gists_url":"https://api.github.com/users/raindicky/gists{/gist_id}","starred_url":"https://api.github.com/users/raindicky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raindicky/subscriptions","organizations_url":"https://api.github.com/users/raindicky/orgs","repos_url":"https://api.github.com/users/raindicky/repos","events_url":"https://api.github.com/users/raindicky/events{/privacy}","received_events_url":"https://api.github.com/users/raindicky/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-09-17T15:44:44Z","updated_at":"2018-09-17T15:52:51Z","closed_at":"2018-09-17T15:52:51Z","author_association":"NONE","body":"In the tutorial of flaskr, an error is raised when running the auth.py. In the development server, the following error is raised:\r\n\r\n```python\r\nFile \"~\\flaskr\\auth.py\", line 90, in login\r\nelif not check_password_hash(user['password'], password):\r\nTypeError: tuple indices must be integers or slices, not str\r\n```\r\n\r\nAnd then I trace back, in line 84, the following code:\r\n```python\r\nuser = db.execute(\r\n        'SELECT * FROM user WHERE username = ?', (username,)\r\n).fetchone().\r\n```\r\n\r\nThe function fetchone() should return a tuple. But in line 90, the function try to access the tuple by user['password']. Can tuple be accessed by this calling? I'm not pretty sure. But I can access the tuple by calling user[2] instead of user['password']. And actually the same situation in other python scripts. I'm not sure what is the case. \r\n### Environment\r\n\r\n* Python version: 3.7.0\r\n* Flask version: 1.0.2\r\n* Werkzeug version: 0.14.1\r\n"},"comment":{"url":"https://api.github.com/repos/pallets/flask/issues/comments/422070722","html_url":"https://github.com/pallets/flask/issues/2911#issuecomment-422070722","issue_url":"https://api.github.com/repos/pallets/flask/issues/2911","id":422070722,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMjA3MDcyMg==","user":{"login":"davidism","id":1242887,"node_id":"MDQ6VXNlcjEyNDI4ODc=","avatar_url":"https://avatars1.githubusercontent.com/u/1242887?v=4","gravatar_id":"","url":"https://api.github.com/users/davidism","html_url":"https://github.com/davidism","followers_url":"https://api.github.com/users/davidism/followers","following_url":"https://api.github.com/users/davidism/following{/other_user}","gists_url":"https://api.github.com/users/davidism/gists{/gist_id}","starred_url":"https://api.github.com/users/davidism/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidism/subscriptions","organizations_url":"https://api.github.com/users/davidism/orgs","repos_url":"https://api.github.com/users/davidism/repos","events_url":"https://api.github.com/users/davidism/events{/privacy}","received_events_url":"https://api.github.com/users/davidism/received_events","type":"User","site_admin":false},"created_at":"2018-09-17T15:52:51Z","updated_at":"2018-09-17T15:52:51Z","author_association":"MEMBER","body":"Be sure to follow the complete tutorial. You didn't set `g.db.row_factory = sqlite3.Row`. See http://flask.pocoo.org/docs/1.0/tutorial/database/#connect-to-the-database.\r\n\r\n```python\r\ndef get_db():\r\n    if 'db' not in g:\r\n        g.db = sqlite3.connect(\r\n            current_app.config['DATABASE'],\r\n            detect_types=sqlite3.PARSE_DECLTYPES\r\n        )\r\n        g.db.row_factory = sqlite3.Row\r\n\r\n    return g.db\r\n```"}}
{"actor":{"display_login":"davidism"}}