Skip to content

Instantly share code, notes, and snippets.

View asvetlov's full-sized avatar

Andrew Svetlov asvetlov

  • apolo.us
  • Gijon
View GitHub Profile
@asvetlov
asvetlov / hack.py
Created October 29, 2012 20:42
Hack to print Russian letters in unittests
# -*- encoding: utf-8 -*-
import unittest
class TestSomething(unittest.TestCase):
def test_unicode(self):
self.assertEqual(u'Русский', u'Текст')
if __name__ == '__main__':
import sys
def test_non_utf8(self):
# Issue #16218
with temp_dir() as script_dir:
script_basename = '\udcf1\udcea\udcf0\udce8\udcef\udcf2'
source = 'print("test output")\n'
script_name = _make_test_script(script_dir, script_basename, source)
if not __debug__:
run_args = ('-' + 'O' * sys.flags.optimize, script_name)
else:
run_args = (script_name,)
def test_non_utf8(self):
# Issue #16218
with temp_dir() as script_dir:
script_basename = '\udcf1\udcea\udcf0\udce8\udcef\udcf2'
source = 'print("test output")\n'
script_name = _make_test_script(script_dir, script_basename, source)
if not __debug__:
run_args = ('-' + 'O' * sys.flags.optimize, script_name)
else:
run_args = (script_name,)
def test_non_utf8(self):
# Issue #16218
with temp_dir() as script_dir:
script_basename = '\u0441\u043a\u0440\u0438\u043f\u0442'
try:
script_basename.encode(sys.getfilesystemencoding())
except UnicodeEncodeError:
raise unittest.SkipTest("Filesystem doesn't support "
"unicode names")
source = 'print("test output")\n'
[ui]
username = Andrew Svetlov <[email protected]>
merge = internal:merge
editor = emacs -nw
[diff]
git = on
showfunc = on
[extensions]
// pymulti.cpp — основной код
#include <iostream>
#include <cstdlib>
#include <conio.h>
#include <boost/python.hpp>
#include <boost/thread.hpp>
using namespace std;
using namespace boost::python;
@asvetlov
asvetlov / gist:9420657
Created March 7, 2014 21:35
Running subprocess from nonmain thread
from asyncio import *
@coroutine
def coro():
proc = yield from create_subprocess_exec('true')
yield from proc.wait()
print('subprocess returncode', proc.returncode)
def thr():
[user]
name = Andrew Svetlov
email = [email protected]
[color]
ui = true
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
st = status -sb
co = checkout
ci = commit
import asyncio
class A:
def __init__(self, reader, writter):
self.reader, self.writer = reader, writter
@asyncio.coroutine
def read_packet(self):
bsize = yield from self.reader.readexactly(4)
import asyncio
@asyncio.coroutine
def sender(queue):
print('sender started')
try:
yield from asyncio.sleep(3)
while True:
data = yield from queue.get()