aboutsummaryrefslogtreecommitdiffstats
path: root/library/python
diff options
context:
space:
mode:
authororivej <orivej@yandex-team.ru>2022-02-10 16:44:49 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:49 +0300
commit718c552901d703c502ccbefdfc3c9028d608b947 (patch)
tree46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /library/python
parente9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff)
downloadydb-718c552901d703c502ccbefdfc3c9028d608b947.tar.gz
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/python')
-rw-r--r--library/python/certifi/.dist-info/METADATA2
-rw-r--r--library/python/certifi/README.md14
-rw-r--r--library/python/certifi/certifi/__init__.py12
-rw-r--r--library/python/certifi/certifi/binary.py50
-rw-r--r--library/python/certifi/certifi/source.py26
-rw-r--r--library/python/certifi/ya.make24
-rw-r--r--library/python/pytest/plugins/collection.py2
-rw-r--r--library/python/pytest/plugins/conftests.py18
-rw-r--r--library/python/resource/__init__.py78
-rw-r--r--library/python/resource/ut/lib/test_simple.py34
-rw-r--r--library/python/resource/ut/lib/ya.make2
-rw-r--r--library/python/resource/ut/py2/ya.make2
-rw-r--r--library/python/resource/ut/py3/ya.make4
-rw-r--r--library/python/resource/ya.make8
-rw-r--r--library/python/runtime_py3/__res.pyx16
-rw-r--r--library/python/runtime_py3/entry_points.py86
-rw-r--r--library/python/runtime_py3/importer.pxi390
-rw-r--r--library/python/runtime_py3/main/main.c64
-rw-r--r--library/python/runtime_py3/main/ya.make14
-rw-r--r--library/python/runtime_py3/sitecustomize.pyx2
-rw-r--r--library/python/runtime_py3/ya.make20
-rw-r--r--library/python/symbols/libc/syms.cpp138
-rw-r--r--library/python/symbols/libc/ya.make28
-rw-r--r--library/python/symbols/module/module.cpp84
-rw-r--r--library/python/symbols/module/ya.make10
-rw-r--r--library/python/symbols/python/syms.cpp32
-rw-r--r--library/python/symbols/python/ut/py2/ya.make16
-rw-r--r--library/python/symbols/python/ut/py3/ya.make18
-rw-r--r--library/python/symbols/python/ut/test_ctypes.py2
-rw-r--r--library/python/symbols/python/ut/ya.make12
-rw-r--r--library/python/symbols/python/ya.make26
-rw-r--r--library/python/symbols/ya.make8
-rw-r--r--library/python/testing/import_test/import_test.py106
-rw-r--r--library/python/testing/yatest_common/yatest/common/process.py8
-rw-r--r--library/python/ya.make28
35 files changed, 692 insertions, 692 deletions
diff --git a/library/python/certifi/.dist-info/METADATA b/library/python/certifi/.dist-info/METADATA
index 4849f81ed4..12bf982cf3 100644
--- a/library/python/certifi/.dist-info/METADATA
+++ b/library/python/certifi/.dist-info/METADATA
@@ -1,2 +1,2 @@
Name: certifi
-Version: 2019.7.1
+Version: 2019.7.1
diff --git a/library/python/certifi/README.md b/library/python/certifi/README.md
index 75a812733c..96dcc4c1c3 100644
--- a/library/python/certifi/README.md
+++ b/library/python/certifi/README.md
@@ -1,7 +1,7 @@
-This library provides arcadia certs via certifi-compatible API.
-
-In binary (single executable) mode it patches python ssl module to
-support loading certs from memory.
-
-.dist-info/METADATA version reflects the last update time of the
-arcadia certs.
+This library provides arcadia certs via certifi-compatible API.
+
+In binary (single executable) mode it patches python ssl module to
+support loading certs from memory.
+
+.dist-info/METADATA version reflects the last update time of the
+arcadia certs.
diff --git a/library/python/certifi/certifi/__init__.py b/library/python/certifi/certifi/__init__.py
index 5270d206cd..8d14209d03 100644
--- a/library/python/certifi/certifi/__init__.py
+++ b/library/python/certifi/certifi/__init__.py
@@ -1,9 +1,9 @@
-import ssl
-
-if hasattr(ssl, 'builtin_cadata'):
- from .binary import where
-else:
- from .source import where
+import ssl
+
+if hasattr(ssl, 'builtin_cadata'):
+ from .binary import where
+else:
+ from .source import where
__all__ = ['where', '__version__']
diff --git a/library/python/certifi/certifi/binary.py b/library/python/certifi/certifi/binary.py
index 1050e733a3..523fe31287 100644
--- a/library/python/certifi/certifi/binary.py
+++ b/library/python/certifi/certifi/binary.py
@@ -1,25 +1,25 @@
-import ssl
-
-
-def builtin_ca():
- return None, None, ssl.builtin_cadata()
-
-
-# Normally certifi.where() returns a path to a certificate file;
-# here it returns a callable.
-def where():
- return builtin_ca
-
-
-# Patch ssl module to accept a callable cafile.
-load_verify_locations = ssl.SSLContext.load_verify_locations
-
-
-def load_verify_locations__callable(self, cafile=None, capath=None, cadata=None):
- if callable(cafile):
- cafile, capath, cadata = cafile()
-
- return load_verify_locations(self, cafile, capath, cadata)
-
-
-ssl.SSLContext.load_verify_locations = load_verify_locations__callable
+import ssl
+
+
+def builtin_ca():
+ return None, None, ssl.builtin_cadata()
+
+
+# Normally certifi.where() returns a path to a certificate file;
+# here it returns a callable.
+def where():
+ return builtin_ca
+
+
+# Patch ssl module to accept a callable cafile.
+load_verify_locations = ssl.SSLContext.load_verify_locations
+
+
+def load_verify_locations__callable(self, cafile=None, capath=None, cadata=None):
+ if callable(cafile):
+ cafile, capath, cadata = cafile()
+
+ return load_verify_locations(self, cafile, capath, cadata)
+
+
+ssl.SSLContext.load_verify_locations = load_verify_locations__callable
diff --git a/library/python/certifi/certifi/source.py b/library/python/certifi/certifi/source.py
index f539b67002..81566bbf32 100644
--- a/library/python/certifi/certifi/source.py
+++ b/library/python/certifi/certifi/source.py
@@ -1,13 +1,13 @@
-import os.path
-
-pem = os.path.abspath(__file__)
-pem = os.path.dirname(pem)
-pem = os.path.dirname(pem)
-pem = os.path.dirname(pem)
-pem = os.path.dirname(pem)
-pem = os.path.dirname(pem)
-pem = os.path.join(pem, 'certs', 'cacert.pem')
-
-
-def where():
- return pem
+import os.path
+
+pem = os.path.abspath(__file__)
+pem = os.path.dirname(pem)
+pem = os.path.dirname(pem)
+pem = os.path.dirname(pem)
+pem = os.path.dirname(pem)
+pem = os.path.dirname(pem)
+pem = os.path.join(pem, 'certs', 'cacert.pem')
+
+
+def where():
+ return pem
diff --git a/library/python/certifi/ya.make b/library/python/certifi/ya.make
index 64fefe2833..398210c0e6 100644
--- a/library/python/certifi/ya.make
+++ b/library/python/certifi/ya.make
@@ -1,18 +1,18 @@
PY23_LIBRARY()
-
-OWNER(orivej g:python-contrib)
-
+
+OWNER(orivej g:python-contrib)
+
RESOURCE_FILES(
- PREFIX library/python/certifi/
+ PREFIX library/python/certifi/
.dist-info/METADATA
.dist-info/top_level.txt
)
-PY_SRCS(
- TOP_LEVEL
- certifi/__init__.py
- certifi/binary.py
- certifi/source.py
-)
-
-END()
+PY_SRCS(
+ TOP_LEVEL
+ certifi/__init__.py
+ certifi/binary.py
+ certifi/source.py
+)
+
+END()
diff --git a/library/python/pytest/plugins/collection.py b/library/python/pytest/plugins/collection.py
index e36f47a78f..79b58cff73 100644
--- a/library/python/pytest/plugins/collection.py
+++ b/library/python/pytest/plugins/collection.py
@@ -69,7 +69,7 @@ class DoctestModule(LoadedModule):
parent=self,
runner=runner,
dtest=test)
- except Exception:
+ except Exception:
import logging
logging.exception('DoctestModule failed, probably you can add NO_DOCTESTS() macro to ya.make')
etype, exc, tb = sys.exc_info()
diff --git a/library/python/pytest/plugins/conftests.py b/library/python/pytest/plugins/conftests.py
index 522041f5a7..17cf1197e5 100644
--- a/library/python/pytest/plugins/conftests.py
+++ b/library/python/pytest/plugins/conftests.py
@@ -1,6 +1,6 @@
import os
import importlib
-import sys
+import sys
import inspect
from pytest import hookimpl
@@ -18,19 +18,19 @@ def getfile(object):
return res
inspect.getfile = getfile
-conftest_modules = []
+conftest_modules = []
@hookimpl(trylast=True)
def pytest_load_initial_conftests(early_config, parser, args):
conftests = filter(lambda name: name.endswith(".conftest"), sys.extra_modules)
-
+
def conftest_key(name):
if not name.startswith("__tests__."):
# Make __tests__ come last
return "_." + name
return name
-
+
for name in sorted(conftests, key=conftest_key):
mod = importlib.import_module(name)
if os.getenv("CONFTEST_LOAD_POLICY") != "LOCAL":
@@ -40,11 +40,11 @@ def pytest_load_initial_conftests(early_config, parser, args):
early_config.pluginmanager.consider_conftest(mod)
-def getconftestmodules(*args, **kwargs):
- return conftest_modules
-
-
-def pytest_sessionstart(session):
+def getconftestmodules(*args, **kwargs):
+ return conftest_modules
+
+
+def pytest_sessionstart(session):
# Override filesystem based relevant conftest discovery on the call path
assert session.config.pluginmanager
session.config.pluginmanager._getconftestmodules = getconftestmodules
diff --git a/library/python/resource/__init__.py b/library/python/resource/__init__.py
index 26503ef7fc..dd00de7b43 100644
--- a/library/python/resource/__init__.py
+++ b/library/python/resource/__init__.py
@@ -1,46 +1,46 @@
-from __res import find as __find, count, key_by_index, resfs_files as __resfs_files
-from __res import resfs_read, resfs_resolve, resfs_src # noqa
+from __res import find as __find, count, key_by_index, resfs_files as __resfs_files
+from __res import resfs_read, resfs_resolve, resfs_src # noqa
-import six
+import six
-def iterkeys(prefix='', strip_prefix=False):
- decode = lambda s: s
- if isinstance(prefix, six.text_type):
- prefix = prefix.encode('utf-8')
- decode = lambda s: s.decode('utf-8')
-
- for i in six.moves.range(count()):
+def iterkeys(prefix='', strip_prefix=False):
+ decode = lambda s: s
+ if isinstance(prefix, six.text_type):
+ prefix = prefix.encode('utf-8')
+ decode = lambda s: s.decode('utf-8')
+
+ for i in six.moves.range(count()):
key = key_by_index(i)
- if key.startswith(prefix):
- if strip_prefix:
- key = key[len(prefix):]
- yield decode(key)
-
-
-def itervalues(prefix=b''):
- for key in iterkeys(prefix=prefix):
- value = find(key)
- yield value
-
-
-def iteritems(prefix='', strip_prefix=False):
- for key in iterkeys(prefix=prefix):
- value = find(key)
- if strip_prefix:
- key = key[len(prefix):]
- yield key, value
-
-
-def resfs_file_exists(path):
- return resfs_src(path, resfs_file=True) is not None
-
-
-def resfs_files(prefix=''):
- decode = lambda s: s
- if isinstance(prefix, six.text_type):
- decode = lambda s: s.decode('utf-8')
- return [decode(s) for s in __resfs_files(prefix=prefix)]
+ if key.startswith(prefix):
+ if strip_prefix:
+ key = key[len(prefix):]
+ yield decode(key)
+
+
+def itervalues(prefix=b''):
+ for key in iterkeys(prefix=prefix):
+ value = find(key)
+ yield value
+
+
+def iteritems(prefix='', strip_prefix=False):
+ for key in iterkeys(prefix=prefix):
+ value = find(key)
+ if strip_prefix:
+ key = key[len(prefix):]
+ yield key, value
+
+
+def resfs_file_exists(path):
+ return resfs_src(path, resfs_file=True) is not None
+
+
+def resfs_files(prefix=''):
+ decode = lambda s: s
+ if isinstance(prefix, six.text_type):
+ decode = lambda s: s.decode('utf-8')
+ return [decode(s) for s in __resfs_files(prefix=prefix)]
def find(path):
diff --git a/library/python/resource/ut/lib/test_simple.py b/library/python/resource/ut/lib/test_simple.py
index 52f006ff91..4fd3747311 100644
--- a/library/python/resource/ut/lib/test_simple.py
+++ b/library/python/resource/ut/lib/test_simple.py
@@ -2,25 +2,25 @@ import six # noqa
import library.python.resource as rs
-text = b'na gorshke sidel korol\n'
-
+text = b'na gorshke sidel korol\n'
+
def test_find():
- assert rs.find('/qw.txt') == text
-
-
-def test_iter():
- assert set(rs.iterkeys()).issuperset({'/qw.txt', '/prefix/1.txt', '/prefix/2.txt'})
- assert set(rs.iterkeys(prefix='/prefix/')) == {'/prefix/1.txt', '/prefix/2.txt'}
- assert set(rs.iterkeys(prefix='/prefix/', strip_prefix=True)) == {'1.txt', '2.txt'}
- assert set(rs.iteritems(prefix='/prefix')) == {
- ('/prefix/1.txt', text),
- ('/prefix/2.txt', text),
- }
- assert set(rs.iteritems(prefix='/prefix', strip_prefix=True)) == {
- ('/1.txt', text),
- ('/2.txt', text),
- }
+ assert rs.find('/qw.txt') == text
+
+
+def test_iter():
+ assert set(rs.iterkeys()).issuperset({'/qw.txt', '/prefix/1.txt', '/prefix/2.txt'})
+ assert set(rs.iterkeys(prefix='/prefix/')) == {'/prefix/1.txt', '/prefix/2.txt'}
+ assert set(rs.iterkeys(prefix='/prefix/', strip_prefix=True)) == {'1.txt', '2.txt'}
+ assert set(rs.iteritems(prefix='/prefix')) == {
+ ('/prefix/1.txt', text),
+ ('/prefix/2.txt', text),
+ }
+ assert set(rs.iteritems(prefix='/prefix', strip_prefix=True)) == {
+ ('/1.txt', text),
+ ('/2.txt', text),
+ }
def test_resfs_files():
diff --git a/library/python/resource/ut/lib/ya.make b/library/python/resource/ut/lib/ya.make
index 693e388878..5019adb9f7 100644
--- a/library/python/resource/ut/lib/ya.make
+++ b/library/python/resource/ut/lib/ya.make
@@ -1,4 +1,4 @@
-PY23_LIBRARY()
+PY23_LIBRARY()
OWNER(pg)
diff --git a/library/python/resource/ut/py2/ya.make b/library/python/resource/ut/py2/ya.make
index 5085610faf..52028b5f4e 100644
--- a/library/python/resource/ut/py2/ya.make
+++ b/library/python/resource/ut/py2/ya.make
@@ -3,7 +3,7 @@ PY2TEST()
OWNER(pg)
PEERDIR(
- library/python/resource/ut/lib
+ library/python/resource/ut/lib
)
END()
diff --git a/library/python/resource/ut/py3/ya.make b/library/python/resource/ut/py3/ya.make
index 64eb2e83ce..bcd5b141b5 100644
--- a/library/python/resource/ut/py3/ya.make
+++ b/library/python/resource/ut/py3/ya.make
@@ -1,9 +1,9 @@
PY3TEST()
-OWNER(pg)
+OWNER(pg)
PEERDIR(
- library/python/resource/ut/lib
+ library/python/resource/ut/lib
)
END()
diff --git a/library/python/resource/ya.make b/library/python/resource/ya.make
index 989329fa4b..7e5af9a55e 100644
--- a/library/python/resource/ya.make
+++ b/library/python/resource/ya.make
@@ -2,10 +2,10 @@ PY23_LIBRARY()
OWNER(pg)
-PEERDIR(
- contrib/python/six
-)
-
+PEERDIR(
+ contrib/python/six
+)
+
PY_SRCS(__init__.py)
END()
diff --git a/library/python/runtime_py3/__res.pyx b/library/python/runtime_py3/__res.pyx
index 97190d9f29..c0e17b7de8 100644
--- a/library/python/runtime_py3/__res.pyx
+++ b/library/python/runtime_py3/__res.pyx
@@ -1,5 +1,5 @@
-from _codecs import utf_8_decode, utf_8_encode
-
+from _codecs import utf_8_decode, utf_8_encode
+
from libcpp cimport bool
from util.generic.string cimport TString, TStringBuf
@@ -24,13 +24,13 @@ def key_by_index(idx):
def find(s):
cdef TString res
- if isinstance(s, str):
- s = utf_8_encode(s)[0]
-
+ if isinstance(s, str):
+ s = utf_8_encode(s)[0]
+
if FindExact(TStringBuf(s, len(s)), &res):
return res.c_str()[:res.length()]
return None
-
-
-include "importer.pxi"
+
+
+include "importer.pxi"
diff --git a/library/python/runtime_py3/entry_points.py b/library/python/runtime_py3/entry_points.py
index 05098723cb..0639bc4aaf 100644
--- a/library/python/runtime_py3/entry_points.py
+++ b/library/python/runtime_py3/entry_points.py
@@ -1,47 +1,47 @@
-import sys
-
-import __res
-
-
-def repl():
- user_ns = {}
- py_main = __res.find('PY_MAIN')
-
- if py_main:
- mod_name, func_name = (py_main.split(b':', 1) + [None])[:2]
- try:
- import importlib
- mod = importlib.import_module(mod_name.decode('UTF-8'))
- user_ns = mod.__dict__
- except:
- import traceback
- traceback.print_exc()
-
- if func_name and '__main__' not in user_ns:
- def run(args):
+import sys
+
+import __res
+
+
+def repl():
+ user_ns = {}
+ py_main = __res.find('PY_MAIN')
+
+ if py_main:
+ mod_name, func_name = (py_main.split(b':', 1) + [None])[:2]
+ try:
+ import importlib
+ mod = importlib.import_module(mod_name.decode('UTF-8'))
+ user_ns = mod.__dict__
+ except:
+ import traceback
+ traceback.print_exc()
+
+ if func_name and '__main__' not in user_ns:
+ def run(args):
if isinstance(args, str):
- import shlex
- args = shlex.split(args)
-
- import sys
- sys.argv = [sys.argv[0]] + args
- getattr(mod, func_name)()
-
- user_ns['__main__'] = run
-
- try:
- import IPython
- except ModuleNotFoundError:
- pass
- else:
- return IPython.start_ipython(user_ns=user_ns)
-
- import code
- code.interact(local=user_ns)
-
-
-def resource_files():
- sys.stdout.buffer.write(b'\n'.join(sorted(__res.resfs_files()) + [b'']))
+ import shlex
+ args = shlex.split(args)
+
+ import sys
+ sys.argv = [sys.argv[0]] + args
+ getattr(mod, func_name)()
+
+ user_ns['__main__'] = run
+
+ try:
+ import IPython
+ except ModuleNotFoundError:
+ pass
+ else:
+ return IPython.start_ipython(user_ns=user_ns)
+
+ import code
+ code.interact(local=user_ns)
+
+
+def resource_files():
+ sys.stdout.buffer.write(b'\n'.join(sorted(__res.resfs_files()) + [b'']))
def run_constructors():
diff --git a/library/python/runtime_py3/importer.pxi b/library/python/runtime_py3/importer.pxi
index 904f94dea2..7caa69e91e 100644
--- a/library/python/runtime_py3/importer.pxi
+++ b/library/python/runtime_py3/importer.pxi
@@ -1,30 +1,30 @@
-import marshal
+import marshal
import sys
-from _codecs import utf_8_decode, utf_8_encode
+from _codecs import utf_8_decode, utf_8_encode
from _frozen_importlib import _call_with_frames_removed, spec_from_loader, BuiltinImporter
from _frozen_importlib_external import _os, _path_isfile, _path_isdir, _path_isabs, path_sep, _path_join, _path_split
-from _io import FileIO
-
+from _io import FileIO
+
import __res as __resource
-_b = lambda x: x if isinstance(x, bytes) else utf_8_encode(x)[0]
-_s = lambda x: x if isinstance(x, str) else utf_8_decode(x)[0]
-env_entry_point = b'Y_PYTHON_ENTRY_POINT'
-env_source_root = b'Y_PYTHON_SOURCE_ROOT'
+_b = lambda x: x if isinstance(x, bytes) else utf_8_encode(x)[0]
+_s = lambda x: x if isinstance(x, str) else utf_8_decode(x)[0]
+env_entry_point = b'Y_PYTHON_ENTRY_POINT'
+env_source_root = b'Y_PYTHON_SOURCE_ROOT'
cfg_source_root = b'arcadia-source-root'
env_extended_source_search = b'Y_PYTHON_EXTENDED_SOURCE_SEARCH'
res_ya_ide_venv = b'YA_IDE_VENV'
executable = sys.executable or 'Y_PYTHON'
-sys.modules['run_import_hook'] = __resource
-
-# This is the prefix in contrib/tools/python3/src/Lib/ya.make.
-py_prefix = b'py/'
-py_prefix_len = len(py_prefix)
+sys.modules['run_import_hook'] = __resource
+# This is the prefix in contrib/tools/python3/src/Lib/ya.make.
+py_prefix = b'py/'
+py_prefix_len = len(py_prefix)
+
YA_IDE_VENV = __resource.find(res_ya_ide_venv)
Y_PYTHON_EXTENDED_SOURCE_SEARCH = _os.environ.get(env_extended_source_search) or YA_IDE_VENV
-
-
+
+
def _init_venv():
if not _path_isabs(executable):
raise RuntimeError('path in sys.executable is not absolute: {}'.format(executable))
@@ -74,112 +74,112 @@ def _get_source_root():
Y_PYTHON_SOURCE_ROOT = _get_source_root()
-def _print(*xs):
- """
- This is helpful for debugging, since automatic bytes to str conversion is
- not available yet. It is also possible to debug with GDB by breaking on
- __Pyx_AddTraceback (with Python GDB pretty printers enabled).
- """
- parts = []
- for s in xs:
- if not isinstance(s, (bytes, str)):
- s = str(s)
- parts.append(_s(s))
- sys.stderr.write(' '.join(parts) + '\n')
-
-
-def file_bytes(path):
- # 'open' is not avaiable yet.
- with FileIO(path, 'r') as f:
- return f.read()
-
-
-def iter_keys(prefix):
- l = len(prefix)
- for idx in range(__resource.count()):
+def _print(*xs):
+ """
+ This is helpful for debugging, since automatic bytes to str conversion is
+ not available yet. It is also possible to debug with GDB by breaking on
+ __Pyx_AddTraceback (with Python GDB pretty printers enabled).
+ """
+ parts = []
+ for s in xs:
+ if not isinstance(s, (bytes, str)):
+ s = str(s)
+ parts.append(_s(s))
+ sys.stderr.write(' '.join(parts) + '\n')
+
+
+def file_bytes(path):
+ # 'open' is not avaiable yet.
+ with FileIO(path, 'r') as f:
+ return f.read()
+
+
+def iter_keys(prefix):
+ l = len(prefix)
+ for idx in range(__resource.count()):
key = __resource.key_by_index(idx)
- if key.startswith(prefix):
- yield key, key[l:]
-
+ if key.startswith(prefix):
+ yield key, key[l:]
-def iter_py_modules(with_keys=False):
- for key, path in iter_keys(b'resfs/file/' + py_prefix):
- if path.endswith(b'.py'): # It may also end with '.pyc'.
- mod = _s(path[:-3].replace(b'/', b'.'))
- if with_keys:
- yield key, mod
- else:
- yield mod
+
+def iter_py_modules(with_keys=False):
+ for key, path in iter_keys(b'resfs/file/' + py_prefix):
+ if path.endswith(b'.py'): # It may also end with '.pyc'.
+ mod = _s(path[:-3].replace(b'/', b'.'))
+ if with_keys:
+ yield key, mod
+ else:
+ yield mod
-def iter_prefixes(s):
- i = s.find('.')
- while i >= 0:
- yield s[:i]
- i = s.find('.', i + 1)
+def iter_prefixes(s):
+ i = s.find('.')
+ while i >= 0:
+ yield s[:i]
+ i = s.find('.', i + 1)
def resfs_resolve(path):
- """
- Return the absolute path of a root-relative path if it exists.
- """
- path = _b(path)
- if Y_PYTHON_SOURCE_ROOT:
- if not path.startswith(Y_PYTHON_SOURCE_ROOT):
- path = _b(path_sep).join((Y_PYTHON_SOURCE_ROOT, path))
- if _path_isfile(path):
- return path
-
-
-def resfs_src(key, resfs_file=False):
- """
- Return the root-relative file path of a resource key.
- """
- if resfs_file:
- key = b'resfs/file/' + _b(key)
- return __resource.find(b'resfs/src/' + _b(key))
-
-
+ """
+ Return the absolute path of a root-relative path if it exists.
+ """
+ path = _b(path)
+ if Y_PYTHON_SOURCE_ROOT:
+ if not path.startswith(Y_PYTHON_SOURCE_ROOT):
+ path = _b(path_sep).join((Y_PYTHON_SOURCE_ROOT, path))
+ if _path_isfile(path):
+ return path
+
+
+def resfs_src(key, resfs_file=False):
+ """
+ Return the root-relative file path of a resource key.
+ """
+ if resfs_file:
+ key = b'resfs/file/' + _b(key)
+ return __resource.find(b'resfs/src/' + _b(key))
+
+
def resfs_read(path, builtin=None):
+ """
+ Return the bytes of the resource file at path, or None.
+ If builtin is True, do not look for it on the filesystem.
+ If builtin is False, do not look in the builtin resources.
+ """
+ if builtin is not True:
+ arcpath = resfs_src(path, resfs_file=True)
+ if arcpath:
+ fspath = resfs_resolve(arcpath)
+ if fspath:
+ return file_bytes(fspath)
+
+ if builtin is not False:
+ return __resource.find(b'resfs/file/' + _b(path))
+
+
+def resfs_files(prefix=b''):
+ """
+ List builtin resource file paths.
+ """
+ return [key[11:] for key, _ in iter_keys(b'resfs/file/' + _b(prefix))]
+
+
+def mod_path(mod):
"""
- Return the bytes of the resource file at path, or None.
- If builtin is True, do not look for it on the filesystem.
- If builtin is False, do not look in the builtin resources.
- """
- if builtin is not True:
- arcpath = resfs_src(path, resfs_file=True)
- if arcpath:
- fspath = resfs_resolve(arcpath)
- if fspath:
- return file_bytes(fspath)
-
- if builtin is not False:
- return __resource.find(b'resfs/file/' + _b(path))
-
-
-def resfs_files(prefix=b''):
- """
- List builtin resource file paths.
- """
- return [key[11:] for key, _ in iter_keys(b'resfs/file/' + _b(prefix))]
-
-
-def mod_path(mod):
- """
- Return the resfs path to the source code of the module with the given name.
+ Return the resfs path to the source code of the module with the given name.
"""
- return py_prefix + _b(mod).replace(b'.', b'/') + b'.py'
-
+ return py_prefix + _b(mod).replace(b'.', b'/') + b'.py'
+
class ResourceImporter(object):
- """ A meta_path importer that loads code from built-in resources.
+ """ A meta_path importer that loads code from built-in resources.
"""
def __init__(self):
- self.memory = set(iter_py_modules()) # Set of importable module names.
- self.source_map = {} # Map from file names to module names.
- self._source_name = {} # Map from original to altered module names.
+ self.memory = set(iter_py_modules()) # Set of importable module names.
+ self.source_map = {} # Map from file names to module names.
+ self._source_name = {} # Map from original to altered module names.
self._package_prefix = ''
if Y_PYTHON_SOURCE_ROOT and Y_PYTHON_EXTENDED_SOURCE_SEARCH:
self.arcadia_source_finder = ArcadiaSourceFinder(_s(Y_PYTHON_SOURCE_ROOT))
@@ -205,11 +205,11 @@ class ResourceImporter(object):
return relpath
return self.arcadia_source_finder.get_module_path(fullname)
- def find_spec(self, fullname, path=None, target=None):
- try:
+ def find_spec(self, fullname, path=None, target=None):
+ try:
is_package = self.is_package(fullname)
- except ImportError:
- return None
+ except ImportError:
+ return None
return spec_from_loader(fullname, self, is_package=is_package)
def find_module(self, fullname, path=None):
@@ -224,103 +224,103 @@ class ResourceImporter(object):
code = self.get_code(module.__name__)
module.__file__ = code.co_filename
if self.is_package(module.__name__):
- module.__path__= [executable + path_sep + module.__name__.replace('.', path_sep)]
- # exec(code, module.__dict__)
+ module.__path__= [executable + path_sep + module.__name__.replace('.', path_sep)]
+ # exec(code, module.__dict__)
_call_with_frames_removed(exec, code, module.__dict__)
- # PEP-302 extension 1 of 3: data loader.
- def get_data(self, path):
- path = _b(path)
- abspath = resfs_resolve(path)
- if abspath:
- return file_bytes(abspath)
+ # PEP-302 extension 1 of 3: data loader.
+ def get_data(self, path):
+ path = _b(path)
+ abspath = resfs_resolve(path)
+ if abspath:
+ return file_bytes(abspath)
path = path.replace(_b('\\'), _b('/'))
- data = resfs_read(path, builtin=True)
- if data is None:
- raise IOError(path) # Y_PYTHON_ENTRY_POINT=:resource_files
- return data
-
- # PEP-302 extension 2 of 3: get __file__ without importing.
- def get_filename(self, fullname):
- modname = fullname
- if self.is_package(fullname):
- fullname += '.__init__'
+ data = resfs_read(path, builtin=True)
+ if data is None:
+ raise IOError(path) # Y_PYTHON_ENTRY_POINT=:resource_files
+ return data
+
+ # PEP-302 extension 2 of 3: get __file__ without importing.
+ def get_filename(self, fullname):
+ modname = fullname
+ if self.is_package(fullname):
+ fullname += '.__init__'
relpath = self._find_mod_path(fullname)
- if isinstance(relpath, bytes):
- relpath = _s(relpath)
+ if isinstance(relpath, bytes):
+ relpath = _s(relpath)
return relpath or modname
- # PEP-302 extension 3 of 3: packaging introspection.
- # Used by `linecache` (while printing tracebacks) unless module filename
- # exists on the filesystem.
- def get_source(self, fullname):
+ # PEP-302 extension 3 of 3: packaging introspection.
+ # Used by `linecache` (while printing tracebacks) unless module filename
+ # exists on the filesystem.
+ def get_source(self, fullname):
fullname = self._source_name.get(fullname) or fullname
if self.is_package(fullname):
fullname += '.__init__'
relpath = self.get_filename(fullname)
- if relpath:
- abspath = resfs_resolve(relpath)
- if abspath:
- return _s(file_bytes(abspath))
+ if relpath:
+ abspath = resfs_resolve(relpath)
+ if abspath:
+ return _s(file_bytes(abspath))
data = resfs_read(mod_path(fullname))
- return _s(data) if data else ''
-
- def get_code(self, fullname):
- modname = fullname
- if self.is_package(fullname):
- fullname += '.__init__'
-
- path = mod_path(fullname)
+ return _s(data) if data else ''
+
+ def get_code(self, fullname):
+ modname = fullname
+ if self.is_package(fullname):
+ fullname += '.__init__'
+
+ path = mod_path(fullname)
relpath = self._find_mod_path(fullname)
- if relpath:
- abspath = resfs_resolve(relpath)
- if abspath:
- data = file_bytes(abspath)
- return compile(data, _s(abspath), 'exec', dont_inherit=True)
-
+ if relpath:
+ abspath = resfs_resolve(relpath)
+ if abspath:
+ data = file_bytes(abspath)
+ return compile(data, _s(abspath), 'exec', dont_inherit=True)
+
yapyc_path = path + b'.yapyc3'
yapyc_data = resfs_read(yapyc_path, builtin=True)
if yapyc_data:
return marshal.loads(yapyc_data)
else:
py_data = resfs_read(path, builtin=True)
- if py_data:
- return compile(py_data, _s(relpath), 'exec', dont_inherit=True)
- else:
- # This covers packages with no __init__.py in resources.
- return compile('', modname, 'exec', dont_inherit=True)
+ if py_data:
+ return compile(py_data, _s(relpath), 'exec', dont_inherit=True)
+ else:
+ # This covers packages with no __init__.py in resources.
+ return compile('', modname, 'exec', dont_inherit=True)
def is_package(self, fullname):
if fullname in self.memory:
return False
-
- if fullname + '.__init__' in self.memory:
+
+ if fullname + '.__init__' in self.memory:
return True
if self.arcadia_source_finder:
return self.arcadia_source_finder.is_package(fullname)
- raise ImportError(fullname)
-
- # Extension for contrib/python/coverage.
- def file_source(self, filename):
- """
- Return the key of the module source by its resource path.
- """
- if not self.source_map:
- for key, mod in iter_py_modules(with_keys=True):
- path = self.get_filename(mod)
- self.source_map[path] = key
-
- if filename in self.source_map:
- return self.source_map[filename]
-
- if resfs_read(filename, builtin=True) is not None:
- return b'resfs/file/' + _b(filename)
-
- return b''
-
+ raise ImportError(fullname)
+
+ # Extension for contrib/python/coverage.
+ def file_source(self, filename):
+ """
+ Return the key of the module source by its resource path.
+ """
+ if not self.source_map:
+ for key, mod in iter_py_modules(with_keys=True):
+ path = self.get_filename(mod)
+ self.source_map[path] = key
+
+ if filename in self.source_map:
+ return self.source_map[filename]
+
+ if resfs_read(filename, builtin=True) is not None:
+ return b'resfs/file/' + _b(filename)
+
+ return b''
+
# Extension for pkgutil.iter_modules.
def iter_modules(self, prefix=''):
import re
@@ -531,19 +531,19 @@ def excepthook(*args, **kws):
return traceback.print_exception(*args, **kws)
-importer = ResourceImporter()
-
-
-def executable_path_hook(path):
- if path == executable:
- return importer
-
- if path.startswith(executable + path_sep):
- return importer.for_package(path[len(executable + path_sep):].replace(path_sep, '.'))
-
- raise ImportError(path)
+importer = ResourceImporter()
+
+def executable_path_hook(path):
+ if path == executable:
+ return importer
+
+ if path.startswith(executable + path_sep):
+ return importer.for_package(path[len(executable + path_sep):].replace(path_sep, '.'))
+ raise ImportError(path)
+
+
if YA_IDE_VENV:
sys.meta_path.append(importer)
sys.meta_path.append(BuiltinSubmoduleImporter)
@@ -557,13 +557,13 @@ else:
sys.path.insert(0, executable)
sys.path_hooks.insert(0, executable_path_hook)
-sys.path_importer_cache[executable] = importer
-
-# Indicator that modules and resources are built-in rather than on the file system.
-sys.is_standalone_binary = True
-sys.frozen = True
+sys.path_importer_cache[executable] = importer
+
+# Indicator that modules and resources are built-in rather than on the file system.
+sys.is_standalone_binary = True
+sys.frozen = True
-# Set of names of importable modules.
+# Set of names of importable modules.
sys.extra_modules = importer.memory
# Use custom implementation of traceback printer.
diff --git a/library/python/runtime_py3/main/main.c b/library/python/runtime_py3/main/main.c
index 3159800615..55afdca5f3 100644
--- a/library/python/runtime_py3/main/main.c
+++ b/library/python/runtime_py3/main/main.c
@@ -1,29 +1,29 @@
-#include <Python.h>
+#include <Python.h>
#include <contrib/tools/python3/src/Include/internal/pycore_runtime.h> // _PyRuntime_Initialize()
-
-#include <stdlib.h>
-#include <string.h>
+
+#include <stdlib.h>
+#include <string.h>
#include <locale.h>
-
-void Py_InitArgcArgv(int argc, wchar_t **argv);
+
+void Py_InitArgcArgv(int argc, wchar_t **argv);
char* GetPyMain();
-
-static const char* env_entry_point = "Y_PYTHON_ENTRY_POINT";
+
+static const char* env_entry_point = "Y_PYTHON_ENTRY_POINT";
static const char* env_bytes_warning = "Y_PYTHON_BYTES_WARNING";
-
-#ifdef _MSC_VER
-extern char** environ;
-
-void unsetenv(const char* name) {
- const int n = strlen(name);
+
+#ifdef _MSC_VER
+extern char** environ;
+
+void unsetenv(const char* name) {
+ const int n = strlen(name);
char** dst = environ;
for (char** src = environ; *src; src++)
- if (strncmp(*src, name, n) || (*src)[n] != '=')
- *dst++ = *src;
- *dst = NULL;
-}
-#endif
-
+ if (strncmp(*src, name, n) || (*src)[n] != '=')
+ *dst++ = *src;
+ *dst = NULL;
+}
+#endif
+
static int RunModule(const char *modname)
{
PyObject *module, *runpy, *runmodule, *runargs, *result;
@@ -73,7 +73,7 @@ static int RunModule(const char *modname)
return 0;
}
-static int pymain(int argc, char** argv) {
+static int pymain(int argc, char** argv) {
PyStatus status = _PyRuntime_Initialize();
if (PyStatus_Exception(status)) {
Py_ExitStatusException(status);
@@ -134,7 +134,7 @@ static int pymain(int argc, char** argv) {
Py_ExitStatusException(status);
}
- const char* entry_point = getenv(env_entry_point);
+ const char* entry_point = getenv(env_entry_point);
if (entry_point) {
entry_point_copy = strdup(entry_point);
if (!entry_point_copy) {
@@ -151,13 +151,13 @@ static int pymain(int argc, char** argv) {
}
if (entry_point_copy && !strcmp(entry_point_copy, ":main")) {
- unsetenv(env_entry_point);
+ unsetenv(env_entry_point);
sts = Py_Main(argc, argv_copy);
free(entry_point_copy);
return sts;
- }
+ }
- Py_InitArgcArgv(argc, argv_copy);
+ Py_InitArgcArgv(argc, argv_copy);
PySys_SetArgv(argc, argv_copy);
{
@@ -222,10 +222,10 @@ error:
}
PyMem_RawFree(oldloc);
return sts;
-}
-
-int (*mainptr)(int argc, char** argv) = pymain;
-
-int main(int argc, char** argv) {
- return mainptr(argc, argv);
-}
+}
+
+int (*mainptr)(int argc, char** argv) = pymain;
+
+int main(int argc, char** argv) {
+ return mainptr(argc, argv);
+}
diff --git a/library/python/runtime_py3/main/ya.make b/library/python/runtime_py3/main/ya.make
index f308a93b28..3ffe3e0eab 100644
--- a/library/python/runtime_py3/main/ya.make
+++ b/library/python/runtime_py3/main/ya.make
@@ -6,21 +6,21 @@ OWNER(
)
PEERDIR(
- contrib/tools/python3/src
+ contrib/tools/python3/src
library/cpp/resource
)
-ADDINCL(
- contrib/tools/python3/src/Include
-)
+ADDINCL(
+ contrib/tools/python3/src/Include
+)
CFLAGS(
-DPy_BUILD_CORE
)
-SRCS(
- main.c
+SRCS(
+ main.c
get_py_main.cpp
-)
+)
END()
diff --git a/library/python/runtime_py3/sitecustomize.pyx b/library/python/runtime_py3/sitecustomize.pyx
index 966bbe8ba6..625ccffb79 100644
--- a/library/python/runtime_py3/sitecustomize.pyx
+++ b/library/python/runtime_py3/sitecustomize.pyx
@@ -2,7 +2,7 @@ import re
import sys
import __res
-
+
from importlib.abc import ResourceReader
from importlib.metadata import Distribution, DistributionFinder, PackageNotFoundError, Prepared
diff --git a/library/python/runtime_py3/ya.make b/library/python/runtime_py3/ya.make
index fa5c11341a..37e04ffd5f 100644
--- a/library/python/runtime_py3/ya.make
+++ b/library/python/runtime_py3/ya.make
@@ -9,19 +9,19 @@ OWNER(
NO_WSHADOW()
PEERDIR(
- contrib/tools/python3/src
- contrib/tools/python3/lib/py
+ contrib/tools/python3/src
+ contrib/tools/python3/lib/py
library/cpp/resource
)
CFLAGS(-DCYTHON_REGISTER_ABCS=0)
-
-NO_PYTHON_INCLUDES()
-
-ENABLE(PYBUILD_NO_PYC)
-
+
+NO_PYTHON_INCLUDES()
+
+ENABLE(PYBUILD_NO_PYC)
+
PY_SRCS(
- entry_points.py
+ entry_points.py
TOP_LEVEL
CYTHON_DIRECTIVE
@@ -29,7 +29,7 @@ PY_SRCS(
__res.pyx
sitecustomize.pyx
-)
+)
IF (CYTHON_COVERAGE)
# Let covarage support add all needed files to resources
@@ -41,7 +41,7 @@ ELSE()
sitecustomize.pyx
)
ENDIF()
-
+
END()
RECURSE_FOR_TESTS(
diff --git a/library/python/symbols/libc/syms.cpp b/library/python/symbols/libc/syms.cpp
index 6c04a7ef6e..0d57b00b99 100644
--- a/library/python/symbols/libc/syms.cpp
+++ b/library/python/symbols/libc/syms.cpp
@@ -1,38 +1,38 @@
#include <util/system/platform.h>
-
+
#include <library/python/symbols/registry/syms.h>
#if !defined(_MSC_VER)
-#if __has_include(<aio.h>)
-#include <aio.h>
-#endif
-#include <arpa/inet.h>
-#include <dirent.h>
-#include <ifaddrs.h>
-#include <netdb.h>
-#include <pthread.h>
-#include <pwd.h>
-#include <sched.h>
-#include <semaphore.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
+#if __has_include(<aio.h>)
+#include <aio.h>
+#endif
+#include <arpa/inet.h>
+#include <dirent.h>
+#include <ifaddrs.h>
+#include <netdb.h>
+#include <pthread.h>
+#include <pwd.h>
+#include <sched.h>
+#include <semaphore.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
#include <errno.h>
#include <sys/ipc.h>
#include <dlfcn.h>
#if defined(_linux_)
#include <sys/prctl.h>
-#include <sys/ptrace.h>
+#include <sys/ptrace.h>
#include <sys/sendfile.h>
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
#endif
-
+
#if defined(_darwin_)
#include <sys/types.h>
#include <sys/sysctl.h>
@@ -97,61 +97,61 @@ namespace {
}
BEGIN_SYMS("c")
-
-SYM(calloc)
-SYM(clock_gettime)
+
+SYM(calloc)
+SYM(clock_gettime)
SYM_2("clock_getres", ClockGetres)
-SYM(closedir)
+SYM(closedir)
SYM(fdopen)
SYM(fflush)
-SYM(freeifaddrs)
-SYM(ftok)
-SYM(getifaddrs)
-SYM(getnameinfo)
-SYM(getpwnam)
-SYM(inet_ntop)
-SYM(opendir)
-SYM(printf)
-SYM(pthread_kill)
-SYM(pthread_self)
-SYM(readdir_r)
-SYM(sem_close)
-SYM(sem_getvalue)
-SYM(sem_open)
-SYM(sem_post)
-SYM(sem_trywait)
-SYM(sem_unlink)
-SYM(sem_wait)
-SYM(siginterrupt)
-SYM(strdup)
+SYM(freeifaddrs)
+SYM(ftok)
+SYM(getifaddrs)
+SYM(getnameinfo)
+SYM(getpwnam)
+SYM(inet_ntop)
+SYM(opendir)
+SYM(printf)
+SYM(pthread_kill)
+SYM(pthread_self)
+SYM(readdir_r)
+SYM(sem_close)
+SYM(sem_getvalue)
+SYM(sem_open)
+SYM(sem_post)
+SYM(sem_trywait)
+SYM(sem_unlink)
+SYM(sem_wait)
+SYM(siginterrupt)
+SYM(strdup)
SYM(sendfile)
SYM(strtod)
SYM_2("__errno_location", ErrnoLocation)
-
-#if defined(_linux_)
-SYM(prctl)
-SYM(ptrace)
-SYM(sched_getaffinity)
-SYM(sched_setaffinity)
-SYM(sem_timedwait)
-SYM(inotify_init)
-SYM(inotify_add_watch)
-SYM(inotify_rm_watch)
+
+#if defined(_linux_)
+SYM(prctl)
+SYM(ptrace)
+SYM(sched_getaffinity)
+SYM(sched_setaffinity)
+SYM(sem_timedwait)
+SYM(inotify_init)
+SYM(inotify_add_watch)
+SYM(inotify_rm_watch)
SYM(mlockall)
-#endif
-
-#if defined(_darwin_)
-SYM(mach_absolute_time)
-SYM(mach_timebase_info)
-SYM(sysctlbyname)
-#endif
-
-#if __has_include(<aio.h>)
-SYM(aio_error)
-SYM(aio_read)
-SYM(aio_return)
-SYM(aio_suspend)
-#endif
-
-END_SYMS()
+#endif
+
+#if defined(_darwin_)
+SYM(mach_absolute_time)
+SYM(mach_timebase_info)
+SYM(sysctlbyname)
+#endif
+
+#if __has_include(<aio.h>)
+SYM(aio_error)
+SYM(aio_read)
+SYM(aio_return)
+SYM(aio_suspend)
+#endif
+
+END_SYMS()
#endif
diff --git a/library/python/symbols/libc/ya.make b/library/python/symbols/libc/ya.make
index 7b84cbc961..d8ab0acb63 100644
--- a/library/python/symbols/libc/ya.make
+++ b/library/python/symbols/libc/ya.make
@@ -1,19 +1,19 @@
LIBRARY()
-
+
OWNER(pg orivej)
-
-PEERDIR(
+
+PEERDIR(
library/python/symbols/registry
-)
-
+)
+
IF (GCC OR CLANG)
- CFLAGS(
- -Wno-deprecated-declarations # For sem_getvalue.
- )
-ENDIF()
-
-SRCS(
+ CFLAGS(
+ -Wno-deprecated-declarations # For sem_getvalue.
+ )
+ENDIF()
+
+SRCS(
GLOBAL syms.cpp
-)
-
-END()
+)
+
+END()
diff --git a/library/python/symbols/module/module.cpp b/library/python/symbols/module/module.cpp
index 92bc7f4d67..d3d511b779 100644
--- a/library/python/symbols/module/module.cpp
+++ b/library/python/symbols/module/module.cpp
@@ -1,9 +1,9 @@
-#include <Python.h>
-
+#include <Python.h>
+
#include <library/python/symbols/registry/syms.h>
-#include <util/generic/string.h>
-
+#include <util/generic/string.h>
+
#define CAP(x) SYM_2(x, x)
BEGIN_SYMS("_capability")
@@ -44,42 +44,42 @@ namespace {
}
}
-static void DictSetStringPtr(PyObject* dict, const char* name, void* value) {
- PyObject* p = PyLong_FromVoidPtr(value);
- PyDict_SetItemString(dict, name, p);
- Py_DECREF(p);
-}
-
-static PyObject* InitSyms(PyObject* m) {
- if (!m)
- return NULL;
- PyObject* d = PyDict_New();
- if (!d)
- return NULL;
-
- auto f = [&](const char* mod, const char* name, void* sym) {
- DictSetStringPtr(d, (TString(mod) + "|" + TString(name)).c_str(), sym);
- };
-
- auto cb = MakeTCB(f);
-
- ForEachSymbol(cb);
-
- if (PyObject_SetAttrString(m, "syms", d))
- m = NULL;
- Py_DECREF(d);
- return m;
-}
-
-#if PY_MAJOR_VERSION >= 3
-static struct PyModuleDef module = {
- PyModuleDef_HEAD_INIT, "syms", NULL, -1, NULL, NULL, NULL, NULL, NULL};
-
-extern "C" PyObject* PyInit_syms() {
- return InitSyms(PyModule_Create(&module));
-}
-#else
-extern "C" void initsyms() {
- InitSyms(Py_InitModule("syms", NULL));
+static void DictSetStringPtr(PyObject* dict, const char* name, void* value) {
+ PyObject* p = PyLong_FromVoidPtr(value);
+ PyDict_SetItemString(dict, name, p);
+ Py_DECREF(p);
+}
+
+static PyObject* InitSyms(PyObject* m) {
+ if (!m)
+ return NULL;
+ PyObject* d = PyDict_New();
+ if (!d)
+ return NULL;
+
+ auto f = [&](const char* mod, const char* name, void* sym) {
+ DictSetStringPtr(d, (TString(mod) + "|" + TString(name)).c_str(), sym);
+ };
+
+ auto cb = MakeTCB(f);
+
+ ForEachSymbol(cb);
+
+ if (PyObject_SetAttrString(m, "syms", d))
+ m = NULL;
+ Py_DECREF(d);
+ return m;
}
-#endif
+
+#if PY_MAJOR_VERSION >= 3
+static struct PyModuleDef module = {
+ PyModuleDef_HEAD_INIT, "syms", NULL, -1, NULL, NULL, NULL, NULL, NULL};
+
+extern "C" PyObject* PyInit_syms() {
+ return InitSyms(PyModule_Create(&module));
+}
+#else
+extern "C" void initsyms() {
+ InitSyms(Py_InitModule("syms", NULL));
+}
+#endif
diff --git a/library/python/symbols/module/ya.make b/library/python/symbols/module/ya.make
index 78e30f2547..f84d3c268e 100644
--- a/library/python/symbols/module/ya.make
+++ b/library/python/symbols/module/ya.make
@@ -1,11 +1,11 @@
-PY23_LIBRARY()
+PY23_LIBRARY()
OWNER(pg orivej)
-NO_PYTHON_INCLUDES()
-
+NO_PYTHON_INCLUDES()
+
PEERDIR(
- contrib/libs/python/Include
+ contrib/libs/python/Include
)
SRCS(
@@ -13,7 +13,7 @@ SRCS(
)
PY_REGISTER(
- library.python.symbols.module.syms
+ library.python.symbols.module.syms
)
PY_SRCS(
diff --git a/library/python/symbols/python/syms.cpp b/library/python/symbols/python/syms.cpp
index 9b52574cb1..46fbd25dc2 100644
--- a/library/python/symbols/python/syms.cpp
+++ b/library/python/symbols/python/syms.cpp
@@ -1,17 +1,17 @@
-#define SYM(SYM_NAME) extern "C" void SYM_NAME();
-SYM(PyObject_GetBuffer)
-SYM(PyBuffer_Release)
+#define SYM(SYM_NAME) extern "C" void SYM_NAME();
+SYM(PyObject_GetBuffer)
+SYM(PyBuffer_Release)
+SYM(PyCell_New)
+SYM(Py_DecRef)
+SYM(Py_IncRef)
+#undef SYM
+
+#include <library/python/symbols/registry/syms.h>
+
+BEGIN_SYMS("python")
+SYM(PyObject_GetBuffer)
+SYM(PyBuffer_Release)
SYM(PyCell_New)
-SYM(Py_DecRef)
-SYM(Py_IncRef)
-#undef SYM
-
-#include <library/python/symbols/registry/syms.h>
-
-BEGIN_SYMS("python")
-SYM(PyObject_GetBuffer)
-SYM(PyBuffer_Release)
-SYM(PyCell_New)
-SYM(Py_DecRef)
-SYM(Py_IncRef)
-END_SYMS()
+SYM(Py_DecRef)
+SYM(Py_IncRef)
+END_SYMS()
diff --git a/library/python/symbols/python/ut/py2/ya.make b/library/python/symbols/python/ut/py2/ya.make
index 214194de57..110c9f7c75 100644
--- a/library/python/symbols/python/ut/py2/ya.make
+++ b/library/python/symbols/python/ut/py2/ya.make
@@ -1,9 +1,9 @@
PY2TEST()
-
-OWNER(orivej)
-
-PEERDIR(
- library/python/symbols/python/ut
-)
-
-END()
+
+OWNER(orivej)
+
+PEERDIR(
+ library/python/symbols/python/ut
+)
+
+END()
diff --git a/library/python/symbols/python/ut/py3/ya.make b/library/python/symbols/python/ut/py3/ya.make
index 76611c6a19..a5e2a0d844 100644
--- a/library/python/symbols/python/ut/py3/ya.make
+++ b/library/python/symbols/python/ut/py3/ya.make
@@ -1,9 +1,9 @@
-PY3TEST()
-
-OWNER(orivej)
-
-PEERDIR(
- library/python/symbols/python/ut
-)
-
-END()
+PY3TEST()
+
+OWNER(orivej)
+
+PEERDIR(
+ library/python/symbols/python/ut
+)
+
+END()
diff --git a/library/python/symbols/python/ut/test_ctypes.py b/library/python/symbols/python/ut/test_ctypes.py
index 253a10d8b3..ff0d37ef1a 100644
--- a/library/python/symbols/python/ut/test_ctypes.py
+++ b/library/python/symbols/python/ut/test_ctypes.py
@@ -34,4 +34,4 @@ def get_buffer(obj):
def test_buffer():
- assert get_buffer(b'test string')
+ assert get_buffer(b'test string')
diff --git a/library/python/symbols/python/ut/ya.make b/library/python/symbols/python/ut/ya.make
index 2849e01b1e..019017f945 100644
--- a/library/python/symbols/python/ut/ya.make
+++ b/library/python/symbols/python/ut/ya.make
@@ -1,16 +1,16 @@
-PY23_LIBRARY()
+PY23_LIBRARY()
OWNER(orivej)
TEST_SRCS(test_ctypes.py)
PEERDIR(
- library/python/symbols/python
+ library/python/symbols/python
)
END()
-RECURSE_FOR_TESTS(
- py2
- py3
-)
+RECURSE_FOR_TESTS(
+ py2
+ py3
+)
diff --git a/library/python/symbols/python/ya.make b/library/python/symbols/python/ya.make
index 6bfd54f8bc..5a1922861c 100644
--- a/library/python/symbols/python/ya.make
+++ b/library/python/symbols/python/ya.make
@@ -1,15 +1,15 @@
-LIBRARY()
-
-OWNER(orivej)
-
-PEERDIR(
- library/python/symbols/registry
-)
-
-SRCS(
- GLOBAL syms.cpp
-)
-
-END()
+LIBRARY()
+
+OWNER(orivej)
+
+PEERDIR(
+ library/python/symbols/registry
+)
+
+SRCS(
+ GLOBAL syms.cpp
+)
+
+END()
RECURSE_FOR_TESTS(ut)
diff --git a/library/python/symbols/ya.make b/library/python/symbols/ya.make
index 340a710c48..4729699d3b 100644
--- a/library/python/symbols/ya.make
+++ b/library/python/symbols/ya.make
@@ -1,12 +1,12 @@
RECURSE(
module
registry
- tests
-
- crypto
+ tests
+
+ crypto
libc
libmagic
- python
+ python
uuid
win_unicode_console
)
diff --git a/library/python/testing/import_test/import_test.py b/library/python/testing/import_test/import_test.py
index 3e3b7234ef..720a972ea3 100644
--- a/library/python/testing/import_test/import_test.py
+++ b/library/python/testing/import_test/import_test.py
@@ -1,15 +1,15 @@
from __future__ import print_function
-import os
-import re
+import os
+import re
import sys
import time
import traceback
-import __res
-from __res import importer
-
+import __res
+from __res import importer
+
def check_imports(no_check=(), extra=(), skip_func=None, py_main=None):
"""
tests all bundled modules are importable
@@ -17,24 +17,24 @@ def check_imports(no_check=(), extra=(), skip_func=None, py_main=None):
"PEERDIR(library/python/import_test)" to your CMakeLists.txt and
"from import_test import test_imports" to your python test source file.
"""
- str_ = lambda s: s
- if not isinstance(b'', str):
- str_ = lambda s: s.decode('UTF-8')
-
- exceptions = list(no_check)
- for key, _ in __res.iter_keys(b'py/no_check_imports/'):
- exceptions += str_(__res.find(key)).split()
- if exceptions:
- exceptions.sort()
- print('NO_CHECK_IMPORTS', ' '.join(exceptions))
-
- patterns = [re.escape(s).replace(r'\*', r'.*') for s in exceptions]
- rx = re.compile('^({})$'.format('|'.join(patterns)))
-
- failed = []
+ str_ = lambda s: s
+ if not isinstance(b'', str):
+ str_ = lambda s: s.decode('UTF-8')
+
+ exceptions = list(no_check)
+ for key, _ in __res.iter_keys(b'py/no_check_imports/'):
+ exceptions += str_(__res.find(key)).split()
+ if exceptions:
+ exceptions.sort()
+ print('NO_CHECK_IMPORTS', ' '.join(exceptions))
+
+ patterns = [re.escape(s).replace(r'\*', r'.*') for s in exceptions]
+ rx = re.compile('^({})$'.format('|'.join(patterns)))
+
+ failed = []
import_times = {}
- norm = lambda s: s[:-9] if s.endswith('.__init__') else s
+ norm = lambda s: s[:-9] if s.endswith('.__init__') else s
modules = sys.extra_modules | set(extra)
modules = sorted(modules, key=norm)
@@ -42,15 +42,15 @@ def check_imports(no_check=(), extra=(), skip_func=None, py_main=None):
modules = [py_main] + modules
for module in modules:
- if module not in extra and (rx.search(module) or skip_func and skip_func(module)):
- print('SKIP', module)
- continue
-
- name = module.rsplit('.', 1)[-1]
- if name == '__main__' and 'if __name__ ==' not in importer.get_source(module):
- print('SKIP', module, '''without "if __name__ == '__main__'" check''')
+ if module not in extra and (rx.search(module) or skip_func and skip_func(module)):
+ print('SKIP', module)
continue
+ name = module.rsplit('.', 1)[-1]
+ if name == '__main__' and 'if __name__ ==' not in importer.get_source(module):
+ print('SKIP', module, '''without "if __name__ == '__main__'" check''')
+ continue
+
def print_backtrace_marked(e):
tb_exc = traceback.format_exception(*e)
for item in tb_exc:
@@ -58,18 +58,18 @@ def check_imports(no_check=(), extra=(), skip_func=None, py_main=None):
print('FAIL:', l, file=sys.stderr)
try:
- print('TRY', module)
+ print('TRY', module)
# XXX waiting for py3 to use print(..., flush=True)
sys.stdout.flush()
s = time.time()
- if module == '__main__':
- importer.load_module('__main__', '__main__py')
+ if module == '__main__':
+ importer.load_module('__main__', '__main__py')
elif module.endswith('.__init__'):
__import__(module[:-len('.__init__')])
- else:
- __import__(module)
-
+ else:
+ __import__(module)
+
delay = time.time() - s
import_times[str(module)] = delay
print('OK ', module, '{:.3f}s'.format(delay))
@@ -77,8 +77,8 @@ def check_imports(no_check=(), extra=(), skip_func=None, py_main=None):
except Exception as e:
print('FAIL:', module, e, file=sys.stderr)
print_backtrace_marked(sys.exc_info())
- failed.append('{}: {}'.format(module, e))
-
+ failed.append('{}: {}'.format(module, e))
+
except:
e = sys.exc_info()
print('FAIL:', module, e, file=sys.stderr)
@@ -91,25 +91,25 @@ def check_imports(no_check=(), extra=(), skip_func=None, py_main=None):
print(' ', '{:.3f}s'.format(t), m)
if failed:
- raise ImportError('modules not imported:\n' + '\n'.join(failed))
-
+ raise ImportError('modules not imported:\n' + '\n'.join(failed))
-test_imports = check_imports
-
-def main():
- skip_names = sys.argv[1:]
-
- os.environ['Y_PYTHON_IMPORT_TEST'] = ''
+test_imports = check_imports
+
+
+def main():
+ skip_names = sys.argv[1:]
+
+ os.environ['Y_PYTHON_IMPORT_TEST'] = ''
# We should initialize Django before importing any applications
if os.getenv('DJANGO_SETTINGS_MODULE'):
- try:
- import django
- except ImportError:
- pass
- else:
- django.setup()
+ try:
+ import django
+ except ImportError:
+ pass
+ else:
+ django.setup()
py_main = __res.find('PY_MAIN')
@@ -118,7 +118,7 @@ def main():
else:
py_main_module = None
- try:
+ try:
check_imports(no_check=skip_names, py_main=py_main_module)
- except:
- sys.exit(1)
+ except:
+ sys.exit(1)
diff --git a/library/python/testing/yatest_common/yatest/common/process.py b/library/python/testing/yatest_common/yatest/common/process.py
index a8bcc21f51..54a899c2ba 100644
--- a/library/python/testing/yatest_common/yatest/common/process.py
+++ b/library/python/testing/yatest_common/yatest/common/process.py
@@ -475,7 +475,7 @@ def execute(
if isinstance(stream, six.string_types):
# User filename is supplied: open file for writing
- return open(stream, 'wb+'), stream.startswith('/dev/')
+ return open(stream, 'wb+'), stream.startswith('/dev/')
# Open file or PIPE sentinel is supplied
is_pipe = stream == subprocess.PIPE
@@ -626,7 +626,7 @@ def wait_for(check_function, timeout, fail_message="", sleep_time=1.0, on_check_
raise TimeoutError(truncate(message, MAX_MESSAGE_LEN))
-def _kill_process_tree(process_pid, target_pid_signal=None):
+def _kill_process_tree(process_pid, target_pid_signal=None):
"""
Kills child processes, req. Note that psutil should be installed
@param process_pid: parent id to search for descendants
@@ -653,7 +653,7 @@ def _get_binname(pid):
return "error({})".format(e)
-def _nix_kill_process_tree(pid, target_pid_signal=None):
+def _nix_kill_process_tree(pid, target_pid_signal=None):
"""
Kills the process tree.
"""
@@ -680,7 +680,7 @@ def _nix_kill_process_tree(pid, target_pid_signal=None):
yatest_logger.debug("Killing child pid {pid} failed: {error}".format(pid=child_pid, error=e))
continue
- try_to_send_signal(pid, target_pid_signal or signal.SIGKILL) # Kill the root process.
+ try_to_send_signal(pid, target_pid_signal or signal.SIGKILL) # Kill the root process.
# sometimes on freebsd sigkill cannot kill the process and either sigkill or sigcont should be sent
# https://www.mail-archive.com/freebsd-hackers@freebsd.org/msg159646.html
diff --git a/library/python/ya.make b/library/python/ya.make
index 2e1eb6e0e1..72cc24a9fe 100644
--- a/library/python/ya.make
+++ b/library/python/ya.make
@@ -13,7 +13,7 @@ RECURSE(
awssdk-extensions
awssdk_async_extensions
base64
- base64/test
+ base64/test
bclclient
blackbox
blackbox/tests
@@ -25,13 +25,13 @@ RECURSE(
build_info/ut
capabilities
celery_dashboard
- certifi
+ certifi
cgroups
charset
charts_notes
charts_notes/example
- cityhash
- cityhash/test
+ cityhash
+ cityhash/test
clickhouse_client
cmain
codecs
@@ -44,7 +44,7 @@ RECURSE(
cores
coverage
cpp_test
- cppdemangle
+ cppdemangle
cqueue
crowd-kit
cyson
@@ -62,7 +62,7 @@ RECURSE(
django_alive
django_celery_monitoring
django_russian
- django_template_common
+ django_template_common
django_tools_log_context
dssclient
dump_dict
@@ -132,7 +132,7 @@ RECURSE(
oauth
oauth/example
ok_client
- openssl
+ openssl
par_apply
par_apply/test
path
@@ -157,15 +157,15 @@ RECURSE(
retry
retry/tests
runtime
- runtime/main
+ runtime/main
runtime/test
- runtime_py3
- runtime_py3/main
+ runtime_py3
+ runtime_py3/main
runtime_py3/test
runtime_test
sanitizers
sdms_api
- sfx
+ sfx
selenium_ui_test
sendmsg
stubmaker
@@ -183,7 +183,7 @@ RECURSE(
svn_ssh
svn_version
svn_version/ut
- symbols
+ symbols
testing
tmp
toloka_client
@@ -215,8 +215,8 @@ RECURSE(
zipatch
)
-IF (NOT MUSL)
- RECURSE(
+IF (NOT MUSL)
+ RECURSE(
yt/example
)
ENDIF()