{"action":"closed","issue":{"url":"https://api.github.com/repos/BoboTiG/python-mss/issues/61","repository_url":"https://api.github.com/repos/BoboTiG/python-mss","labels_url":"https://api.github.com/repos/BoboTiG/python-mss/issues/61/labels{/name}","comments_url":"https://api.github.com/repos/BoboTiG/python-mss/issues/61/comments","events_url":"https://api.github.com/repos/BoboTiG/python-mss/issues/61/events","html_url":"https://github.com/BoboTiG/python-mss/issues/61","id":345709597,"node_id":"MDU6SXNzdWUzNDU3MDk1OTc=","number":61,"title":"[XServer] Library makes program hard crash when monitor is out of bounds","user":{"login":"RedFantom","id":15170036,"node_id":"MDQ6VXNlcjE1MTcwMDM2","avatar_url":"https://avatars0.githubusercontent.com/u/15170036?v=4","gravatar_id":"","url":"https://api.github.com/users/RedFantom","html_url":"https://github.com/RedFantom","followers_url":"https://api.github.com/users/RedFantom/followers","following_url":"https://api.github.com/users/RedFantom/following{/other_user}","gists_url":"https://api.github.com/users/RedFantom/gists{/gist_id}","starred_url":"https://api.github.com/users/RedFantom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RedFantom/subscriptions","organizations_url":"https://api.github.com/users/RedFantom/orgs","repos_url":"https://api.github.com/users/RedFantom/repos","events_url":"https://api.github.com/users/RedFantom/events{/privacy}","received_events_url":"https://api.github.com/users/RedFantom/received_events","type":"User","site_admin":false},"labels":[{"id":504186471,"node_id":"MDU6TGFiZWw1MDQxODY0NzE=","url":"https://api.github.com/repos/BoboTiG/python-mss/labels/GNU/Linux","name":"GNU/Linux","color":"fbca04","default":false},{"id":45944199,"node_id":"MDU6TGFiZWw0NTk0NDE5OQ==","url":"https://api.github.com/repos/BoboTiG/python-mss/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-07-30T10:59:02Z","updated_at":"2018-08-05T10:30:28Z","closed_at":"2018-08-05T10:30:28Z","author_association":"NONE","body":"General information:\r\n\r\n* OS name: _Ubuntu (`ubuntu-desktop`)_\r\n* OS version: __18.04 LTS__\r\n* OS architecture: _64 bits_\r\n* Resolutions:\r\n    * Monitor 1: _1920x1080 (laptop built-in)_\r\n    * Monitor 2: _1366x768 (external)_\r\n* Python version: _3.6.5_\r\n* MSS version: __3.2.0__\r\n\r\n\r\nFor GNU/Linux users:\r\n\r\n* Display server protocol and version, if known: __X server__ _(X.Org version: 1.19.6)_\r\n* Desktop Environment: _Gnome 3_\r\n* Composite Window Manager name and version: __???__ (The default one, I guess?)\r\n\r\n\r\n### Description of the warning/error\r\nThis error occurs when the a monitor that is out of bounds is specified in the `grab()` call.\r\n```python\r\nfrom mss import mss\r\n\r\nscreenshotter = mss()\r\nmonitor = {\r\n    \"left\": -30,\r\n    \"top\": 0,\r\n    \"width\": 100,\r\n    \"height\": 100,\r\n}\r\ntry:\r\n    screenshotter.grab(monitor)  # X Error\r\nexcept BaseException as e:\r\n    # Never reached\r\n    print(\"Handling error\")\r\n```\r\nUsing a monitor like `{\"left\": 0, \"top\": 0, \"width\": 10000, \"height\": 100}` has the same result.\r\n### Full message\r\n```stderr\r\nX Error of failed request:  BadMatch (invalid parameter attributes)\r\n  Major opcode of failed request:  73 (X_GetImage)\r\n  Serial number of failed request:  91\r\n  Current serial number in output stream:  91\r\n```\r\nThe message is printed to `stderr`, then the Python interpreter quits with exit code `1`.\r\n\r\n### Other details\r\nI discovered this because I let my program generate a box based on the location of the cursor. Then I take the screenshot of only the cursor area.\r\n\r\nWhile it might be better for efficiency not to check the bounds of the monitor, I personally don't think causing this type of hard crash is acceptable. It's up to you. If you decide not to check bounds, I think a mention of this in the documentation would be appropriate.\r\n"}}
{"actor":{"display_login":"BoboTiG"}}