Title: PYTHONSTARTUP file with non-ascii codes generates error · Issue #888 · bpython/bpython · GitHub
Open Graph Title: PYTHONSTARTUP file with non-ascii codes generates error · Issue #888 · bpython/bpython
X Title: PYTHONSTARTUP file with non-ascii codes generates error · Issue #888 · bpython/bpython
Description: I have this code set up on .pythonrc: try: import django from django.conf import settings if not settings.configured: django.setup() print('Imported django settings.') try: exec_strs = [ (app, 'from {}.models import *'.format(app)) for a...
Open Graph Description: I have this code set up on .pythonrc: try: import django from django.conf import settings if not settings.configured: django.setup() print('Imported django settings.') try: exec_strs = [ (app, 'fro...
X Description: I have this code set up on .pythonrc: try: import django from django.conf import settings if not settings.configured: django.setup() print('Imported django settings.') try: exec_strs = [ (a...
Opengraph URL: https://github.com/bpython/bpython/issues/888
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PYTHONSTARTUP file with non-ascii codes generates error","articleBody":"I have this code set up on `.pythonrc`:\r\n\r\n```\r\ntry:\r\n import django\r\n from django.conf import settings\r\n if not settings.configured:\r\n django.setup()\r\n print('Imported django settings.')\r\n try:\r\n exec_strs = [\r\n (app, 'from {}.models import *'.format(app))\r\n for app in settings.INSTALLED_APPS\r\n ]\r\n for app, x in exec_strs:\r\n try:\r\n exec(x)\r\n except:\r\n pass\r\n else:\r\n print('Imported models for app {}'.format(app))\r\n except:\r\n pass\r\nexcept django.core.exceptions.ImproperlyConfigured as msg:\r\n print('Erro na configuração do django ao importar módulo: {}'.format(msg))\r\n```\r\n\r\nOn latest bpython, it prints an ascii decode error whenever I start bpython (I'm running Python 3.9.2).\r\n\r\nThe issue is this code:\r\n\r\nhttps://github.com/bpython/bpython/blob/34f0e700082bf79223689ff120dddf4e46442129/bpython/inspection.py#L332\r\n\r\nIt assumes old style comment block `coding: utf-8`, and if it fails, then assumes ascii encoding.\r\n\r\nYou could assume `utf-8` encoding if there is no block, or try to decode the string and catch a `UnicodeDecodeError`.","author":{"url":"https://github.com/niloct","@type":"Person","name":"niloct"},"datePublished":"2021-03-11T22:35:27.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/888/bpython/issues/888"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8f5774a8-caed-8ed9-b5e3-fd78ab276f04 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B65A:1EF88C:597D17:7CCB58:6968DF01 |
| html-safe-nonce | 12109091d99dc31597e5c1a6ca163d8de554a2391d5ef0f2a58cfac0bfa7acb1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNjVBOjFFRjg4Qzo1OTdEMTc6N0NDQjU4OjY5NjhERjAxIiwidmlzaXRvcl9pZCI6IjQ4ODc1MTI1MzUwOTE2OTk0NTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 252b3e9b813733fa00313df87cecba95d1b99acd0a08204be77365971286545c |
| hovercard-subject-tag | issue:829576220 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/bpython/bpython/888/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fa7aa2eac7dc9328479f18c7df2c25558a80872815ec3ed2d7f04c1e2573da08/bpython/bpython/issues/888 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fa7aa2eac7dc9328479f18c7df2c25558a80872815ec3ed2d7f04c1e2573da08/bpython/bpython/issues/888 |
| og:image:alt | I have this code set up on .pythonrc: try: import django from django.conf import settings if not settings.configured: django.setup() print('Imported django settings.') try: exec_strs = [ (app, 'fro... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | niloct |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3c4e9f2fc1db52c609205138be6a397cfde4574cb54d53015014de30dd49f27e |
| turbo-cache-control | no-preview |
| go-import | github.com/bpython/bpython git https://github.com/bpython/bpython.git |
| octolytics-dimension-user_id | 8071396 |
| octolytics-dimension-user_login | bpython |
| octolytics-dimension-repository_id | 21508865 |
| octolytics-dimension-repository_nwo | bpython/bpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 21508865 |
| octolytics-dimension-repository_network_root_nwo | bpython/bpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 1fb1ea11f8c37dd4dd50347cca70d89824e93788 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width