| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -955,6 +955,9 @@ Removed | |||
| 955 | 955 | ``SSTATE_INTERNED_IMMORTAL`` macro. | |
| 956 | 956 | (Contributed by Victor Stinner in :gh:`85858`.) | |
| 957 | 957 | ||
| 958 | + * Remove ``Jython`` compatibility hacks from several stdlib modules and tests. | ||
| 959 | + (Contributed by Nikita Sobolev in :gh:`99482`.) | ||
| 960 | + | ||
| 958 | 961 | * Remove ``_use_broken_old_ctypes_structure_semantics_`` flag | |
| 959 | 962 | from :mod:`ctypes` module. | |
| 960 | 963 | (Contributed by Nikita Sobolev in :gh:`99285`.) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -56,11 +56,6 @@ class Error(Exception): | |||
| 56 | 56 | pass | |
| 57 | 57 | error = Error # backward compatibility | |
| 58 | 58 | ||
| 59 | - try: | ||
| 60 | - from org.python.core import PyStringMap | ||
| 61 | - except ImportError: | ||
| 62 | - PyStringMap = None | ||
| 63 | - | ||
| 64 | 59 | __all__ = ["Error", "copy", "deepcopy"] | |
| 65 | 60 | ||
| 66 | 61 | def copy(x): | |
@@ -120,9 +115,6 @@ def _copy_immutable(x): | |||
| 120 | 115 | d[set] = set.copy | |
| 121 | 116 | d[bytearray] = bytearray.copy | |
| 122 | 117 | ||
| 123 | - if PyStringMap is not None: | ||
| 124 | - d[PyStringMap] = PyStringMap.copy | ||
| 125 | - | ||
| 126 | 118 | del d, t | |
| 127 | 119 | ||
| 128 | 120 | def deepcopy(x, memo=None, _nil=[]): | |
@@ -231,8 +223,6 @@ def _deepcopy_dict(x, memo, deepcopy=deepcopy): | |||
| 231 | 223 | y[deepcopy(key, memo)] = deepcopy(value, memo) | |
| 232 | 224 | return y | |
| 233 | 225 | d[dict] = _deepcopy_dict | |
| 234 | - if PyStringMap is not None: | ||
| 235 | - d[PyStringMap] = _deepcopy_dict | ||
| 236 | 226 | ||
| 237 | 227 | def _deepcopy_method(x, memo): # Copy instance methods | |
| 238 | 228 | return type(x)(x.__func__, deepcopy(x.__self__, memo)) | |
@@ -301,4 +291,4 @@ def _reconstruct(x, memo, func, args, | |||
| 301 | 291 | y[key] = value | |
| 302 | 292 | return y | |
| 303 | 293 | ||
| 304 | - del types, weakref, PyStringMap | ||
| 294 | + del types, weakref | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -98,12 +98,6 @@ class _Stop(Exception): | |||
| 98 | 98 | def __init__(self, value): | |
| 99 | 99 | self.value = value | |
| 100 | 100 | ||
| 101 | - # Jython has PyStringMap; it's a dict subclass with string keys | ||
| 102 | - try: | ||
| 103 | - from org.python.core import PyStringMap | ||
| 104 | - except ImportError: | ||
| 105 | - PyStringMap = None | ||
| 106 | - | ||
| 107 | 101 | # Pickle opcodes. See pickletools.py for extensive docs. The listing | |
| 108 | 102 | # here is in kind-of alphabetical order of 1-character pickle code. | |
| 109 | 103 | # pickletools groups them by purpose. | |
@@ -972,8 +966,6 @@ def save_dict(self, obj): | |||
| 972 | 966 | self._batch_setitems(obj.items()) | |
| 973 | 967 | ||
| 974 | 968 | dispatch[dict] = save_dict | |
| 975 | - if PyStringMap is not None: | ||
| 976 | - dispatch[PyStringMap] = save_dict | ||
| 977 | 969 | ||
| 978 | 970 | def _batch_setitems(self, items): | |
| 979 | 971 | # Helper to batch up SETITEMS sequences; proto >= 1 only | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1290,7 +1290,7 @@ def platform(aliased=0, terse=0): | |||
| 1290 | 1290 | else: | |
| 1291 | 1291 | platform = _platform(system, release, version, csd) | |
| 1292 | 1292 | ||
| 1293 | - elif system in ('Linux',): | ||
| 1293 | + elif system == 'Linux': | ||
| 1294 | 1294 | # check for libc vs. glibc | |
| 1295 | 1295 | libcname, libcversion = libc_ver() | |
| 1296 | 1296 | platform = _platform(system, release, machine, processor, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -404,12 +404,7 @@ def setquit(): | |||
| 404 | 404 | def setcopyright(): | |
| 405 | 405 | """Set 'copyright' and 'credits' in builtins""" | |
| 406 | 406 | builtins.copyright = _sitebuiltins._Printer("copyright", sys.copyright) | |
| 407 | - if sys.platform[:4] == 'java': | ||
| 408 | - builtins.credits = _sitebuiltins._Printer( | ||
| 409 | - "credits", | ||
| 410 | - "Jython is maintained by the Jython developers (www.jython.org).") | ||
| 411 | - else: | ||
| 412 | - builtins.credits = _sitebuiltins._Printer("credits", """\ | ||
| 407 | + builtins.credits = _sitebuiltins._Printer("credits", """\ | ||
| 413 | 408 | Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands | |
| 414 | 409 | for supporting Python development. See www.python.org for more information.""") | |
| 415 | 410 | files, dirs = [], [] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -505,6 +505,7 @@ def requires_debug_ranges(reason='requires co_positions / debug_ranges'): | |||
| 505 | 505 | requires_legacy_unicode_capi = unittest.skipUnless(unicode_legacy_string, | |
| 506 | 506 | 'requires legacy Unicode C API') | |
| 507 | 507 | ||
| 508 | + # Is not actually used in tests, but is kept for compatibility. | ||
| 508 | 509 | is_jython = sys.platform.startswith('java') | |
| 509 | 510 | ||
| 510 | 511 | is_android = hasattr(sys, 'getandroidapilevel') | |
@@ -736,8 +737,6 @@ def gc_collect(): | |||
| 736 | 737 | """ | |
| 737 | 738 | import gc | |
| 738 | 739 | gc.collect() | |
| 739 | - if is_jython: | ||
| 740 | - time.sleep(0.1) | ||
| 741 | 740 | gc.collect() | |
| 742 | 741 | gc.collect() | |
| 743 | 742 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,11 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | 13 | # Filename used for testing | |
| 14 | - if os.name == 'java': | ||
| 15 | - # Jython disallows @ in module names | ||
| 16 | - TESTFN_ASCII = '$test' | ||
| 17 | - else: | ||
| 18 | - TESTFN_ASCII = '@test' | ||
| 14 | + TESTFN_ASCII = '@test' | ||
| 19 | 15 | ||
| 20 | 16 | # Disambiguate TESTFN for parallel testing, while letting it remain a valid | |
| 21 | 17 | # module name. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -100,10 +100,9 @@ def test_all(self): | |||
| 100 | 100 | '__future__', | |
| 101 | 101 | ]) | |
| 102 | 102 | ||
| 103 | - if not sys.platform.startswith('java'): | ||
| 104 | - # In case _socket fails to build, make this test fail more gracefully | ||
| 105 | - # than an AttributeError somewhere deep in CGIHTTPServer. | ||
| 106 | - import _socket | ||
| 103 | + # In case _socket fails to build, make this test fail more gracefully | ||
| 104 | + # than an AttributeError somewhere deep in CGIHTTPServer. | ||
| 105 | + import _socket | ||
| 107 | 106 | ||
| 108 | 107 | ignored = [] | |
| 109 | 108 | failed_imports = [] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,47 +2,18 @@ | |||
| 2 | 2 | Test cases for codeop.py | |
| 3 | 3 | Nick Mathewson | |
| 4 | 4 | """ | |
| 5 | - import sys | ||
| 6 | 5 | import unittest | |
| 7 | 6 | import warnings | |
| 8 | - from test import support | ||
| 9 | 7 | from test.support import warnings_helper | |
| 10 | 8 | ||
| 11 | 9 | from codeop import compile_command, PyCF_DONT_IMPLY_DEDENT | |
| 12 | - import io | ||
| 13 | - | ||
| 14 | - if support.is_jython: | ||
| 15 | - | ||
| 16 | - def unify_callables(d): | ||
| 17 | - for n,v in d.items(): | ||
| 18 | - if hasattr(v, '__call__'): | ||
| 19 | - d[n] = True | ||
| 20 | - return d | ||
| 21 | 10 | ||
| 22 | 11 | class CodeopTests(unittest.TestCase): | |
| 23 | 12 | ||
| 24 | 13 | def assertValid(self, str, symbol='single'): | |
| 25 | 14 | '''succeed iff str is a valid piece of code''' | |
| 26 | - if support.is_jython: | ||
| 27 | - code = compile_command(str, "<input>", symbol) | ||
| 28 | - self.assertTrue(code) | ||
| 29 | - if symbol == "single": | ||
| 30 | - d,r = {},{} | ||
| 31 | - saved_stdout = sys.stdout | ||
| 32 | - sys.stdout = io.StringIO() | ||
| 33 | - try: | ||
| 34 | - exec(code, d) | ||
| 35 | - exec(compile(str,"<input>","single"), r) | ||
| 36 | - finally: | ||
| 37 | - sys.stdout = saved_stdout | ||
| 38 | - elif symbol == 'eval': | ||
| 39 | - ctx = {'a': 2} | ||
| 40 | - d = { 'value': eval(code,ctx) } | ||
| 41 | - r = { 'value': eval(str,ctx) } | ||
| 42 | - self.assertEqual(unify_callables(r),unify_callables(d)) | ||
| 43 | - else: | ||
| 44 | - expected = compile(str, "<input>", symbol, PyCF_DONT_IMPLY_DEDENT) | ||
| 45 | - self.assertEqual(compile_command(str, "<input>", symbol), expected) | ||
| 15 | + expected = compile(str, "<input>", symbol, PyCF_DONT_IMPLY_DEDENT) | ||
| 16 | + self.assertEqual(compile_command(str, "<input>", symbol), expected) | ||
| 46 | 17 | ||
| 47 | 18 | def assertIncomplete(self, str, symbol='single'): | |
| 48 | 19 | '''succeed iff str is the start of a valid piece of code''' | |
@@ -62,16 +33,12 @@ def test_valid(self): | |||
| 62 | 33 | av = self.assertValid | |
| 63 | 34 | ||
| 64 | 35 | # special case | |
| 65 | - if not support.is_jython: | ||
| 66 | - self.assertEqual(compile_command(""), | ||
| 67 | - compile("pass", "<input>", 'single', | ||
| 68 | - PyCF_DONT_IMPLY_DEDENT)) | ||
| 69 | - self.assertEqual(compile_command("\n"), | ||
| 70 | - compile("pass", "<input>", 'single', | ||
| 71 | - PyCF_DONT_IMPLY_DEDENT)) | ||
| 72 | - else: | ||
| 73 | - av("") | ||
| 74 | - av("\n") | ||
| 36 | + self.assertEqual(compile_command(""), | ||
| 37 | + compile("pass", "<input>", 'single', | ||
| 38 | + PyCF_DONT_IMPLY_DEDENT)) | ||
| 39 | + self.assertEqual(compile_command("\n"), | ||
| 40 | + compile("pass", "<input>", 'single', | ||
| 41 | + PyCF_DONT_IMPLY_DEDENT)) | ||
| 75 | 42 | ||
| 76 | 43 | av("a = 1") | |
| 77 | 44 | av("\na = 1") | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -360,10 +360,9 @@ def test_capi3(): | |||
| 360 | 360 | self.assertRaises(SystemError, _testcapi.raise_exception, | |
| 361 | 361 | InvalidException, 1) | |
| 362 | 362 | ||
| 363 | - if not sys.platform.startswith('java'): | ||
| 364 | - test_capi1() | ||
| 365 | - test_capi2() | ||
| 366 | - test_capi3() | ||
| 363 | + test_capi1() | ||
| 364 | + test_capi2() | ||
| 365 | + test_capi3() | ||
| 367 | 366 | ||
| 368 | 367 | def test_WindowsError(self): | |
| 369 | 368 | try: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments