def create_new_paste(contents):
import re<EOL>if sys.version_info < (<NUM_LIT:3>, <NUM_LIT:0>):<EOL><INDENT>from urllib import urlopen, urlencode<EOL><DEDENT>else:<EOL><INDENT>from urllib.request import urlopen<EOL>from urllib.parse import urlencode<EOL><DEDENT>params = {<EOL>"<STR_LIT:code>": contents,<EOL>"<STR_LIT>": "<STR_LIT>" if sys.version_info[<NUM_LIT:0>] == <NUM_LIT:3> else "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>}<EOL>url = "<STR_LIT>"<EOL>response = urlopen(url, data=urlencode(params).encode("<STR_LIT:ascii>")).read()<EOL>m = re.search(r'<STR_LIT>', response.decode("<STR_LIT:utf-8>"))<EOL>if m:<EOL><INDENT>return "<STR_LIT>" % (url, m.group(<NUM_LIT:1>))<EOL><DEDENT>else:<EOL><INDENT>return "<STR_LIT>" + response<EOL><DEDENT>
Creates a new paste using bpaste.net service.

:contents: paste contents as utf-8 encoded bytes
:returns: url to the pasted contents