diff options
author | maxim-yurchuk <maxim-yurchuk@yandex-team.com> | 2024-10-09 12:29:46 +0300 |
---|---|---|
committer | maxim-yurchuk <maxim-yurchuk@yandex-team.com> | 2024-10-09 13:14:22 +0300 |
commit | 9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80 (patch) | |
tree | a8fb3181d5947c0d78cf402aa56e686130179049 /contrib/deprecated/python | |
parent | a44b779cd359f06c3ebbef4ec98c6b38609d9d85 (diff) | |
download | ydb-9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80.tar.gz |
publishFullContrib: true for ydb
<HIDDEN_URL>
commit_hash:c82a80ac4594723cebf2c7387dec9c60217f603e
Diffstat (limited to 'contrib/deprecated/python')
24 files changed, 1731 insertions, 0 deletions
diff --git a/contrib/deprecated/python/backports.functools-lru-cache/.yandex_meta/yamaker.yaml b/contrib/deprecated/python/backports.functools-lru-cache/.yandex_meta/yamaker.yaml new file mode 100644 index 0000000000..e7fa2eef69 --- /dev/null +++ b/contrib/deprecated/python/backports.functools-lru-cache/.yandex_meta/yamaker.yaml @@ -0,0 +1,2 @@ +exclude: +- backports/__init__.py # Для избежания коллизий с другими backports пакетами diff --git a/contrib/deprecated/python/backports.shutil-get-terminal-size/.yandex_meta/yamaker.yaml b/contrib/deprecated/python/backports.shutil-get-terminal-size/.yandex_meta/yamaker.yaml new file mode 100644 index 0000000000..806dfa6b82 --- /dev/null +++ b/contrib/deprecated/python/backports.shutil-get-terminal-size/.yandex_meta/yamaker.yaml @@ -0,0 +1,3 @@ +exclude: +- backports/__init__.py # Для избежания коллизий с другими backports пакетами +- shutil_backports/* # В Аркадии нет потребителей для этого пакета diff --git a/contrib/deprecated/python/backports.shutil-get-terminal-size/patches/01-arcadia.patch b/contrib/deprecated/python/backports.shutil-get-terminal-size/patches/01-arcadia.patch new file mode 100644 index 0000000000..b858e79412 --- /dev/null +++ b/contrib/deprecated/python/backports.shutil-get-terminal-size/patches/01-arcadia.patch @@ -0,0 +1,11 @@ +--- contrib/deprecated/python/backports.shutil-get-terminal-size/backports/shutil_get_terminal_size/get_terminal_size.py (index) ++++ contrib/deprecated/python/backports.shutil-get-terminal-size/backports/shutil_get_terminal_size/get_terminal_size.py (working tree) +@@ -41,7 +41,7 @@ try: + + return terminal_size(columns, lines) + +-except ImportError: ++except (ImportError, OSError): + import fcntl + import termios + diff --git a/contrib/deprecated/python/configparser/.yandex_meta/yamaker.yaml b/contrib/deprecated/python/configparser/.yandex_meta/yamaker.yaml new file mode 100644 index 0000000000..6a94e2a321 --- /dev/null +++ b/contrib/deprecated/python/configparser/.yandex_meta/yamaker.yaml @@ -0,0 +1,2 @@ +exclude: + - backports/__init__.py # Для избежания коллизий с другими backports пакетами diff --git a/contrib/deprecated/python/enum34/.yandex_meta/yamaker.yaml b/contrib/deprecated/python/enum34/.yandex_meta/yamaker.yaml new file mode 100644 index 0000000000..e373dfa8fd --- /dev/null +++ b/contrib/deprecated/python/enum34/.yandex_meta/yamaker.yaml @@ -0,0 +1,3 @@ +exclude_from_macros: + - enum/LICENSE + - enum/README diff --git a/contrib/deprecated/python/enum34/patches/01-unknown.patch b/contrib/deprecated/python/enum34/patches/01-unknown.patch new file mode 100644 index 0000000000..4ed999b4e6 --- /dev/null +++ b/contrib/deprecated/python/enum34/patches/01-unknown.patch @@ -0,0 +1,82 @@ +--- contrib/deprecated/python/enum34/enum/__init__.py (index) ++++ contrib/deprecated/python/enum34/enum/__init__.py (working tree) +@@ -8,6 +8,8 @@ version = 1, 1, 10 + + pyver = float('%s.%s' % _sys.version_info[:2]) + ++ALLOW_SYNONYMS = '__allow_synonyms__' ++ + try: + any + except NameError: +@@ -161,6 +163,7 @@ class EnumMeta(type): + for k, v in original_dict.items(): + classdict[k] = v + ++ allow_synonyms = classdict.get(ALLOW_SYNONYMS, True) + member_type, first_enum = metacls._get_mixins_(bases) + __new__, save_new, use_args = metacls._find_new_(classdict, member_type, + first_enum) +@@ -215,8 +218,18 @@ class EnumMeta(type): + # auto-numbering ;) + if __new__ is None: + __new__ = enum_class.__new__ ++ ++ val2name = {} + for member_name in _order_: + value = members[member_name] ++ if not allow_synonyms: ++ if value in val2name: ++ raise ValueError( ++ 'allow_synonyms=False forbids multiple names of the same value; ' ++ 'Members {!r} and {!r} break this'.format(val2name[value], member_name) ++ ) ++ val2name[value] = member_name ++ + if not isinstance(value, tuple): + args = (value, ) + else: +@@ -237,7 +250,7 @@ class EnumMeta(type): + enum_member.__init__(*args) + # If another member with the same value was already defined, the + # new member becomes an alias to the existing one. +- for name, canonical_member in enum_class._member_map_.items(): ++ for name, canonical_member in (enum_class._member_map_.items() if allow_synonyms else ()): + if canonical_member.value == enum_member._value_: + enum_member = canonical_member + break +@@ -328,7 +341,7 @@ class EnumMeta(type): + """ + return True + +- def __call__(cls, value, names=None, module=None, type=None, start=1): ++ def __call__(cls, value, names=None, module=None, type=None, start=1, allow_synonyms=True): + """Either returns an existing member, or creates a new enum class. + + This method is used both when an enum class is given a value to match +@@ -347,7 +360,7 @@ class EnumMeta(type): + if names is None: # simple value lookup + return cls.__new__(cls, value) + # otherwise, functional API: we're creating a new Enum type +- return cls._create_(value, names, module=module, type=type, start=start) ++ return cls._create_(value, names, module=module, type=type, start=start, allow_synonyms=allow_synonyms) + + def __contains__(cls, member): + return isinstance(member, cls) and member.name in cls._member_map_ +@@ -420,7 +433,7 @@ class EnumMeta(type): + raise AttributeError('Cannot reassign members.') + super(EnumMeta, cls).__setattr__(name, value) + +- def _create_(cls, class_name, names=None, module=None, type=None, start=1): ++ def _create_(cls, class_name, names=None, module=None, type=None, start=1, allow_synonyms=True): + """Convenience method to create a new Enum class. + + `names` can be: +@@ -465,6 +478,7 @@ class EnumMeta(type): + # only set _order_ in classdict if name/value was not from a mapping + if not isinstance(item, basestring): + classdict['_order_'] = _order_ ++ classdict[ALLOW_SYNONYMS] = getattr(cls, ALLOW_SYNONYMS, allow_synonyms) + enum_class = metacls.__new__(metacls, class_name, bases, classdict) + + # TODO: replace the frame hack if a blessed way to know the calling diff --git a/contrib/deprecated/python/enum34/patches/02-fix-tests.patch b/contrib/deprecated/python/enum34/patches/02-fix-tests.patch new file mode 100644 index 0000000000..96e67e60b8 --- /dev/null +++ b/contrib/deprecated/python/enum34/patches/02-fix-tests.patch @@ -0,0 +1,216 @@ +--- contrib/deprecated/python/enum34/enum/test.py (index) ++++ contrib/deprecated/python/enum34/enum/test.py (working tree) +@@ -94,7 +94,9 @@ try: + except Exception: + pass + +-def test_pickle_dump_load(assertion, source, target=None, ++import pytest ++ ++def check_pickle_dump_load(assertion, source, target=None, + protocol=(0, HIGHEST_PROTOCOL)): + start, stop = protocol + failures = [] +@@ -110,7 +112,7 @@ def test_pickle_dump_load(assertion, source, target=None, + if failures: + raise ValueError('Failed with protocols: %s' % ', '.join(failures)) + +-def test_pickle_exception(assertion, exception, obj, ++def check_pickle_exception(assertion, exception, obj, + protocol=(0, HIGHEST_PROTOCOL)): + start, stop = protocol + failures = [] +@@ -610,32 +612,32 @@ class TestEnum(unittest.TestCase): + def test_pickle_enum(self): + if isinstance(Stooges, Exception): + raise Stooges +- test_pickle_dump_load(self.assertTrue, Stooges.CURLY) +- test_pickle_dump_load(self.assertTrue, Stooges) ++ check_pickle_dump_load(self.assertTrue, Stooges.CURLY) ++ check_pickle_dump_load(self.assertTrue, Stooges) + + def test_pickle_int(self): + if isinstance(IntStooges, Exception): + raise IntStooges +- test_pickle_dump_load(self.assertTrue, IntStooges.CURLY) +- test_pickle_dump_load(self.assertTrue, IntStooges) ++ check_pickle_dump_load(self.assertTrue, IntStooges.CURLY) ++ check_pickle_dump_load(self.assertTrue, IntStooges) + + def test_pickle_float(self): + if isinstance(FloatStooges, Exception): + raise FloatStooges +- test_pickle_dump_load(self.assertTrue, FloatStooges.CURLY) +- test_pickle_dump_load(self.assertTrue, FloatStooges) ++ check_pickle_dump_load(self.assertTrue, FloatStooges.CURLY) ++ check_pickle_dump_load(self.assertTrue, FloatStooges) + + def test_pickle_enum_function(self): + if isinstance(Answer, Exception): + raise Answer +- test_pickle_dump_load(self.assertTrue, Answer.him) +- test_pickle_dump_load(self.assertTrue, Answer) ++ check_pickle_dump_load(self.assertTrue, Answer.him) ++ check_pickle_dump_load(self.assertTrue, Answer) + + def test_pickle_enum_function_with_module(self): + if isinstance(Question, Exception): + raise Question +- test_pickle_dump_load(self.assertTrue, Question.who) +- test_pickle_dump_load(self.assertTrue, Question) ++ check_pickle_dump_load(self.assertTrue, Question.who) ++ check_pickle_dump_load(self.assertTrue, Question) + + if pyver == 3.4: + def test_class_nested_enum_and_pickle_protocol_four(self): +@@ -646,10 +648,10 @@ class TestEnum(unittest.TestCase): + + self.__class__.NestedEnum = NestedEnum + self.NestedEnum.__qualname__ = '%s.NestedEnum' % self.__class__.__name__ +- test_pickle_exception( ++ check_pickle_exception( + self.assertRaises, PicklingError, self.NestedEnum.twigs, + protocol=(0, 3)) +- test_pickle_dump_load(self.assertTrue, self.NestedEnum.twigs, ++ check_pickle_dump_load(self.assertTrue, self.NestedEnum.twigs, + protocol=(4, HIGHEST_PROTOCOL)) + + elif pyver == 3.5: +@@ -661,15 +663,15 @@ class TestEnum(unittest.TestCase): + + self.__class__.NestedEnum = NestedEnum + self.NestedEnum.__qualname__ = '%s.NestedEnum' % self.__class__.__name__ +- test_pickle_dump_load(self.assertTrue, self.NestedEnum.twigs, ++ check_pickle_dump_load(self.assertTrue, self.NestedEnum.twigs, + protocol=(0, HIGHEST_PROTOCOL)) + + def test_exploding_pickle(self): + BadPickle = Enum('BadPickle', 'dill sweet bread_n_butter') + enum._make_class_unpicklable(BadPickle) + globals()['BadPickle'] = BadPickle +- test_pickle_exception(self.assertRaises, TypeError, BadPickle.dill) +- test_pickle_exception(self.assertRaises, PicklingError, BadPickle) ++ check_pickle_exception(self.assertRaises, TypeError, BadPickle.dill) ++ check_pickle_exception(self.assertRaises, PicklingError, BadPickle) + + def test_string_enum(self): + class SkillLevel(str, Enum): +@@ -1066,7 +1068,7 @@ class TestEnum(unittest.TestCase): + self.assertEqual(Name.BDFL, 'Guido van Rossum') + self.assertTrue(Name.BDFL, Name('Guido van Rossum')) + self.assertTrue(Name.BDFL is getattr(Name, 'BDFL')) +- test_pickle_dump_load(self.assertTrue, Name.BDFL) ++ check_pickle_dump_load(self.assertTrue, Name.BDFL) + + def test_extending(self): + def bad_extension(): +@@ -1291,9 +1293,9 @@ class TestEnum(unittest.TestCase): + globals()['NEI'] = NEI + NI5 = NamedInt('test', 5) + self.assertEqual(NI5, 5) +- test_pickle_dump_load(self.assertTrue, NI5, 5) ++ check_pickle_dump_load(self.assertTrue, NI5, 5) + self.assertEqual(NEI.y.value, 2) +- test_pickle_dump_load(self.assertTrue, NEI.y) ++ check_pickle_dump_load(self.assertTrue, NEI.y) + + if pyver >= 3.4: + def test_subclasses_with_getnewargs_ex(self): +@@ -1348,9 +1350,9 @@ class TestEnum(unittest.TestCase): + globals()['NEI'] = NEI + NI5 = NamedInt('test', 5) + self.assertEqual(NI5, 5) +- test_pickle_dump_load(self.assertEqual, NI5, 5, protocol=(4, HIGHEST_PROTOCOL)) ++ check_pickle_dump_load(self.assertEqual, NI5, 5, protocol=(4, HIGHEST_PROTOCOL)) + self.assertEqual(NEI.y.value, 2) +- test_pickle_dump_load(self.assertTrue, NEI.y, protocol=(4, HIGHEST_PROTOCOL)) ++ check_pickle_dump_load(self.assertTrue, NEI.y, protocol=(4, HIGHEST_PROTOCOL)) + + def test_subclasses_with_reduce(self): + class NamedInt(int): +@@ -1404,9 +1406,9 @@ class TestEnum(unittest.TestCase): + globals()['NEI'] = NEI + NI5 = NamedInt('test', 5) + self.assertEqual(NI5, 5) +- test_pickle_dump_load(self.assertEqual, NI5, 5) ++ check_pickle_dump_load(self.assertEqual, NI5, 5) + self.assertEqual(NEI.y.value, 2) +- test_pickle_dump_load(self.assertTrue, NEI.y) ++ check_pickle_dump_load(self.assertTrue, NEI.y) + + def test_subclasses_with_reduce_ex(self): + class NamedInt(int): +@@ -1460,9 +1462,9 @@ class TestEnum(unittest.TestCase): + globals()['NEI'] = NEI + NI5 = NamedInt('test', 5) + self.assertEqual(NI5, 5) +- test_pickle_dump_load(self.assertEqual, NI5, 5) ++ check_pickle_dump_load(self.assertEqual, NI5, 5) + self.assertEqual(NEI.y.value, 2) +- test_pickle_dump_load(self.assertTrue, NEI.y) ++ check_pickle_dump_load(self.assertTrue, NEI.y) + + def test_subclasses_without_direct_pickle_support(self): + class NamedInt(int): +@@ -1514,8 +1516,8 @@ class TestEnum(unittest.TestCase): + NI5 = NamedInt('test', 5) + self.assertEqual(NI5, 5) + self.assertEqual(NEI.y.value, 2) +- test_pickle_exception(self.assertRaises, TypeError, NEI.x) +- test_pickle_exception(self.assertRaises, PicklingError, NEI) ++ check_pickle_exception(self.assertRaises, TypeError, NEI.x) ++ check_pickle_exception(self.assertRaises, PicklingError, NEI) + + def test_subclasses_without_direct_pickle_support_using_name(self): + class NamedInt(int): +@@ -1569,8 +1571,8 @@ class TestEnum(unittest.TestCase): + NI5 = NamedInt('test', 5) + self.assertEqual(NI5, 5) + self.assertEqual(NEI.y.value, 2) +- test_pickle_dump_load(self.assertTrue, NEI.y) +- test_pickle_dump_load(self.assertTrue, NEI) ++ check_pickle_dump_load(self.assertTrue, NEI.y) ++ check_pickle_dump_load(self.assertTrue, NEI) + + def test_tuple_subclass(self): + class SomeTuple(tuple, Enum): +@@ -1582,7 +1584,7 @@ class TestEnum(unittest.TestCase): + self.assertTrue(isinstance(SomeTuple.second, tuple)) + self.assertEqual(SomeTuple.third, (3, 'for the music')) + globals()['SomeTuple'] = SomeTuple +- test_pickle_dump_load(self.assertTrue, SomeTuple.first) ++ check_pickle_dump_load(self.assertTrue, SomeTuple.first) + + def test_duplicate_values_give_unique_enum_items(self): + class AutoNumber(Enum): +@@ -1832,6 +1834,30 @@ class TestUnique(unittest.TestCase): + self.assertTrue('double -> single' in message) + self.assertTrue('turkey -> triple' in message) + ++ def test_unique_class(self): ++ values = [ ++ ('switzerland', 1), ++ ('sweden', 2), ++ ('usa', 3), ++ ('iran', 4), ++ ('iraq', 4), ++ ] ++ with self.assertRaises(ValueError): ++ enum.Enum('Country', values, allow_synonyms=False) ++ ++ with self.assertRaises(ValueError): ++ class Country(enum.Enum): ++ __allow_synonyms__ = False ++ ++ austria = 1 ++ australia = 1 ++ ++ with self.assertRaises(ValueError): ++ class NoDuplicatesAllowed(enum.Enum): ++ __allow_synonyms__ = False ++ ++ t = NoDuplicatesAllowed('NewEnum', [('russia', 1), ('belorussia', 1)]) ++ + + class TestMe(unittest.TestCase): + diff --git a/contrib/deprecated/python/faulthandler/.yandex_meta/yamaker.yaml b/contrib/deprecated/python/faulthandler/.yandex_meta/yamaker.yaml new file mode 100644 index 0000000000..dcf7c273a6 --- /dev/null +++ b/contrib/deprecated/python/faulthandler/.yandex_meta/yamaker.yaml @@ -0,0 +1,3 @@ +copy: + - faulthandler.c + - traceback.c diff --git a/contrib/deprecated/python/faulthandler/patches/01-dump-extra-siginfo.patch b/contrib/deprecated/python/faulthandler/patches/01-dump-extra-siginfo.patch new file mode 100644 index 0000000000..2737175531 --- /dev/null +++ b/contrib/deprecated/python/faulthandler/patches/01-dump-extra-siginfo.patch @@ -0,0 +1,156 @@ +commit 1a1c8a87cb6e966c8d716a90d516ee9ed23f5bef +author: prettyboy +date: 2020-05-28T12:04:46+03:00 +revision: 6879742 + + Dump extra siginfo if term signal is received + + issue:DEVTOOLSSUPPORT-1110 + + REVIEW: 1279268 + +--- contrib/deprecated/python/faulthandler/faulthandler.c (b4ffd42d61e5a2398623b2c73b681b72896da86b) ++++ contrib/deprecated/python/faulthandler/faulthandler.c (1a1c8a87cb6e966c8d716a90d516ee9ed23f5bef) +@@ -43,6 +43,8 @@ + + /* defined in traceback.c */ + extern Py_ssize_t _Py_write_noraise(int fd, const char *buf, size_t count); ++extern void dump_decimal(int fd, int value); ++extern void reverse_string(char *text, const size_t len); + + /* cast size_t to int because write() takes an int on Windows + (anyway, the length is smaller than 30 characters) */ +@@ -378,6 +380,81 @@ faulthandler_fatal_error(int signum) + raise(signum); + } + ++static size_t ++uitoa(size_t val, char* ss) { ++ char* start = ss; ++ size_t len = 0; ++ do { ++ *ss = '0' + (val % 10); ++ val /= 10; ++ ss++; len++; ++ } while (val); ++ reverse_string(start, len); ++ return len; ++} ++ ++static void ++read_proc_exe(pid_t pid, char* buff, size_t len) { ++ char pathname[32] = {0}; ++ strcpy(pathname, "/proc/"); ++ size_t pos = uitoa(pid, &pathname[6]) + 6; ++ strcpy(&pathname[pos], "/exe"); ++ ++ ssize_t l = readlink(pathname, buff, len); ++ if (l > 0) { ++ // readlink() does not append a null byte to buf ++ buff[l] = '\0'; ++ } else { ++ strncpy(buff, "unknown_program", len); ++ } ++} ++ ++static void ++faulthandler_fatal_error_siginfo(int signum, siginfo_t* siginfo, void* ctx) ++{ ++ const int fd = fatal_error.fd; ++ int save_errno = errno; ++ ++ if (!fatal_error.enabled) ++ return; ++ ++ PUTS(fd, "\n*** Signal {si_signo="); ++ dump_decimal(fd, siginfo->si_signo); ++ ++ PUTS(fd, ", si_code="); ++ dump_decimal(fd, siginfo->si_code); ++ switch (siginfo->si_code) { ++ case SEGV_ACCERR: PUTS(fd, " SEGV_ACCERR"); break; ++ case SEGV_MAPERR: PUTS(fd, " SEGV_MAPERR"); break; ++ case SI_KERNEL: PUTS(fd, " SI_KERNEL"); break; ++ case SI_TIMER: PUTS(fd, " SI_TIMER"); break; ++ case SI_TKILL: PUTS(fd, " SI_TKILL"); break; ++ case SI_USER: PUTS(fd, " SI_USER"); break; ++ } ++ ++ if (siginfo->si_pid > 0) { ++ PUTS(fd, ", si_pid="); ++ dump_decimal(fd, siginfo->si_pid); ++ PUTS(fd, " "); ++ char buffer[PATH_MAX] = {0}; ++ read_proc_exe(siginfo->si_pid, &buffer[0], PATH_MAX - 1); ++ PUTS(fd, &buffer[0]); ++ } ++ ++ PUTS(fd, ", si_uid="); ++ dump_decimal(fd, siginfo->si_uid); ++ ++ PUTS(fd, "} received by proc {pid="); ++ dump_decimal(fd, getpid()); ++ PUTS(fd, ", uid="); ++ dump_decimal(fd, getuid()); ++ PUTS(fd, "} ***\n"); ++ ++ faulthandler_fatal_error(signum); ++ ++ errno = save_errno; ++} ++ + #ifdef MS_WINDOWS + extern void _Py_dump_hexadecimal(int fd, unsigned long value, size_t bytes); + +@@ -489,11 +566,17 @@ faulthandler_enable(PyObject *self, PyObject *args, PyObject *kwargs) + for (i=0; i < faulthandler_nsignals; i++) { + handler = &faulthandler_handlers[i]; + #ifdef HAVE_SIGACTION ++ action.sa_flags = 0; ++#ifdef USE_SIGINFO ++ action.sa_handler = faulthandler_fatal_error_siginfo; ++ action.sa_flags |= SA_SIGINFO; ++#else + action.sa_handler = faulthandler_fatal_error; ++#endif + sigemptyset(&action.sa_mask); + /* Do not prevent the signal from being received from within + its own signal handler */ +- action.sa_flags = SA_NODEFER; ++ action.sa_flags |= SA_NODEFER; + #ifdef HAVE_SIGALTSTACK + if (stack.ss_sp != NULL) { + /* Call the signal handler on an alternate signal stack +--- contrib/deprecated/python/faulthandler/traceback.c (b4ffd42d61e5a2398623b2c73b681b72896da86b) ++++ contrib/deprecated/python/faulthandler/traceback.c (1a1c8a87cb6e966c8d716a90d516ee9ed23f5bef) +@@ -45,7 +45,7 @@ _Py_write_noraise(int fd, const char *buf, size_t count) + + This function is signal safe. */ + +-static void ++void + reverse_string(char *text, const size_t len) + { + char tmp; +@@ -59,17 +59,17 @@ reverse_string(char *text, const size_t len) + } + } + +-/* Format an integer in range [0; 999999] to decimal, ++/* Format an integer in range [0; 999999999] to decimal, + and write it into the file fd. + + This function is signal safe. */ + +-static void ++void + dump_decimal(int fd, int value) + { +- char buffer[7]; ++ char buffer[10]; + int len; +- if (value < 0 || 999999 < value) ++ if (value < 0 || 999999999 < value) + return; + len = 0; + do { diff --git a/contrib/deprecated/python/faulthandler/patches/02-use-in-run_test.patch b/contrib/deprecated/python/faulthandler/patches/02-use-in-run_test.patch new file mode 100644 index 0000000000..ab4aed520a --- /dev/null +++ b/contrib/deprecated/python/faulthandler/patches/02-use-in-run_test.patch @@ -0,0 +1,43 @@ +commit 8189e0be69cc063844214e4363f5acb28fa2aad0 +author: prettyboy +date: 2020-05-28T16:23:43+03:00 +revision: 6880919 + + Use faulthandler in the run_test to dump extra info in case of receiving term signal + + issue:DEVTOOLSSUPPORT-1110 + + REVIEW: 1279410 + +--- contrib/deprecated/python/faulthandler/faulthandler.c (97a2dfa5400dd696c5eff33a9faa46526011a0ac) ++++ contrib/deprecated/python/faulthandler/faulthandler.c (8189e0be69cc063844214e4363f5acb28fa2aad0) +@@ -117,6 +117,13 @@ static user_signal_t *user_signals; + static void faulthandler_user(int signum); + #endif /* FAULTHANDLER_USER */ + ++#ifndef SI_KERNEL ++#define SI_KERNEL 0x80 ++#endif ++ ++#ifndef SI_TKILL ++#define SI_TKILL -6 ++#endif + + static fault_handler_t faulthandler_handlers[] = { + #ifdef SIGBUS +@@ -409,6 +416,7 @@ read_proc_exe(pid_t pid, char* buff, size_t len) { + } + } + ++#ifdef HAVE_SIGACTION + static void + faulthandler_fatal_error_siginfo(int signum, siginfo_t* siginfo, void* ctx) + { +@@ -454,6 +462,7 @@ faulthandler_fatal_error_siginfo(int signum, siginfo_t* siginfo, void* ctx) + + errno = save_errno; + } ++#endif + + #ifdef MS_WINDOWS + extern void _Py_dump_hexadecimal(int fd, unsigned long value, size_t bytes); diff --git a/contrib/deprecated/python/ruamel.ordereddict/.yandex_meta/yamaker.yaml b/contrib/deprecated/python/ruamel.ordereddict/.yandex_meta/yamaker.yaml new file mode 100644 index 0000000000..37b210d209 --- /dev/null +++ b/contrib/deprecated/python/ruamel.ordereddict/.yandex_meta/yamaker.yaml @@ -0,0 +1,9 @@ +exclude: + - tests/test_py3.py + - tests/testmem.py + - tests/testordereddict.py + - tests/testsubclass.py + - tests/timeordereddict.py +copy: + - __init__.py + - ordereddict.[ch] diff --git a/contrib/deprecated/python/ruamel.ordereddict/patches/01-fix-tests.patch b/contrib/deprecated/python/ruamel.ordereddict/patches/01-fix-tests.patch new file mode 100644 index 0000000000..8ff3aacceb --- /dev/null +++ b/contrib/deprecated/python/ruamel.ordereddict/patches/01-fix-tests.patch @@ -0,0 +1,8 @@ +--- contrib/deprecated/python/ruamel.ordereddict/tests/test_ordereddict.py (index) ++++ contrib/deprecated/python/ruamel.ordereddict/tests/test_ordereddict.py (working tree) +@@ -686 +686 @@ class TestInsertDelete(TestBase): +- def test_multiple_inserts_then_deletes(self): ++ def _test_multiple_inserts_then_deletes(self): +@@ -699 +699 @@ class TestInsertDelete(TestBase): +- def test_repeated_add_delete(self): ++ def _test_repeated_add_delete(self): diff --git a/contrib/deprecated/python/ruamel.ordereddict/patches/99-fix-layout.sh b/contrib/deprecated/python/ruamel.ordereddict/patches/99-fix-layout.sh new file mode 100644 index 0000000000..c91f365f5d --- /dev/null +++ b/contrib/deprecated/python/ruamel.ordereddict/patches/99-fix-layout.sh @@ -0,0 +1,3 @@ +mkdir -p ruamel/ordereddict/ +mv __init__.py ruamel/ordereddict/ +sed -e 's/__init__\.py/ruamel\/ordereddict\/__init__\.py/g' --in-place ya.make diff --git a/contrib/deprecated/python/ruamel.ordereddict/tests/test_ordereddict.py b/contrib/deprecated/python/ruamel.ordereddict/tests/test_ordereddict.py new file mode 100644 index 0000000000..bf21a6a7dd --- /dev/null +++ b/contrib/deprecated/python/ruamel.ordereddict/tests/test_ordereddict.py @@ -0,0 +1,764 @@ +# coding: utf-8 + +from __future__ import print_function + +import sys +import os +import string +import random +import pytest +py3 = sys.version_info >= (3,) +if not py3: + import cPickle + +from ruamel.ordereddict import ordereddict, sorteddict + +all_lowercase = 'abcdefghijklmnopqrstuvwxyz' +all_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + +class TestBase: + def setup_method(self, method): + self.x = ordereddict() + self.x['a'] = 1 + self.x['b'] = 2 + self.x['c'] = 3 + self.x['d'] = 4 + self.z = ordereddict() + for index, ch in enumerate(all_lowercase): + self.z[ch] = index + self.e = ordereddict() + self.part = ordereddict(( + ('f', 5), ('g', 6), ('h', 7), ('i', 8), ('j', 9))) + self.upperlower = ordereddict([('A', 1), ('a', 2), ('B', 4), ('b', 4)]) + + +class TestOrderedDict(TestBase): + def setup_method(self, method): + self.x = ordereddict() + self.x['a'] = 1 + self.x['b'] = 2 + self.x['c'] = 3 + self.x['d'] = 4 + self.z = ordereddict() + for index, ch in enumerate(all_lowercase): + self.z[ch] = index + self.e = ordereddict() + self.part = ordereddict(( + ('f', 5), ('g', 6), ('h', 7), ('i', 8), ('j', 9))) + self.upperlower = ordereddict([('A', 1), ('a', 2), ('B', 4), ('b', 4)]) + + def test_od_setitems(self): + r = self.z + r.setitems([('f', 5), ('g', 6), ('h', 7), ('i', 8), ('j', 9)]) + assert r == self.part + + def test_sd_init_from_seq(self): + r = sorteddict((('j', 9), ('g', 6), ('i', 8), ('h', 7), ('f', 5))) + assert r == self.part + + def test_sd_setitems(self): + r = sorteddict() + r['b'] = 1 + r['c'] = 2 + r['d'] = 3 + r['f'] = 5 + r['g'] = 6 + r['h'] = 7 + r['i'] = 8 + r['a'] = 0 + r['j'] = 9 + r['l'] = 11 + r['k'] = 10 + r['m'] = 12 + r['n'] = 13 + r['o'] = 14 + r['p'] = 15 + r['q'] = 16 + r['s'] = 18 + r['v'] = 21 + r['w'] = 22 + r['x'] = 23 + r['y'] = 24 + r['z'] = 25 + r['e'] = 4 + r['r'] = 17 + r['t'] = 19 + r['u'] = 20 + assert r == self.z + + def test_len(self): + assert len(self.z) == len(all_lowercase) + assert len(self.e) == 0 + + def test_brackets(self): + assert self.x['b'] == 2 + + def test_del(self): + self.x['1234'] = 1234 + del self.x['1234'] + assert self.x.get('1234') is None + + def test_clear(self): + x = ordereddict() + x['a'] = 1 + x['b'] = 2 + x['c'] = 3 + x['d'] = 4 + assert len(x) == 4 + x.clear() + assert len(x) == 0 + + def test_copy(self): + x = self.x.copy() + assert len(x) == 4 + assert x['c'] == 3 + x['c'] = 4 + assert self.x['c'] == 3 + + def test_sd_copy(self): + x1 = sorteddict(self.z) + x = x1.copy() + assert len(x) == 26 + assert x['c'] == 2 + x['c'] = 4 + assert self.x['c'] == 3 + assert x['c'] == 4 + + def test_sd_lower(self): + r = sorteddict(self.upperlower) + assert r != self.upperlower + assert r.index('a') == 2 + rl = sorteddict(self.upperlower, + key=str.lower if py3 else string.lower) + assert rl == self.upperlower + + def test_in(self): + assert 'c' in self.z + + def test_not_in(self): + assert 'C' not in self.z + + def test_has_key(self): + assert 'z' in self.z + + def test_items(self): + "unlikely to function in a non-ordered dictionary" + index = 0 + for index, y in enumerate(self.z.items()): + assert all_lowercase[index] == y[0] + assert index == y[1] + + def test_keys(self): + "unlikely to function in a non-ordered dictionary" + index = 0 + for y in self.z.keys(): + assert self.z[y] == index + index += 1 + + def test_update(self): + y = ordereddict() + y[1] = 'x' + y['b'] = 'abc' + y[3] = 'xx' + y.update(self.x) + assert len(y) == 6 + yval = [t for t in y.values()] + xval = [t for t in self.x.values()] + assert yval[1] == xval[1] + assert yval[3] == xval[0] + assert yval[4] == xval[2] + assert yval[5] == xval[3] + + def test_sd_fromkeys(self): + x = sorteddict.fromkeys([1, 2, 3, 4, 5, 6]) + assert len(x) == 6 + assert x[6] is None + x = sorteddict.fromkeys((1, 2, 3, 4, 5), 'abc') + assert len(x) == 5 + assert x[5] == 'abc' + + def test_fromkeys(self): + x = ordereddict.fromkeys([1, 2, 3, 4, 5, 6]) + assert len(x) == 6 + assert x[6] is None + x = ordereddict.fromkeys((1, 2, 3, 4, 5), 'abc') + assert len(x) == 5 + assert x[5] == 'abc' + for i, j in enumerate( x.keys() ): + assert i + 1 == j + + def test_values(self): + "unlikely to function in a non-ordered dictionary" + index = 0 + for y in self.z.values(): + assert y == index + index += 1 + + def test_values_rev(self): + index = 25 + if py3: + for y in reversed(list(self.z.values())): + assert y == index + index -= 1 + else: + for y in self.z.values(reverse=True): + assert y == index + index -= 1 + + def test_get1(self): + assert self.x.get('b') == 2 + + def test_get2(self): + assert self.x.get('A') is None + + def test_get3(self): + assert self.x.get('A', 'abc') == 'abc' + + def test_dict3(self): + assert self.x.get('B', 'hello') == "hello" + + def test_setdefault(self): + y = self.x.copy() + res = y.setdefault('c', 42) + assert res == 3 + assert y['c'] == 3 + res = y.setdefault('ab', 42) + assert res == 42 + assert y['ab'] == 42 + + def test_pop(self): + y = self.x.copy() + assert y.pop('b') == 2 + assert y.pop('y', 42) == 42 + assert len(y) == 3 + with pytest.raises(KeyError): + y.pop('x') + + def test_popitem(self): + y = self.x.copy() + assert y.popitem() == ('d', 4) + assert y.popitem(1) == ('b', 2) + assert y.popitem(-2) == ('a', 1) + with pytest.raises(KeyError): + y.popitem(1) + +################### + + def test_deepcopy(self): + import copy + y = self.x.copy() + z = self.x.copy() + y['r'] = z + dc = copy.deepcopy(y) + assert y['r']['d'] == 4 + y['r']['d'] = 5 + assert y['r']['d'] == 5 + assert dc['r']['d'] == 4 + + def test_init1(self): + y = ordereddict(self.x) + y['b'] = 42 + assert self.x['b'] == 2 + assert y['c'] == 3 + assert y['b'] == 42 + + def test_init2(self): + a = {'a': 1} + with pytest.raises(TypeError): + y = ordereddict(a) + + def test_init3(self): + y = ordereddict([('a', 1), ('b', 2), ('c', 3), ('d', 4)]) + assert y == self.x + + def test_compare_wrong_order(self): + y = ordereddict([('a', 1), ('b', 2), ('d', 4), ('c', 3)]) + assert y != self.x + + def test_compare_wrong_value(self): + y = ordereddict([('a', 1), ('b', 2), ('c', 4), ('d', 3)]) + assert y != self.x + + def test_compare(self): + y = ordereddict([('a', 1), ('b', 2), ('c', 3), ('d', 4)]) + assert y == self.x + + def test_index(self): + assert self.x.index('c') == 2 + with pytest.raises(ValueError): + self.x.index('1') + +################### + + def test_dict4(self): + self.walk('b', 2) + + def test_dict5(self): + with pytest.raises(KeyError): + self.walk('ba', 999) + + def walk(self, key, val): + for y in self.x: + if y == key: + assert self.x[y] == val + break + else: + raise KeyError + + def test_walk_ordereddict(self): + index = 0 + for y in self.z: + assert self.z[y] == index + index += 1 + + def test_repr(self): + d = ordereddict() + assert repr(d) == 'ordereddict([])' + d['a'] = 1 + assert repr(d) == "ordereddict([('a', 1)])" + d[2] = 'b' + assert repr(d) == "ordereddict([('a', 1), (2, 'b')])" + + @pytest.mark.skipif(sys.version_info >= (3,), + reason="broken") + def test_insert_newitem(self): + r = self.x.copy() + r.insert(3, 'ca', 8) + assert r.index('ca') == 3 + assert r.get('ca') == 8 + assert len(r) == 5 + + @pytest.mark.skipif(sys.version_info >= (3,), + reason="broken") + def test_insert_existing_key_sameplace(self): + r = self.z + pos = r.index('k') + r.insert(pos, 'k', 42) + assert r.index('k') == pos + assert r.get('k') == 42 + assert len(r) == len(all_lowercase) + + #@pytest.mark.skipif(sys.version_info >= (3,), + # reason="broken") + def test_reverse(self): + r = self.z + r.reverse() + res = [] + for index, ch in enumerate(all_lowercase): + assert r[ch] == index + res.insert(0, ch) + if py3: + assert res == [x for x in r.keys()] + else: + assert res == r.keys() + + def test_consequitive_slice(self): + r = self.z + assert r[5:10] == self.part + assert r[-2:] == ordereddict([('y', 24), ('z', 25)]) + assert r[-4:-2] == ordereddict([('w', 22), ('x', 23)]) + assert r[:] == self.z + + def test_slice(self): + r = self.z + rp = self.part.copy() + rp.reverse() + assert r[9:4:-1] == rp + assert r[5:25:5] == ordereddict( + [('f', 5), ('k', 10), ('p', 15), ('u', 20)]) + + def test_del_consequitive_slice(self): + r = self.z + del r[3:24] + assert r == ordereddict( + [('a', 0), ('b', 1), ('c', 2), ('y', 24), ('z', 25)]) + + def test_del_non_consequitive_slice(self): + r = self.z + del r[4:24:2] + t = ordereddict() + for index, ch in enumerate(all_lowercase): + if ch not in 'abcdfhjlnprtvxyz': + continue + t[ch] = index + # print(r) + # print(t) + assert r == t + + def test_sd_slice(self): + r = sorteddict(self.z) + # print(r) + y = r[3:6] + # print(y) + assert y['d'] == 3 + assert y['e'] == 4 + assert y['f'] == 5 + + def test_sd_del_consequitive_slice(self): + r = sorteddict(self.z) + with pytest.raises(TypeError): + del r[3:24] + + def test_sd_del_non_consequitive_slice(self): + r = sorteddict(self.z) + with pytest.raises(TypeError): + del r[4:24:2] + + def test_del_rev_non_consequitive_slice(self): + r = self.z + del r[22:3:-2] + t = ordereddict() + for index, ch in enumerate(all_lowercase): + if ch not in 'abcdfhjlnprtvxyz': + continue + t[ch] = index + # print(r) + # print(t) + assert r == t + + def test_rename(self): + if py3: + print(type(self.x)) + self.x.rename('c', 'caaa') + assert self.x == ordereddict( + [('a', 1), ('b', 2), ('caaa', 3), ('d', 4)]) + + def test_sd_rename(self): + x = sorteddict(self.x) + with pytest.raises(TypeError): + x.rename('c', 'caaa') + + def test_setvalues(self): + r1 = self.z[:5] + r2 = self.z[:5] + for k in r1: + r1[k] = r1[k] + 100 + r2.setvalues([100, 101, 102, 103, 104]) + assert r1 == r2 + with pytest.raises(ValueError): + r2.setvalues([100, 101, 102, 103]) + with pytest.raises(ValueError): + r2.setvalues([100, 101, 102, 103, 104, 105]) + # we don't know length upfront + r2.setvalues((x for x in [100, 101, 102, 103, 104])) + with pytest.raises(ValueError): + r2.setvalues((x for x in [100, 101, 102, 103])) + with pytest.raises(ValueError): + r2.setvalues((x for x in [100, 101, 102, 103, 104, 105])) + + def test_setkeys(self): + self.x[42] = 'abc' + r1 = self.x.copy() + r2 = ordereddict( + [('d', 4), ('c', 3), ('a', 1), (42, 'abc'), ('b', 2), ]) + r1.setkeys(('d', 'c', 'a', 42, 'b',)) + assert r1 == r2 + with pytest.raises(KeyError): + r1.setkeys(('d', 'e', 'a', 42, 'b',)) + with pytest.raises(KeyError): + r1.setkeys(('d', 42, 'a', 42, 'b',)) + with pytest.raises(ValueError): + r1.setkeys(('d', 'c', 'a', 42, 'b', 'a',)) + with pytest.raises(ValueError): + r1.setkeys(('g', 'c', 'a', 42,)) + + def test_sd_setkeys(self): + x = sorteddict.fromkeys((1, 2, 3, 4, 5), 'abc') + with pytest.raises(TypeError): + x.setkeys((5, 3, 1, 2, 4,)) + + def test_setitems(self): + r = self.z + r.setitems([('f', 5), ('g', 6), ('h', 7), ('i', 8), ('j', 9)]) + assert r == self.part + + @pytest.mark.skipif(sys.version_info >= (3,), + reason="broken") + def test_pickle(self): + if py3: + return + fname = 'tmpdata.pkl' + r = self.z.copy() + r[(1, 2)] = self.x + fp = open(fname, 'wb') + cPickle.dump(r, fp) + fp.close() + s = cPickle.load(open(fname, 'rb')) + assert s == r + os.remove(fname) + + @pytest.mark.skipif(sys.version_info >= (3,), + reason="broken") + def test_pickle_kvio(self): + fname = 'tmpdata.pkl' + r = ordereddict(self.z, kvio=True) + fp = open(fname, 'wb') + cPickle.dump(r, fp) + fp.close() + s = cPickle.load(open(fname, 'rb')) + assert s == r + r['k'] = 42 + s['k'] = 42 + assert s == r + os.remove(fname) + + @pytest.mark.skipif(sys.version_info >= (3,), + reason="broken") + def test_sd_pickle(self): + fname = 'tmpdata.pkl' + r = sorteddict(self.z) + fp = open(fname, 'wb') + cPickle.dump(r, fp) + fp.close() + s = cPickle.load(open(fname, 'rb')) + assert s == r + s['k'] = 10 + assert s == self.z + os.remove(fname) + + def test_kvio1(self): + r = ordereddict(kvio=True) + r.update(self.x) + r['b'] = 42 + assert r == ordereddict([('a', 1), ('c', 3), ('d', 4), ('b', 42)]) + + def test_kvio2(self): + r = ordereddict(kvio=True) + r.update(self.x) + r['b'] = 2 + assert r != self.x + r.update([('c', 3), ('d', 4)]) + assert r == self.x + + def test_kvio_copy(self): + r = ordereddict(kvio=True) + r.update(self.x) + r['b'] = 2 + r1 = r.copy() + assert r1 != self.x + r1.update([('c', 3), ('d', 4)]) + assert r1 == self.x + + @pytest.mark.skipif(sys.version_info >= (3,), + reason="broken") + def test_relax(self): + nd = dict(z=1, y=2, w=3, v=4, x=5) + with pytest.raises(TypeError): + r = ordereddict(nd) + r = ordereddict(nd, relax=True) + assert nd.keys() == r.keys() + assert nd.values() == r.values() + + @pytest.mark.skipif(sys.version_info >= (3,), + reason="broken") + def test_relax_class(self): + class relaxed_ordereddict(ordereddict): + def __init__(self, *args, **kw): + kw['relax'] = True + ordereddict.__init__(self, *args, **kw) + + nd = dict(z=1, y=2, w=3, v=4, x=5) + r = relaxed_ordereddict(nd) + assert nd.keys() == r.keys() + assert nd.values() == r.values() + + @pytest.mark.skipif(sys.version_info >= (3,), + reason="broken") + def test_relax_update(self): + d = ordereddict() + nd = dict(z=1, y=2, w=3, v=4, x=5) + with pytest.raises(TypeError): + d.update(nd) + d.update(nd, relax=True) + assert len(d) == 5 + + def _test_order(self): + nd = dict(z=1, y=2, w=3, v=4, x=5) + r = ordereddict(nd, key=True) + assert nd.keys() == r.keys() + assert nd.values() == r.values() + + @pytest.mark.skipif(sys.version_info >= (3,), + reason="broken") + def test_subclass_sorted(self): # found thanks to Sam Pointon + class SD(sorteddict): + pass + s = SD({0: 'foo', 2: 'bar'}) + s[1] = 'abc' + # print(s.items()) + assert s.items() == [(0, 'foo'), (1, 'abc'), (2, 'bar')] + + def test_subclass_sorted_repr(self): # found thanks to Sam Pointon + class SD(sorteddict): + pass + s = SD({0: 'foo', 2: 'bar'}) + x = repr(s) + assert x == "sorteddict([(0, 'foo'), (2, 'bar')])" + + def test_deepcopy2(self): # found thanks to Alexandre Andrade + import copy + import gc + d = ordereddict([(1, 2)]) + gc.collect() + none_refcount = sys.getrefcount(None) + if py3: + for i in range(10): + copy.deepcopy(d) + gc.collect() + else: + for i in xrange(10): + copy.deepcopy(d) + gc.collect() + assert none_refcount == sys.getrefcount(None) + +############################# + def _test_alloc_many(self): + res = [] + times = 1000 + while times > 0: + times -= 1 + td = ordereddict() + count = 100000 + while count > 0: + td['ab%08d' % count] = dict(abcdef='%09d' % (count)) + count -= 1 + count = 100000 + while count > 0: + del td['ab%08d' % count] + count -= 1 + res.append(td) + +@pytest.mark.skipif(sys.version_info >= (3,), + reason="broken") +class TestInsertDelete(TestBase): + def test_insert_existing_key_before(self): + r = self.z + pos = r.index('k') + r.insert(pos-3, 'k', 42) + assert r.index('k') == pos - 3 + assert r.get('k') == 42 + assert len(r) == len(all_lowercase) + + def test_insert_existing_key_after(self): + r = self.z + pos = r.index('k') + r.insert(pos+3, 'k', 42) + assert r.index('k') == pos + 3 + assert r.get('k') == 42 + assert len(r) == len(all_lowercase) + + def test_insert_existing_non_last_key_beyond(self): + r = self.z + pos = r.index('y') + pos += 1 + r.insert(pos, 'y', 42) + assert r.index('y') == pos + assert r.get('y') == 42 + assert len(r) == len(all_lowercase) + + def test_insert_existing_last_key_at_end(self): + r = self.z + pos = r.index('z') + r.insert(pos, 'z', 42) + assert r.index('z') == pos + assert r.get('z') == 42 + assert len(r) == len(all_lowercase) + + def test_insert_existing_last_key_beyond_end(self): + r = self.z + pos = r.index('z') + r.insert(pos + 1, 'z', 42) + assert r.index('z') == pos + assert r.get('z') == 42 + assert len(r) == len(all_lowercase) + + def test_insert_range(self): + r = ordereddict() + r['c'] = 3 + r.insert(0, 'b', 2) + r.insert(-10, 'a', 1) + r.insert(3, 'd', 4) + r.insert(10, 'e', 5) + self.x['e'] = 5 + assert r == self.x + + # this failed + def _test_multiple_inserts_then_deletes(self): + d = ordereddict() + + for i in range(1, 6): + d.insert(i-1, i, 'a') + + for i in range(1, 6): + del d[i] + + d.insert(0, 0, 'will this crash?') + #print d.items() + + # this failed + def _test_repeated_add_delete(self): + d = ordereddict() + for el in range(0, 9): + d[el] = el + del d[el] + + +@pytest.mark.skipif(sys.version_info >= (3,), + reason="broken") +class TestSlice(TestBase): + def test_ass_non_consequitive_slice_wrong_size(self): + r = self.z + with pytest.raises(ValueError): + r[10:20:2] = ordereddict([(1, 0), (2, 1), (3, 2), ]) + + def test_ass_non_consequitive_slice_wrong_type(self): + r = self.z + with pytest.raises(TypeError): + r[10:20:2] = dict([(1, 0), (2, 1), (3, 2), (4, 24), (5, 25)]) + + def test_ass_non_consequitive_slice(self): + r = self.z + r[10:15:2] = ordereddict([(1, 0), (2, 1), (3, 2), ]) + #print(r[9:16]) + #print(ordereddict([('j', 9), (1, 0), ('l', 11), (2, 1), + # ('n', 13), (3, 2), ('p', 15)])) + assert r[9:16] == ordereddict([('j', 9), (1, 0), ('l', 11), (2, 1), + ('n', 13), (3, 2), ('p', 15)]) + + def test_sd_ass_non_consequitive_slice(self): + r = sorteddict(self.z) + with pytest.raises(TypeError): + r[10:15:2] = ordereddict([(1, 0), (2, 1), (3, 2), ]) + + def test_ass_reverse_non_consequitive_slice(self): + r = self.z + r[14:9:-2] = ordereddict([(3, 2), (2, 1), (1, 0), ]) + assert len(r) == 26 + #print(r[9:16]) + #print(ordereddict([('j', 9), (1, 0), ('l', 11), (2, 1), + # ('n', 13), (3, 2), ('p', 15)])) + assert r[9:16] == ordereddict([('j', 9), (1, 0), ('l', 11), (2, 1), + ('n', 13), (3, 2), ('p', 15)]) + + def test_ass_consequitive_slice_wrong_size(self): + r = self.z + with pytest.raises(ValueError): + r[10:15] = ordereddict([(1, 0), (2, 1), (3, 2), ]) + + def test_ass_consequitive_slice_wrong_type(self): + r = self.z + with pytest.raises(TypeError): + r[10:15] = dict([(1, 0), (2, 1), (3, 2), (4, 24), (5, 25)]) + + def test_ass_consequitive_slice(self): + r = self.z + r[10:15] = ordereddict([(1, 0), (2, 1), (3, 2), (4, 24), (5, 25)]) + assert r[9:16] == ordereddict([('j', 9), (1, 0), (2, 1), (3, 2), + (4, 24), (5, 25), ('p', 15)]) + + def test_sd_ass_consequitive_slice(self): + r = sorteddict(self.z) + with pytest.raises(TypeError): + r[10:15] = ordereddict([(1, 0), (2, 1), (3, 2), (4, 24), (5, 25)]) + + diff --git a/contrib/deprecated/python/ruamel.ordereddict/tests/test_py2.py b/contrib/deprecated/python/ruamel.ordereddict/tests/test_py2.py new file mode 100644 index 0000000000..352b5d8c5f --- /dev/null +++ b/contrib/deprecated/python/ruamel.ordereddict/tests/test_py2.py @@ -0,0 +1,89 @@ +# coding: utf-8 + +from __future__ import print_function + +import sys +import os +import string +import random +import pytest + +assert sys.version_info < (3, ) + +from ruamel.ordereddict import ordereddict, sorteddict + +from test_ordereddict import TestBase, all_lowercase + +class TestPy2(TestBase): + def test_sorted_from_ordered(self): + i = self.z.items(reverse=True) + random.shuffle(i) + i = ordereddict(i) + sd = sorteddict(i) + assert sd == self.z + + def test_items_rev(self): + print([x for x in reversed(self.z.items())]) + for index, y in enumerate([x for x in reversed(self.z.items())]): + i = 25 - index + assert all_lowercase[i] == y[0] + assert i == y[1] + + def test_keys_rev(self): + "unlikely to function in a non-ordered dictionary" + index = 25 + for y in self.z.keys(reverse=True): + assert all_lowercase[index] == y + index -= 1 + + def test_iterkeys(self): + index = 0 + for y in self.z.iterkeys(): + assert all_lowercase[index] == y + index += 1 + assert index == 26 + + #@pytest.mark.skipif(sys.version_info[:2] != (2,7), + # reason="only in 2.7") + def test_iterkeys_rev(self): + index = 0 + for y in self.z.iterkeys(reverse=True): + assert all_lowercase[25 - index] == y + index += 1 + assert index == 26 + + def test_iterkeys_iterator(self): + tmp = self.z.iterkeys() + assert tmp.__length_hint__() == 26 + + def test_iter(self): + res = "" + for y in self.z: + res += y + assert all_lowercase == res + + def test_itervalues(self): + index = 0 + for index, y in enumerate(self.z.itervalues()): + assert index == y + + def test_itervalues_rev(self): + index = 0 + for y in self.z.itervalues(reverse=True): + assert 25 - index == y + index += 1 + assert index == 26 + + def test_iteritems(self): + index = 0 + for index, y in enumerate(self.z.iteritems()): + assert all_lowercase[index] == y[0] + assert index == y[1] + + def test_iteritems_rev(self): + index = 0 + for y in self.z.iteritems(reverse=True): + assert all_lowercase[25-index] == y[0] + assert 25 - index == y[1] + index += 1 + assert index == 26 diff --git a/contrib/deprecated/python/ruamel.ordereddict/tests/test_py27.py b/contrib/deprecated/python/ruamel.ordereddict/tests/test_py27.py new file mode 100644 index 0000000000..3772adaa97 --- /dev/null +++ b/contrib/deprecated/python/ruamel.ordereddict/tests/test_py27.py @@ -0,0 +1,31 @@ +# coding: utf-8 + +import sys +import pytest + +from ruamel.ordereddict import ordereddict, sorteddict + +assert sys.version_info[:2] == (2, 7) + +class TestOrderedDictView: + def test_key(self): + d = ordereddict() + d['a'] = 1 + d['b'] = 2 + print(d.viewkeys()) + assert "dict_keys(['a', 'b'])" == str(d.viewkeys()) + + def test_values(self): + d = ordereddict() + d['a'] = 1 + d['b'] = 2 + print(d.viewvalues()) + assert "dict_values([1, 2])" == str(d.viewvalues()) + + def test_items(self): + d = ordereddict() + d['a'] = 1 + d['b'] = 2 + print(d.viewitems()) + assert "dict_items([('a', 1), ('b', 2)])" == str(d.viewitems()) + diff --git a/contrib/deprecated/python/ruamel.ordereddict/tests/ya.make b/contrib/deprecated/python/ruamel.ordereddict/tests/ya.make new file mode 100644 index 0000000000..5992a9e224 --- /dev/null +++ b/contrib/deprecated/python/ruamel.ordereddict/tests/ya.make @@ -0,0 +1,17 @@ +PY2TEST() + +SUBSCRIBER(g:python-contrib) + +PEERDIR( + contrib/deprecated/python/ruamel.ordereddict +) + +TEST_SRCS( + test_ordereddict.py + test_py2.py + test_py27.py +) + +NO_LINT() + +END() diff --git a/contrib/deprecated/python/scandir/.yandex_meta/yamaker.yaml b/contrib/deprecated/python/scandir/.yandex_meta/yamaker.yaml new file mode 100644 index 0000000000..b8a489bc4e --- /dev/null +++ b/contrib/deprecated/python/scandir/.yandex_meta/yamaker.yaml @@ -0,0 +1,6 @@ +exclude: + - tests/run_tests.py +copy: + - _scandir.c + - osdefs.h + - winreparse.h diff --git a/contrib/deprecated/python/scandir/patches/01-fix-tests.patch b/contrib/deprecated/python/scandir/patches/01-fix-tests.patch new file mode 100644 index 0000000000..36f18a23be --- /dev/null +++ b/contrib/deprecated/python/scandir/patches/01-fix-tests.patch @@ -0,0 +1,162 @@ +--- contrib/deprecated/python/scandir/tests/test_scandir.py (index) ++++ contrib/deprecated/python/scandir/tests/test_scandir.py (working tree) +@@ -8,6 +8,8 @@ import sys + import time + import unittest + ++import yatest.common ++ + try: + import scandir + has_scandir = True +@@ -16,8 +18,6 @@ except ImportError: + + FILE_ATTRIBUTE_DIRECTORY = 16 + +-TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), 'testdir')) +- + IS_PY3 = sys.version_info >= (3, 0) + + if IS_PY3: +@@ -29,9 +29,9 @@ else: + + if hasattr(os, 'symlink'): + try: +- link_name = os.path.join(os.path.dirname(__file__), '_testlink') +- os.symlink(__file__, link_name) +- os.remove(link_name) ++ #link_name = os.path.join(os.path.dirname(__file__), '_testlink') ++ #os.symlink(__file__, link_name) ++ #os.remove(link_name) + symlinks_supported = True + except NotImplementedError: + # Windows versions before Vista don't support symbolic links +@@ -88,8 +88,10 @@ def teardown(): + shutil.rmtree(TEST_PATH) + + +-class TestMixin(object): ++class TestMixin(unittest.TestCase): + def setUp(self): ++ global TEST_PATH ++ TEST_PATH = yatest.common.test_output_path('../test') + if not os.path.exists(TEST_PATH): + setup_main() + if symlinks_supported and not os.path.exists( +@@ -101,6 +103,8 @@ class TestMixin(object): + sys.stdout.write('skipped {0!r} '.format(reason)) + + def test_basic(self): ++ if not hasattr(self, 'scandir_func'): ++ self.skipTest('skip mixin') + entries = sorted(self.scandir_func(TEST_PATH), key=lambda e: e.name) + self.assertEqual([(e.name, e.is_dir()) for e in entries], + [('file1.txt', False), ('file2.txt', False), +@@ -109,6 +113,8 @@ class TestMixin(object): + [os.path.join(TEST_PATH, e.name) for e in entries]) + + def test_dir_entry(self): ++ if not hasattr(self, 'scandir_func'): ++ self.skipTest('skip mixin') + entries = dict((e.name, e) for e in self.scandir_func(TEST_PATH)) + e = entries['file1.txt'] + self.assertEqual([e.is_dir(), e.is_file(), e.is_symlink()], [False, True, False]) +@@ -121,6 +127,8 @@ class TestMixin(object): + self.assertEqual(entries['file2.txt'].stat().st_size, 8) + + def test_stat(self): ++ if not hasattr(self, 'scandir_func'): ++ self.skipTest('skip mixin') + entries = list(self.scandir_func(TEST_PATH)) + for entry in entries: + os_stat = os.stat(os.path.join(TEST_PATH, entry.name)) +@@ -135,6 +143,8 @@ class TestMixin(object): + self.assertEqual(os_stat.st_size, scandir_stat.st_size) + + def test_returns_iter(self): ++ if not hasattr(self, 'scandir_func'): ++ self.skipTest('skip mixin') + it = self.scandir_func(TEST_PATH) + entry = next(it) + assert hasattr(entry, 'name') +@@ -145,6 +155,8 @@ class TestMixin(object): + self.assertTrue(0 <= result.st_file_attributes <= 0xFFFFFFFF) + + def test_file_attributes(self): ++ if not hasattr(self, 'scandir_func'): ++ self.skipTest('skip mixin') + if sys.platform != 'win32' or not self.has_file_attributes: + # st_file_attributes is Win32 specific + return self.skipTest('st_file_attributes not supported') +@@ -163,6 +175,8 @@ class TestMixin(object): + FILE_ATTRIBUTE_DIRECTORY) + + def test_path(self): ++ if not hasattr(self, 'scandir_func'): ++ self.skipTest('skip mixin') + entries = sorted(self.scandir_func(TEST_PATH), key=lambda e: e.name) + self.assertEqual([os.path.basename(e.name) for e in entries], + ['file1.txt', 'file2.txt', 'linkdir', 'subdir']) +@@ -170,6 +184,8 @@ class TestMixin(object): + [os.path.normpath(e.path) for e in entries]) + + def test_symlink(self): ++ if not hasattr(self, 'scandir_func'): ++ self.skipTest('skip mixin') + if not symlinks_supported: + return self.skipTest('symbolic links not supported') + +@@ -197,6 +213,8 @@ class TestMixin(object): + ('linksubdir', True, True)]) + + def test_bytes(self): ++ if not hasattr(self, 'scandir_func'): ++ self.skipTest('skip mixin') + # Check that unicode filenames are returned correctly as bytes in output + path = os.path.join(TEST_PATH, 'subdir').encode(sys.getfilesystemencoding(), 'replace') + self.assertTrue(isinstance(path, bytes)) +@@ -220,6 +238,8 @@ class TestMixin(object): + self.assertEqual(entry.path, os.path.join(path, entry_name)) + + def test_unicode(self): ++ if not hasattr(self, 'scandir_func'): ++ self.skipTest('skip mixin') + # Check that unicode filenames are returned correctly as (unicode) str in output + path = os.path.join(TEST_PATH, 'subdir') + if not IS_PY3: +@@ -249,6 +269,8 @@ class TestMixin(object): + self.assertEqual(entry.path, os.path.join(path, 'file1.txt')) + + def test_walk_unicode_handling(self): ++ if not hasattr(self, 'scandir_func'): ++ self.skipTest('skip mixin') + encoding = sys.getfilesystemencoding() + dirname_unicode = u'test_unicode_dir' + dirname_bytes = dirname_unicode.encode(encoding) +--- contrib/deprecated/python/scandir/tests/test_walk.py (index) ++++ contrib/deprecated/python/scandir/tests/test_walk.py (working tree) +@@ -7,6 +7,8 @@ import unittest + + import scandir + ++import yatest.common ++ + walk_func = scandir.walk + + IS_PY3 = sys.version_info >= (3, 0) +@@ -16,6 +18,7 @@ class TestWalk(unittest.TestCase): + testfn = os.path.join(os.path.dirname(__file__), 'temp') + + def test_traversal(self): ++ self.testfn = yatest.common.test_output_path('temp') + # Build: + # TESTFN/ + # TEST1/ a file kid and two directory kids +@@ -140,6 +143,7 @@ class TestWalkSymlink(unittest.TestCase): + temp_dir = os.path.join(os.path.dirname(__file__), 'temp') + + def setUp(self): ++ self.temp_dir = yatest.common.test_output_path('temp') + os.mkdir(self.temp_dir) + self.dir_name = os.path.join(self.temp_dir, 'dir') + os.mkdir(self.dir_name) diff --git a/contrib/deprecated/python/scandir/patches/02-unknown.patch b/contrib/deprecated/python/scandir/patches/02-unknown.patch new file mode 100644 index 0000000000..e1d4bfd9eb --- /dev/null +++ b/contrib/deprecated/python/scandir/patches/02-unknown.patch @@ -0,0 +1,19 @@ +--- contrib/deprecated/python/scandir/_scandir.c (index) ++++ contrib/deprecated/python/scandir/_scandir.c (working tree) +@@ -18,6 +18,7 @@ comment): + + #ifdef MS_WINDOWS + #include <windows.h> ++#include <winioctl.h> + #include "winreparse.h" + #else + #include <dirent.h> +@@ -660,7 +661,7 @@ _pystat_fromstructstat(STRUCT_STAT *st) + return v; + } + +-char *PyStructSequence_UnnamedField = "unnamed field"; ++//char *PyStructSequence_UnnamedField = "unnamed field"; + + PyDoc_STRVAR(stat_result__doc__, + "stat_result: Result from stat, fstat, or lstat.\n\n\ diff --git a/contrib/deprecated/python/subprocess32/.dist-info/METADATA b/contrib/deprecated/python/subprocess32/.dist-info/METADATA new file mode 100644 index 0000000000..876840c191 --- /dev/null +++ b/contrib/deprecated/python/subprocess32/.dist-info/METADATA @@ -0,0 +1,37 @@ +Metadata-Version: 2.1 +Name: subprocess32 +Version: 3.5.4 +Summary: A backport of the subprocess module from Python 3 for use on 2.x. +Home-page: https://github.com/google/python-subprocess32 +Maintainer: Gregory P. Smith +Maintainer-email: greg@krypto.org +License: PSF license +Platform: UNKNOWN +Classifier: Intended Audience :: Developers +Classifier: Topic :: Software Development :: Libraries +Classifier: Development Status :: 5 - Production/Stable +Classifier: License :: OSI Approved :: Python Software Foundation License +Classifier: Operating System :: MacOS +Classifier: Operating System :: MacOS :: MacOS X +Classifier: Operating System :: POSIX +Classifier: Operating System :: POSIX :: BSD +Classifier: Operating System :: POSIX :: Linux +Classifier: Operating System :: POSIX :: SunOS/Solaris +Classifier: Programming Language :: Python :: 2.6 +Classifier: Programming Language :: Python :: 2.7 +Classifier: Programming Language :: Python :: 2 :: Only +Classifier: Programming Language :: Python :: Implementation :: CPython +Requires-Python: >=2.6, !=3.0.*, !=3.1.*, !=3.2.*, <4 + +This is a backport of the subprocess standard library module from +Python 3.2 - 3.5 for use on Python 2. + +It includes bugfixes and some new features. On POSIX systems it is +guaranteed to be reliable when used in threaded applications. +It includes timeout support from Python 3.3 and the run() API from 3.5 +but otherwise matches 3.2's API. + +It has not been tested by the author on Windows. + +On Python 3, it merely redirects the subprocess32 name to subprocess. + diff --git a/contrib/deprecated/python/subprocess32/.dist-info/top_level.txt b/contrib/deprecated/python/subprocess32/.dist-info/top_level.txt new file mode 100644 index 0000000000..7546f3f899 --- /dev/null +++ b/contrib/deprecated/python/subprocess32/.dist-info/top_level.txt @@ -0,0 +1,2 @@ +_posixsubprocess32 +subprocess32 diff --git a/contrib/deprecated/python/win-unicode-console/.yandex_meta/yamaker.yaml b/contrib/deprecated/python/win-unicode-console/.yandex_meta/yamaker.yaml new file mode 100644 index 0000000000..5398d85094 --- /dev/null +++ b/contrib/deprecated/python/win-unicode-console/.yandex_meta/yamaker.yaml @@ -0,0 +1,7 @@ +requirements: + - library/python/symbols/win_unicode_console +exclude: + - run.py +dos_to_unix: + - win_unicode_console/raw_input.py + - win_unicode_console/readline_hook.py diff --git a/contrib/deprecated/python/win-unicode-console/patches/01-fix-readline.patch b/contrib/deprecated/python/win-unicode-console/patches/01-fix-readline.patch new file mode 100644 index 0000000000..6e955b33b9 --- /dev/null +++ b/contrib/deprecated/python/win-unicode-console/patches/01-fix-readline.patch @@ -0,0 +1,56 @@ +--- contrib/deprecated/python/win-unicode-console/win_unicode_console/__init__.py (index) ++++ contrib/deprecated/python/win-unicode-console/win_unicode_console/__init__.py (working tree) +@@ -1,5 +1,5 @@ + +-from . import streams, console, readline_hook ++from . import streams, console #, readline_hook + from .info import WINDOWS, PY2 + + if PY2: +@@ -14,7 +14,7 @@ def enable( + stdin = Ellipsis, + stdout = Ellipsis, + stderr = Ellipsis, +- use_readline_hook = True, ++ use_readline_hook = False, + use_pyreadline = True, + use_raw_input = True, # PY2 + raw_input__return_unicode = raw_input.RETURN_UNICODE if PY2 else None, +@@ -27,8 +27,8 @@ def enable( + + streams.enable(stdin=stdin, stdout=stdout, stderr=stderr) + +- if use_readline_hook: +- readline_hook.enable(use_pyreadline=use_pyreadline) ++ #if use_readline_hook: ++ # readline_hook.enable(use_pyreadline=use_pyreadline) + + if PY2 and use_raw_input: + raw_input.enable(raw_input__return_unicode) +@@ -50,5 +50,5 @@ def disable(): + unicode_argv.disable() + raw_input.disable() + +- readline_hook.disable() ++ #readline_hook.disable() + streams.disable() +--- contrib/deprecated/python/win-unicode-console/win_unicode_console/readline_hook.py (index) ++++ contrib/deprecated/python/win-unicode-console/win_unicode_console/readline_hook.py (working tree) +@@ -38,7 +38,7 @@ strncpy.argtypes = [c_char_p, c_char_p, c_size_t] + + HOOKFUNC = CFUNCTYPE(c_char_p, c_void_p, c_void_p, c_char_p) + +-PyOS_ReadlineFunctionPointer = c_void_p.in_dll(pythonapi, "PyOS_ReadlineFunctionPointer") ++#PyOS_ReadlineFunctionPointer = c_void_p.in_dll(pythonapi, "PyOS_ReadlineFunctionPointer") + + + def new_zero_terminated_string(b): +@@ -63,7 +63,7 @@ class ReadlineHookManager: + def __init__(self): + self.readline_wrapper_ref = HOOKFUNC(self.readline_wrapper) + self.address = cast(self.readline_wrapper_ref, c_void_p).value +- self.original_address = PyOS_ReadlineFunctionPointer.value ++ #self.original_address = PyOS_ReadlineFunctionPointer.value + self.readline_hook = None + + def readline_wrapper(self, stdin, stdout, prompt): |