Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: no need to encode arguments in python 3.x #120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ansiz
Copy link

@ansiz ansiz commented Jun 25, 2017

It seems there is no need to encode arguments in python 3.x, it reports errors on Windows while I set "browser_command": ["C:\Program Files (x86)\Google\Chrome\Application\chrome.exe","{url}"],:

OmniMarkupPreviewer: [ERROR] Error while launching user defined web browser
  Traceback (most recent call last):
    File "C:\Users\Ansiz\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupPreviewer.py", line 81, in launching_web_browser_for_url
    subprocess.Popen(browser_command)
    File "./python3.3/subprocess.py", line 819, in __init__
    File "./python3.3/subprocess.py", line 1063, in _execute_child
    File "./python3.3/subprocess.py", line 632, in list2cmdline
  TypeError: Type str doesn't support the buffer API

  no need to encode arguments in python 3.x
@duoluoxiaosheng
Copy link

I have the same problem. Have you solved it?

@ansiz
Copy link
Author

ansiz commented Apr 16, 2019

I have the same problem. Have you solved it?

yep, just modify the file as I commited

@duoluoxiaosheng
Copy link

It dosen't work!
My system is Windows 10
2

1

@ansiz
Copy link
Author

ansiz commented Apr 16, 2019

@duoluoxiaosheng 把你修改过的代码发来看一下吧,看看第80行报错的代码是什么内容

@duoluoxiaosheng
Copy link

duoluoxiaosheng commented Apr 16, 2019

我只是在用户配置文件添加了"browser_command"
并没有修改程序文件

def launching_web_browser_for_url(url, success_msg_default=None, success_msg_user=None):
    try:
        setting = Setting.instance()
        if setting.browser_command:
            browser_command = [os.path.expandvars(arg).format(url=url)
                               for arg in setting.browser_command]

            if os.name == 'nt':
                # unicode arguments broken under windows
                encoding = locale.getpreferredencoding()
                browser_command = [arg.encode(encoding) for arg in browser_command]

            subprocess.Popen(browser_command)
            if success_msg_user:
                sublime.status_message(success_msg_user)
        else:
            # Default web browser
            desktop.open(url)
            if success_msg_default:
                sublime.status_message(success_msg_default)
    except:
        if setting.browser_command:
            log.exception('Error while launching user defined web browser')
        else:
            log.exception('Error while launching default web browser')

第80行就是 subprocess.Popen(browser_command)

其中subprocessimport 的一个包

@ansiz
Copy link
Author

ansiz commented Apr 16, 2019

@duoluoxiaosheng 那你自己改一下吧,我写得很清楚呀,需要修改的地方在我提交的文件中,你照着改那么一行就行了

@duoluoxiaosheng
Copy link

好了,可以了,谢谢你

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants