diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
commit | 2d37894b1b037cf24231090eda8589bbb44fb6fc (patch) | |
tree | be835aa92c6248212e705f25388ebafcf84bc7a1 /library | |
parent | 718c552901d703c502ccbefdfc3c9028d608b947 (diff) | |
download | ydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library')
64 files changed, 829 insertions, 829 deletions
diff --git a/library/cpp/actors/util/recentwnd.h b/library/cpp/actors/util/recentwnd.h index fe52a3bfe6..ba1ede6f29 100644 --- a/library/cpp/actors/util/recentwnd.h +++ b/library/cpp/actors/util/recentwnd.h @@ -63,5 +63,5 @@ public: private: TContainer<TElem> Window_; - ui32 MaxWndSize_; + ui32 MaxWndSize_; }; diff --git a/library/cpp/balloc/balloc.cpp b/library/cpp/balloc/balloc.cpp index c5766a19f8..fab489db4c 100644 --- a/library/cpp/balloc/balloc.cpp +++ b/library/cpp/balloc/balloc.cpp @@ -296,10 +296,10 @@ extern "C" void* memalign(size_t alignment, size_t size) { return res ? nullptr : ptr; } -extern "C" void* valloc(size_t size) { - return memalign(NBalloc::PAGE_ELEM, size); -} - +extern "C" void* valloc(size_t size) { + return memalign(NBalloc::PAGE_ELEM, size); +} + #if !defined(_MSC_VER) && !defined(_freebsd_) // Workaround for pthread_create bug in linux. extern "C" void* __libc_memalign(size_t alignment, size_t size) { diff --git a/library/cpp/charset/iconv.cpp b/library/cpp/charset/iconv.cpp index 3651f3682c..df43471470 100644 --- a/library/cpp/charset/iconv.cpp +++ b/library/cpp/charset/iconv.cpp @@ -27,7 +27,7 @@ size_t NICONVPrivate::RecodeImpl(const TDescriptor& descriptor, const char* in, Y_ASSERT(in); Y_ASSERT(out); - char* inPtr = const_cast<char*>(in); + char* inPtr = const_cast<char*>(in); char* outPtr = out; size_t inSizeMod = inSize; size_t outSizeMod = outSize; diff --git a/library/cpp/codecs/ya.make b/library/cpp/codecs/ya.make index 11d36ae67b..7e76fb0c9a 100644 --- a/library/cpp/codecs/ya.make +++ b/library/cpp/codecs/ya.make @@ -19,7 +19,7 @@ SRCS( ) PEERDIR( - contrib/libs/zstd + contrib/libs/zstd library/cpp/bit_io library/cpp/blockcodecs library/cpp/codecs/greedy_dict diff --git a/library/cpp/containers/flat_hash/lib/map.h b/library/cpp/containers/flat_hash/lib/map.h index b7f5c4b9b5..f77c318a61 100644 --- a/library/cpp/containers/flat_hash/lib/map.h +++ b/library/cpp/containers/flat_hash/lib/map.h @@ -96,12 +96,12 @@ public: insert(il.begin(), il.end()); } - TMap(std::initializer_list<value_type> il, size_type initSize = INIT_SIZE) - : TBase(initSize) - { - insert(il.begin(), il.end()); - } - + TMap(std::initializer_list<value_type> il, size_type initSize = INIT_SIZE) + : TBase(initSize) + { + insert(il.begin(), il.end()); + } + TMap(const TMap&) = default; TMap(TMap&&) = default; diff --git a/library/cpp/containers/flat_hash/lib/set.h b/library/cpp/containers/flat_hash/lib/set.h index f6ae678068..5266293c6c 100644 --- a/library/cpp/containers/flat_hash/lib/set.h +++ b/library/cpp/containers/flat_hash/lib/set.h @@ -87,12 +87,12 @@ public: insert(il.begin(), il.end()); } - TSet(std::initializer_list<value_type> il, size_type initSize = INIT_SIZE) - : TBase(initSize) - { - insert(il.begin(), il.end()); - } - + TSet(std::initializer_list<value_type> il, size_type initSize = INIT_SIZE) + : TBase(initSize) + { + insert(il.begin(), il.end()); + } + TSet(const TSet&) = default; TSet(TSet&&) = default; diff --git a/library/cpp/json/writer/json.h b/library/cpp/json/writer/json.h index 95c3aefb10..0aae2531b9 100644 --- a/library/cpp/json/writer/json.h +++ b/library/cpp/json/writer/json.h @@ -163,19 +163,19 @@ namespace NJsonWriter { template <typename TOutContext> class TValueWriter { public: - TOutContext WriteNull(); - TOutContext WriteString(const TStringBuf&); - TOutContext WriteString(const TStringBuf& s, EHtmlEscapeMode hem); - TOutContext WriteInt(int); - TOutContext WriteLongLong(long long); - TOutContext WriteULongLong(unsigned long long); - TOutContext WriteBool(bool); - TOutContext WriteFloat(float); - TOutContext WriteFloat(float, EFloatToStringMode, int ndigits); - TOutContext WriteDouble(double); - TOutContext WriteDouble(double, EFloatToStringMode, int ndigits); - TOutContext WriteJsonValue(const NJson::TJsonValue* value, bool sortKeys = false); - TOutContext UnsafeWriteValue(const TStringBuf&); + TOutContext WriteNull(); + TOutContext WriteString(const TStringBuf&); + TOutContext WriteString(const TStringBuf& s, EHtmlEscapeMode hem); + TOutContext WriteInt(int); + TOutContext WriteLongLong(long long); + TOutContext WriteULongLong(unsigned long long); + TOutContext WriteBool(bool); + TOutContext WriteFloat(float); + TOutContext WriteFloat(float, EFloatToStringMode, int ndigits); + TOutContext WriteDouble(double); + TOutContext WriteDouble(double, EFloatToStringMode, int ndigits); + TOutContext WriteJsonValue(const NJson::TJsonValue* value, bool sortKeys = false); + TOutContext UnsafeWriteValue(const TStringBuf&); TValueContext BeginList(); TPairContext BeginObject(); @@ -253,28 +253,28 @@ namespace NJsonWriter { TBuf& Buf; }; -#define JSON_VALUE_WRITER_WRAP(function, params, args) \ - template <typename TOutContext> \ - TOutContext TValueWriter<TOutContext>::function params { \ - Buf.function args; \ - return TOutContext(Buf); \ - } - - JSON_VALUE_WRITER_WRAP(WriteNull, (), ()) - JSON_VALUE_WRITER_WRAP(WriteString, (const TStringBuf& arg), (arg)) - JSON_VALUE_WRITER_WRAP(WriteString, (const TStringBuf& s, EHtmlEscapeMode hem), (s, hem)) - JSON_VALUE_WRITER_WRAP(WriteInt, (int arg), (arg)) - JSON_VALUE_WRITER_WRAP(WriteLongLong, (long long arg), (arg)) - JSON_VALUE_WRITER_WRAP(WriteULongLong, (unsigned long long arg), (arg)) - JSON_VALUE_WRITER_WRAP(WriteBool, (bool arg), (arg)) - JSON_VALUE_WRITER_WRAP(WriteFloat, (float arg), (arg)) - JSON_VALUE_WRITER_WRAP(WriteFloat, (float arg, EFloatToStringMode mode, int ndigits), (arg, mode, ndigits)) - JSON_VALUE_WRITER_WRAP(WriteDouble, (double arg), (arg)) - JSON_VALUE_WRITER_WRAP(WriteDouble, (double arg, EFloatToStringMode mode, int ndigits), (arg, mode, ndigits)) - JSON_VALUE_WRITER_WRAP(WriteJsonValue, (const NJson::TJsonValue* value, bool sortKeys), (value, sortKeys)) - JSON_VALUE_WRITER_WRAP(UnsafeWriteValue, (const TStringBuf& arg), (arg)) -#undef JSON_VALUE_WRITER_WRAP - +#define JSON_VALUE_WRITER_WRAP(function, params, args) \ + template <typename TOutContext> \ + TOutContext TValueWriter<TOutContext>::function params { \ + Buf.function args; \ + return TOutContext(Buf); \ + } + + JSON_VALUE_WRITER_WRAP(WriteNull, (), ()) + JSON_VALUE_WRITER_WRAP(WriteString, (const TStringBuf& arg), (arg)) + JSON_VALUE_WRITER_WRAP(WriteString, (const TStringBuf& s, EHtmlEscapeMode hem), (s, hem)) + JSON_VALUE_WRITER_WRAP(WriteInt, (int arg), (arg)) + JSON_VALUE_WRITER_WRAP(WriteLongLong, (long long arg), (arg)) + JSON_VALUE_WRITER_WRAP(WriteULongLong, (unsigned long long arg), (arg)) + JSON_VALUE_WRITER_WRAP(WriteBool, (bool arg), (arg)) + JSON_VALUE_WRITER_WRAP(WriteFloat, (float arg), (arg)) + JSON_VALUE_WRITER_WRAP(WriteFloat, (float arg, EFloatToStringMode mode, int ndigits), (arg, mode, ndigits)) + JSON_VALUE_WRITER_WRAP(WriteDouble, (double arg), (arg)) + JSON_VALUE_WRITER_WRAP(WriteDouble, (double arg, EFloatToStringMode mode, int ndigits), (arg, mode, ndigits)) + JSON_VALUE_WRITER_WRAP(WriteJsonValue, (const NJson::TJsonValue* value, bool sortKeys), (value, sortKeys)) + JSON_VALUE_WRITER_WRAP(UnsafeWriteValue, (const TStringBuf& arg), (arg)) +#undef JSON_VALUE_WRITER_WRAP + template <typename TOutContext> TValueContext TValueWriter<TOutContext>::BeginList() { return Buf.BeginList(); diff --git a/library/cpp/logger/rotating_file_ut.cpp b/library/cpp/logger/rotating_file_ut.cpp index 05770ead4b..84966933d9 100644 --- a/library/cpp/logger/rotating_file_ut.cpp +++ b/library/cpp/logger/rotating_file_ut.cpp @@ -40,18 +40,18 @@ Y_UNIT_TEST_SUITE(NewRotatingFileSuite) { TStringBuilder data; for (size_t i = 0; i < 10; ++i) data << "data\n"; - log.WriteData(TLogRecord(ELogPriority::TLOG_INFO, data.data(), data.size())); - UNIT_ASSERT_C(TFileStat(PATH).Size > 0, "file " << PATH << " has zero size"); - log.WriteData(TLogRecord(ELogPriority::TLOG_INFO, data.data(), data.size())); - UNIT_ASSERT_C(TFileStat(PATH).Size > 0, "file " << PATH << " has zero size"); - UNIT_ASSERT_C(TFileStat(TStringBuilder{} << PATH << ".1").Size > 0, "file " << PATH << ".1 has zero size"); - UNIT_ASSERT_C(TFileStat(PATH).Size > maxSize, "size of file " << PATH << " is lesser than was written"); - data.clear(); - data << "more data"; - log.WriteData(TLogRecord(ELogPriority::TLOG_INFO, data.data(), data.size())); - UNIT_ASSERT_C(TFileStat(PATH).Size > 0, "file " << PATH << " has zero size"); - UNIT_ASSERT_C(TFileStat(TStringBuilder{} << PATH << ".1").Size > 0, "file " << PATH << ".1 has zero size"); - UNIT_ASSERT_C(TFileStat(TStringBuilder{} << PATH << ".2").Size > 0, "file " << PATH << ".2 has zero size"); - UNIT_ASSERT_C(TFileStat(PATH).Size < maxSize, "size of file " << PATH << " is greater than the size limit of " << maxSize << " bytes"); + log.WriteData(TLogRecord(ELogPriority::TLOG_INFO, data.data(), data.size())); + UNIT_ASSERT_C(TFileStat(PATH).Size > 0, "file " << PATH << " has zero size"); + log.WriteData(TLogRecord(ELogPriority::TLOG_INFO, data.data(), data.size())); + UNIT_ASSERT_C(TFileStat(PATH).Size > 0, "file " << PATH << " has zero size"); + UNIT_ASSERT_C(TFileStat(TStringBuilder{} << PATH << ".1").Size > 0, "file " << PATH << ".1 has zero size"); + UNIT_ASSERT_C(TFileStat(PATH).Size > maxSize, "size of file " << PATH << " is lesser than was written"); + data.clear(); + data << "more data"; + log.WriteData(TLogRecord(ELogPriority::TLOG_INFO, data.data(), data.size())); + UNIT_ASSERT_C(TFileStat(PATH).Size > 0, "file " << PATH << " has zero size"); + UNIT_ASSERT_C(TFileStat(TStringBuilder{} << PATH << ".1").Size > 0, "file " << PATH << ".1 has zero size"); + UNIT_ASSERT_C(TFileStat(TStringBuilder{} << PATH << ".2").Size > 0, "file " << PATH << ".2 has zero size"); + UNIT_ASSERT_C(TFileStat(PATH).Size < maxSize, "size of file " << PATH << " is greater than the size limit of " << maxSize << " bytes"); } } diff --git a/library/cpp/lwtrace/log.h b/library/cpp/lwtrace/log.h index 9bf3aa7d24..56981a97f8 100644 --- a/library/cpp/lwtrace/log.h +++ b/library/cpp/lwtrace/log.h @@ -276,7 +276,7 @@ namespace NLWTrace { struct TItem : TLogItem { TThread::TId ThreadId; - TItem() = default; + TItem() = default; TItem(TThread::TId tid, const TLogItem& item) : TLogItem(item) diff --git a/library/cpp/malloc/ya.make b/library/cpp/malloc/ya.make index fe0c439002..0ec9db71d2 100644 --- a/library/cpp/malloc/ya.make +++ b/library/cpp/malloc/ya.make @@ -5,7 +5,7 @@ RECURSE( tcmalloc galloc jemalloc - lockless + lockless nalf sample-client system @@ -15,10 +15,10 @@ RECURSE( hu/link_test ) -IF (NOT OS_WINDOWS) +IF (NOT OS_WINDOWS) RECURSE( - calloc - calloc/tests + calloc + calloc/tests calloc/calloc_profile_diff calloc/calloc_profile_scan calloc/calloc_profile_scan/ut diff --git a/library/cpp/monlib/encode/spack/compression.cpp b/library/cpp/monlib/encode/spack/compression.cpp index 6de23dbb08..0d2152fc85 100644 --- a/library/cpp/monlib/encode/spack/compression.cpp +++ b/library/cpp/monlib/encode/spack/compression.cpp @@ -10,7 +10,7 @@ #include <util/stream/walk.h> #include <contrib/libs/lz4/lz4.h> -#include <contrib/libs/xxhash/xxhash.h> +#include <contrib/libs/xxhash/xxhash.h> #include <contrib/libs/zlib/zlib.h> #define ZSTD_STATIC_LINKING_ONLY #include <contrib/libs/zstd/include/zstd.h> @@ -60,7 +60,7 @@ namespace NMonitoring { struct TXxHash32 { static TCheckSum Calc(TBlock in) { static const ui32 SEED = 0x1337c0de; - return XXH32(in.data(), in.size(), SEED); + return XXH32(in.data(), in.size(), SEED); } static bool Check(TBlock in, TCheckSum checksum) { diff --git a/library/cpp/monlib/encode/spack/ya.make b/library/cpp/monlib/encode/spack/ya.make index 71d4169b0d..78d3061291 100644 --- a/library/cpp/monlib/encode/spack/ya.make +++ b/library/cpp/monlib/encode/spack/ya.make @@ -17,7 +17,7 @@ PEERDIR( library/cpp/monlib/exception contrib/libs/lz4 - contrib/libs/xxhash + contrib/libs/xxhash contrib/libs/zlib contrib/libs/zstd ) diff --git a/library/cpp/monlib/metrics/metric_value.h b/library/cpp/monlib/metrics/metric_value.h index 424f51f40e..607fcc8602 100644 --- a/library/cpp/monlib/metrics/metric_value.h +++ b/library/cpp/monlib/metrics/metric_value.h @@ -16,7 +16,7 @@ namespace NMonitoring { template <typename T> T FromFloatSafe(double d) { static_assert(std::is_integral<T>::value, "this function only converts floats to integers"); - Y_ENSURE(::IsValidFloat(d) && d >= Min<T>() && d <= MaxFloor<T>(), "Cannot convert " << d << " to an integer value"); + Y_ENSURE(::IsValidFloat(d) && d >= Min<T>() && d <= MaxFloor<T>(), "Cannot convert " << d << " to an integer value"); return static_cast<T>(d); } diff --git a/library/cpp/openssl/init/ya.make b/library/cpp/openssl/init/ya.make index 19f291d980..aac073497c 100644 --- a/library/cpp/openssl/init/ya.make +++ b/library/cpp/openssl/init/ya.make @@ -1,6 +1,6 @@ LIBRARY() -OWNER(pg g:zora) +OWNER(pg g:zora) PEERDIR( contrib/libs/openssl diff --git a/library/cpp/protobuf/json/json2proto.cpp b/library/cpp/protobuf/json/json2proto.cpp index 66a9ef115f..640c10f5a5 100644 --- a/library/cpp/protobuf/json/json2proto.cpp +++ b/library/cpp/protobuf/json/json2proto.cpp @@ -42,12 +42,12 @@ static TString GetFieldName(const google::protobuf::FieldDescriptor& field, if (config.UseJsonName) { Y_ASSERT(!field.json_name().empty()); - TString name = field.json_name(); - if (!field.has_json_name() && !name.empty()) { - // FIXME: https://st.yandex-team.ru/CONTRIB-139 - name[0] = AsciiToLower(name[0]); - } - return name; + TString name = field.json_name(); + if (!field.has_json_name() && !name.empty()) { + // FIXME: https://st.yandex-team.ru/CONTRIB-139 + name[0] = AsciiToLower(name[0]); + } + return name; } TString name = field.name(); @@ -61,7 +61,7 @@ static TString GetFieldName(const google::protobuf::FieldDescriptor& field, name.to_upper(); break; case NProtobufJson::TJson2ProtoConfig::FieldNameCamelCase: - if (!name.empty()) { + if (!name.empty()) { name[0] = AsciiToLower(name[0]); } break; diff --git a/library/cpp/protobuf/json/proto2json_printer.cpp b/library/cpp/protobuf/json/proto2json_printer.cpp index ae5bdbcd29..6123eab0f2 100644 --- a/library/cpp/protobuf/json/proto2json_printer.cpp +++ b/library/cpp/protobuf/json/proto2json_printer.cpp @@ -22,12 +22,12 @@ namespace NProtobufJson { if (config.UseJsonName) { Y_ASSERT(!field.json_name().empty()); - NewKeyStr = field.json_name(); - if (!field.has_json_name() && !NewKeyStr.empty()) { - // FIXME: https://st.yandex-team.ru/CONTRIB-139 - NewKeyStr[0] = AsciiToLower(NewKeyStr[0]); - } - NewKeyBuf = NewKeyStr; + NewKeyStr = field.json_name(); + if (!field.has_json_name() && !NewKeyStr.empty()) { + // FIXME: https://st.yandex-team.ru/CONTRIB-139 + NewKeyStr[0] = AsciiToLower(NewKeyStr[0]); + } + NewKeyBuf = NewKeyStr; return; } @@ -53,7 +53,7 @@ namespace NProtobufJson { case TProto2JsonConfig::FieldNameCamelCase: { NewKeyStr = field.name(); - if (!NewKeyStr.empty()) { + if (!NewKeyStr.empty()) { NewKeyStr[0] = AsciiToLower(NewKeyStr[0]); } NewKeyBuf = NewKeyStr; diff --git a/library/cpp/protobuf/json/ut/json.h b/library/cpp/protobuf/json/ut/json.h index 3b3b27057b..c1f108e6e4 100644 --- a/library/cpp/protobuf/json/ut/json.h +++ b/library/cpp/protobuf/json/ut/json.h @@ -61,9 +61,9 @@ namespace NProtobufJsonTest { #define UNIT_ASSERT_JSON_STRINGS_EQUAL(lhs, rhs) \ if (lhs != rhs) { \ NJson::TJsonValue _lhs_json, _rhs_json; \ - UNIT_ASSERT(NJson::ReadJsonTree(lhs, &_lhs_json)); \ - UNIT_ASSERT(NJson::ReadJsonTree(rhs, &_rhs_json)); \ + UNIT_ASSERT(NJson::ReadJsonTree(lhs, &_lhs_json)); \ + UNIT_ASSERT(NJson::ReadJsonTree(rhs, &_rhs_json)); \ UNIT_ASSERT_JSONS_EQUAL(_lhs_json, _rhs_json); \ - } - + } + } diff --git a/library/cpp/protobuf/json/ut/test.proto b/library/cpp/protobuf/json/ut/test.proto index 41575daf9a..0fa996fd41 100644 --- a/library/cpp/protobuf/json/ut/test.proto +++ b/library/cpp/protobuf/json/ut/test.proto @@ -172,10 +172,10 @@ message TComplexMapType { }; message TWithJsonName { - optional int32 my_upper = 1 [json_name = "My-Upper"]; - optional int32 My_lower = 2 [json_name = "my-lower"]; - optional int32 Def_upper = 3; // json_name = "DefUpper" - optional int32 def_lower = 4; // json_name = "defLower" + optional int32 my_upper = 1 [json_name = "My-Upper"]; + optional int32 My_lower = 2 [json_name = "my-lower"]; + optional int32 Def_upper = 3; // json_name = "DefUpper" + optional int32 def_lower = 4; // json_name = "defLower" } message TSingleRequiredString { diff --git a/library/cpp/resource/registry.cpp b/library/cpp/resource/registry.cpp index 1a52646390..66001c4769 100644 --- a/library/cpp/resource/registry.cpp +++ b/library/cpp/resource/registry.cpp @@ -23,23 +23,23 @@ namespace { struct TStore: public IStore, public THashMap<TStringBuf, TDescriptor*> { void Store(const TStringBuf key, const TStringBuf data) override { if (contains(key)) { - const TStringBuf value = (*this)[key]->second; - if (value != data) { - size_t vsize = GetCodec()->DecompressedLength(value); - size_t dsize = GetCodec()->DecompressedLength(data); - if (vsize + dsize < 1000) { - Y_VERIFY(false, "Redefinition of key %s:\n" - " old value: %s,\n" - " new value: %s.", + const TStringBuf value = (*this)[key]->second; + if (value != data) { + size_t vsize = GetCodec()->DecompressedLength(value); + size_t dsize = GetCodec()->DecompressedLength(data); + if (vsize + dsize < 1000) { + Y_VERIFY(false, "Redefinition of key %s:\n" + " old value: %s,\n" + " new value: %s.", TString{key}.Quote().c_str(), - Decompress(value).Quote().c_str(), - Decompress(data).Quote().c_str()); - } else { - Y_VERIFY(false, "Redefinition of key %s," + Decompress(value).Quote().c_str(), + Decompress(data).Quote().c_str()); + } else { + Y_VERIFY(false, "Redefinition of key %s," " old size: %zu," " new size: %zu.", TString{key}.Quote().c_str(), vsize, dsize); - } + } } } else { D_.push_back(TDescriptor(key, data)); diff --git a/library/cpp/scheme/tests/ut/scheme_ut.cpp b/library/cpp/scheme/tests/ut/scheme_ut.cpp index a8b829b6e1..1a5d07c31b 100644 --- a/library/cpp/scheme/tests/ut/scheme_ut.cpp +++ b/library/cpp/scheme/tests/ut/scheme_ut.cpp @@ -756,7 +756,7 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { TValue v = TValue::FromJson("{foo:bar}"); TValue w(std::move(v)); UNIT_ASSERT(v.IsNull()); - v = static_cast<TValue&>(v); + v = static_cast<TValue&>(v); UNIT_ASSERT(v.IsNull()); UNIT_ASSERT_VALUES_EQUAL(w.Get("foo").GetString(), "bar"); v = std::move(w); diff --git a/library/cpp/streams/bzip2/bzip2.cpp b/library/cpp/streams/bzip2/bzip2.cpp index 2bb8592017..bccc5c6807 100644 --- a/library/cpp/streams/bzip2/bzip2.cpp +++ b/library/cpp/streams/bzip2/bzip2.cpp @@ -19,13 +19,13 @@ public: } inline void Init() { - if (BZ2_bzDecompressInit(&BzStream_, 0, 0) != BZ_OK) { + if (BZ2_bzDecompressInit(&BzStream_, 0, 0) != BZ_OK) { ythrow TBZipDecompressError() << "can not init bzip engine"; } } inline void Clear() noexcept { - BZ2_bzDecompressEnd(&BzStream_); + BZ2_bzDecompressEnd(&BzStream_); } inline size_t Read(void* buf, size_t size) { @@ -39,7 +39,7 @@ public: } } - switch (BZ2_bzDecompress(&BzStream_)) { + switch (BZ2_bzDecompress(&BzStream_)) { case BZ_STREAM_END: { Clear(); Init(); @@ -93,7 +93,7 @@ public: { Zero(BzStream_); - if (BZ2_bzCompressInit(&BzStream_, level, 0, 0) != BZ_OK) { + if (BZ2_bzCompressInit(&BzStream_, level, 0, 0) != BZ_OK) { ythrow TBZipCompressError() << "can not init bzip engine"; } @@ -102,7 +102,7 @@ public: } inline ~TImpl() { - BZ2_bzCompressEnd(&BzStream_); + BZ2_bzCompressEnd(&BzStream_); } inline void Write(const void* buf, size_t size) { @@ -115,7 +115,7 @@ public: }; while (BzStream_.avail_in) { - const int ret = BZ2_bzCompress(&BzStream_, BZ_RUN); + const int ret = BZ2_bzCompress(&BzStream_, BZ_RUN); switch (ret) { case BZ_RUN_OK: @@ -142,14 +142,14 @@ public: } inline void Finish() { - int ret = BZ2_bzCompress(&BzStream_, BZ_FINISH); + int ret = BZ2_bzCompress(&BzStream_, BZ_FINISH); while (ret != BZ_STREAM_END) { Stream_->Write(TmpBuf(), TmpBufLen() - BzStream_.avail_out); BzStream_.next_out = TmpBuf(); BzStream_.avail_out = TmpBufLen(); - ret = BZ2_bzCompress(&BzStream_, BZ_FINISH); + ret = BZ2_bzCompress(&BzStream_, BZ_FINISH); } Stream_->Write(TmpBuf(), TmpBufLen() - BzStream_.avail_out); diff --git a/library/cpp/streams/lz/lz.cpp b/library/cpp/streams/lz/lz.cpp index a9fcb9bf6d..b65bb3ed96 100644 --- a/library/cpp/streams/lz/lz.cpp +++ b/library/cpp/streams/lz/lz.cpp @@ -475,7 +475,7 @@ public: } inline size_t Decompress(const char* data, size_t len, char* ptr, size_t max) { - int res = LZ4_decompress_safe(data, ptr, len, max); + int res = LZ4_decompress_safe(data, ptr, len, max); if (res < 0) ythrow TDecompressorError(); return res; diff --git a/library/cpp/timezone_conversion/civil.h b/library/cpp/timezone_conversion/civil.h index e6de68233f..0e95b807ed 100644 --- a/library/cpp/timezone_conversion/civil.h +++ b/library/cpp/timezone_conversion/civil.h @@ -2,8 +2,8 @@ #include <util/datetime/base.h> -#include <contrib/libs/cctz/include/cctz/civil_time.h> -#include <contrib/libs/cctz/include/cctz/time_zone.h> +#include <contrib/libs/cctz/include/cctz/civil_time.h> +#include <contrib/libs/cctz/include/cctz/time_zone.h> #include <util/generic/strbuf.h> #include <util/generic/string.h> diff --git a/library/cpp/timezone_conversion/convert.cpp b/library/cpp/timezone_conversion/convert.cpp index 463bfd94aa..490bb4e270 100644 --- a/library/cpp/timezone_conversion/convert.cpp +++ b/library/cpp/timezone_conversion/convert.cpp @@ -1,6 +1,6 @@ #include "convert.h" -#include <contrib/libs/cctz/include/cctz/civil_time.h> +#include <contrib/libs/cctz/include/cctz/civil_time.h> #include <util/generic/yexception.h> diff --git a/library/cpp/timezone_conversion/convert.h b/library/cpp/timezone_conversion/convert.h index 858ce65f59..768a9e110f 100644 --- a/library/cpp/timezone_conversion/convert.h +++ b/library/cpp/timezone_conversion/convert.h @@ -2,7 +2,7 @@ #include "civil.h" -#include <contrib/libs/cctz/include/cctz/time_zone.h> +#include <contrib/libs/cctz/include/cctz/time_zone.h> #include <util/datetime/base.h> #include <util/draft/datetime.h> diff --git a/library/cpp/tld/ya.make b/library/cpp/tld/ya.make index 7a7f90f03d..aeabbfeebf 100644 --- a/library/cpp/tld/ya.make +++ b/library/cpp/tld/ya.make @@ -2,7 +2,7 @@ LIBRARY() OWNER(abolkhovityanov) -PYTHON( +PYTHON( gen_tld.py tlds-alpha-by-domain.txt IN tlds-alpha-by-domain.txt STDOUT tld.inc diff --git a/library/cpp/uri/parsefsm.rl6 b/library/cpp/uri/parsefsm.rl6 index 53956539d3..7097723650 100644 --- a/library/cpp/uri/parsefsm.rl6 +++ b/library/cpp/uri/parsefsm.rl6 @@ -479,13 +479,13 @@ bool TParser::doParse(const char* str_beg, size_t length) %% write init nocs; - if (0 == (Flags & TFeature::FeatureNoRelPath)) { + if (0 == (Flags & TFeature::FeatureNoRelPath)) { cs = TParser_en_URI_ref; - } else if (0 == (Flags & TFeature::FeatureAllowRootless)) { + } else if (0 == (Flags & TFeature::FeatureAllowRootless)) { cs = TParser_en_URI_ref_no_rootless; - } else { + } else { cs = TParser_en_URI_ref_no_relpath; - } + } %% write exec; diff --git a/library/cpp/yson/node/node.h b/library/cpp/yson/node/node.h index 82b956272f..5f90f95df0 100644 --- a/library/cpp/yson/node/node.h +++ b/library/cpp/yson/node/node.h @@ -6,7 +6,7 @@ #include <util/generic/variant.h> #include <util/generic/vector.h> #include <util/generic/yexception.h> -#include <util/generic/ylimits.h> +#include <util/generic/ylimits.h> #include <util/string/cast.h> #include <cmath> @@ -324,7 +324,7 @@ inline T TNode::ConvertTo() const { case NYT::TNode::Uint64: return IntCast<T>(); case NYT::TNode::Double: - if (AsDouble() < Min<T>() || AsDouble() > MaxFloor<T>() || !std::isfinite(AsDouble())) { + if (AsDouble() < Min<T>() || AsDouble() > MaxFloor<T>() || !std::isfinite(AsDouble())) { ythrow TTypeError() << AsDouble() << " can't be converted to " << TypeName<T>(); } return AsDouble(); diff --git a/library/cpp/yson/node/node_ut.cpp b/library/cpp/yson/node/node_ut.cpp index 0d385b54f8..448e99f575 100644 --- a/library/cpp/yson/node/node_ut.cpp +++ b/library/cpp/yson/node/node_ut.cpp @@ -345,14 +345,14 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { UNIT_ASSERT_EXCEPTION(TNode(-5.3).ConvertTo<ui8>(), TNode::TTypeError); UNIT_ASSERT_EXCEPTION(TNode(-5.3).ConvertTo<ui64>(), TNode::TTypeError); - UNIT_ASSERT_VALUES_EQUAL(TNode(127.0).ConvertTo<i8>(), 127); - UNIT_ASSERT_EXCEPTION(TNode(128.0).ConvertTo<i8>(), TNode::TTypeError); - UNIT_ASSERT_VALUES_EQUAL(TNode(255.0).ConvertTo<ui8>(), 255); + UNIT_ASSERT_VALUES_EQUAL(TNode(127.0).ConvertTo<i8>(), 127); + UNIT_ASSERT_EXCEPTION(TNode(128.0).ConvertTo<i8>(), TNode::TTypeError); + UNIT_ASSERT_VALUES_EQUAL(TNode(255.0).ConvertTo<ui8>(), 255); UNIT_ASSERT_EXCEPTION(TNode(256.0).ConvertTo<ui8>(), TNode::TTypeError); UNIT_ASSERT_EXCEPTION(TNode(1e100).ConvertTo<i64>(), TNode::TTypeError); UNIT_ASSERT_EXCEPTION(TNode(1e100).ConvertTo<ui64>(), TNode::TTypeError); { - double v = 1ull << 63; + double v = 1ull << 63; TNode node = v; UNIT_ASSERT(node.IsDouble()); UNIT_ASSERT_EXCEPTION(node.ConvertTo<i64>(), TNode::TTypeError); diff --git a/library/python/certifi/.dist-info/METADATA b/library/python/certifi/.dist-info/METADATA index 12bf982cf3..4849f81ed4 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 96dcc4c1c3..75a812733c 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 8d14209d03..5270d206cd 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 523fe31287..1050e733a3 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 81566bbf32..f539b67002 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 398210c0e6..64fefe2833 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 79b58cff73..e36f47a78f 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 17cf1197e5..522041f5a7 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 dd00de7b43..26503ef7fc 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 4fd3747311..52f006ff91 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 5019adb9f7..693e388878 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 52028b5f4e..5085610faf 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 bcd5b141b5..64eb2e83ce 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 7e5af9a55e..989329fa4b 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 c0e17b7de8..97190d9f29 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 0639bc4aaf..05098723cb 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 7caa69e91e..904f94dea2 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 +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) -# 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 resfs path to the source code of the module with the given name. + 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 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() +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) - -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 55afdca5f3..3159800615 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 3ffe3e0eab..f308a93b28 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 625ccffb79..966bbe8ba6 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 37e04ffd5f..fa5c11341a 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 0d57b00b99..6c04a7ef6e 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 d8ab0acb63..7b84cbc961 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 d3d511b779..92bc7f4d67 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; +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)); } - -#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 +#endif diff --git a/library/python/symbols/module/ya.make b/library/python/symbols/module/ya.make index f84d3c268e..78e30f2547 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 46fbd25dc2..9b52574cb1 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) -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) +#define SYM(SYM_NAME) extern "C" void SYM_NAME(); +SYM(PyObject_GetBuffer) +SYM(PyBuffer_Release) SYM(PyCell_New) -SYM(Py_DecRef) -SYM(Py_IncRef) -END_SYMS() +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() diff --git a/library/python/symbols/python/ut/py2/ya.make b/library/python/symbols/python/ut/py2/ya.make index 110c9f7c75..214194de57 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 a5e2a0d844..76611c6a19 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 ff0d37ef1a..253a10d8b3 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 019017f945..2849e01b1e 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 5a1922861c..6bfd54f8bc 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 4729699d3b..340a710c48 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 720a972ea3..3e3b7234ef 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) + 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 - 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 -test_imports = check_imports - - -def main(): - skip_names = sys.argv[1:] - - os.environ['Y_PYTHON_IMPORT_TEST'] = '' + +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 54a899c2ba..a8bcc21f51 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 72cc24a9fe..2e1eb6e0e1 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() |