GeezerVison is showing github.com — fix metaclass keyword parameter in class definition, add getcwdb to p… · jython/jython3@d884642
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: CPythonLib.includes +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -20,6 +20,7 @@ _LWPCookieJar.py | 20 | 20 | _MozillaCookieJar.py | 21 | 21 | _pyio.py | 22 | 22 | _strptime.py | | 23 | +_sitebuiltins.py | 23 | 24 | _threading_local.py | 24 | 25 | _weakrefset.py | 25 | 26 | abc.py | |
Collapse file Copy file name to clipboardExpand all lines: lib-python/3.5/abc.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -130,10 +130,10 @@ class ABCMeta(type): | 130 | 130 | _abc_invalidation_counter = 0 | 131 | 131 |
| 132 | 132 | def __new__(mcls, name, bases, namespace): | 133 | | - cls = super().__new__(mcls, name, bases, namespace) | | 133 | + cls = type.__new__(mcls, name, bases, namespace) | 134 | 134 | # Compute set of abstract method names | 135 | 135 | abstracts = {name | 136 | | - for name, value in namespace.items() | | 136 | + for name, value in dict(namespace).items() | 137 | 137 | if getattr(value, "__isabstractmethod__", False)} | 138 | 138 | for base in bases: | 139 | 139 | for name in getattr(base, "__abstractmethods__", set()): | |
Collapse file Copy file name to clipboardExpand all lines: lib-python/3.5/posixpath.py +46-1Lines changed: 46 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 22 | 22 | "ismount", "expanduser","expandvars","normpath","abspath", | 23 | 23 | "samefile","sameopenfile","samestat", | 24 | 24 | "curdir","pardir","sep","pathsep","defpath","altsep","extsep", | 25 | | - "devnull","realpath","supports_unicode_filenames","relpath"] | | 25 | + "devnull","realpath","supports_unicode_filenames","relpath", | | 26 | + "commonpath"] | 26 | 27 |
| 27 | 28 | # Strings representing various path-related bits and pieces. | 28 | 29 | # These are primarily for export; internally, they are hardcoded. | @@ -75,6 +76,8 @@ def join(a, *p): | 75 | 76 | sep = _get_sep(a) | 76 | 77 | path = a | 77 | 78 | try: | | 79 | + if not p: | | 80 | + path[:0] + sep #23780: Ensure compatible data type even if p is null. | 78 | 81 | for b in p: | 79 | 82 | if b.startswith(sep): | 80 | 83 | path = b | @@ -455,3 +458,45 @@ def relpath(path, start=None): | 455 | 458 | except (TypeError, AttributeError, BytesWarning, DeprecationWarning): | 456 | 459 | genericpath._check_arg_types('relpath', path, start) | 457 | 460 | raise | | 461 | + | | 462 | + | | 463 | +# Return the longest common sub-path of the sequence of paths given as input. | | 464 | +# The paths are not normalized before comparing them (this is the | | 465 | +# responsibility of the caller). Any trailing separator is stripped from the | | 466 | +# returned path. | | 467 | + | | 468 | +def commonpath(paths): | | 469 | + """Given a sequence of path names, returns the longest common sub-path.""" | | 470 | + | | 471 | + if not paths: | | 472 | + raise ValueError('commonpath() arg is an empty sequence') | | 473 | + | | 474 | + if isinstance(paths[0], bytes): | | 475 | + sep = b'/' | | 476 | + curdir = b'.' | | 477 | + else: | | 478 | + sep = '/' | | 479 | + curdir = '.' | | 480 | + | | 481 | + try: | | 482 | + split_paths = [path.split(sep) for path in paths] | | 483 | + | | 484 | + try: | | 485 | + isabs, = set(p[:1] == sep for p in paths) | | 486 | + except ValueError: | | 487 | + raise ValueError("Can't mix absolute and relative paths") from None | | 488 | + | | 489 | + split_paths = [[c for c in s if c and c != curdir] for s in split_paths] | | 490 | + s1 = min(split_paths) | | 491 | + s2 = max(split_paths) | | 492 | + common = s1 | | 493 | + for i, c in enumerate(s1): | | 494 | + if c != s2[i]: | | 495 | + common = s1[:i] | | 496 | + break | | 497 | + | | 498 | + prefix = sep if isabs else sep[:0] | | 499 | + return prefix + sep.join(common) | | 500 | + except (TypeError, AttributeError): | | 501 | + genericpath._check_arg_types('commonpath', *paths) | | 502 | + raise |
Collapse file Copy file name to clipboardExpand all lines: src/org/python/compiler/CodeCompiler.java -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -2436,7 +2436,6 @@ public Object visitClassDef(ClassDef node) throws Exception { | 2436 | 2436 | code.aload(baseArray); | 2437 | 2437 | if (node.getInternalKeywords() != null && node.getInternalKeywords().size() > 0) { | 2438 | 2438 | // Assume only keywords parameter is the metaclass | 2439 | | - assert node.getInternalKeywords().get(0).getInternalArg().equals("metaclass"); | 2440 | 2439 | visit(node.getInternalKeywords().get(0).getInternalValue()); | 2441 | 2440 | } else { | 2442 | 2441 | code.aconst_null(); | |
Collapse file Copy file name to clipboardExpand all lines: src/org/python/core/imp.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -548,7 +548,7 @@ private static PyObject loadBuiltin(String name) { | 548 | 548 | Py.writeComment(IMPORT_LOG, "'" + name + "' as sys in builtin modules"); | 549 | 549 | return Py.java2py(Py.getSystemState()); | 550 | 550 | } | 551 | | - if (name == "__builtin__") { | | 551 | + if (name == "__builtin__" || name == "builtins") { | 552 | 552 | Py.writeComment(IMPORT_LOG, "'" + name + "' as __builtin__ in builtin modules"); | 553 | 553 | return new PyModule("__builtin__", Py.getSystemState().builtins); | 554 | 554 | } | |
Collapse file Copy file name to clipboardExpand all lines: src/org/python/modules/_sre.java +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -24,6 +24,8 @@ public class _sre { | 24 | 24 |
| 25 | 25 | // probably the right number for Jython since we are UTF-16. | 26 | 26 | public static int MAXREPEAT = 65535; | | 27 | + | | 28 | + public static int MAXGROUPS = 65535; | 27 | 29 |
| 28 | 30 | // workaround the fact that H, I types are unsigned, but we are not really using them as such | 29 | 31 | // XXX: May not be the right size, but I suspect it is -- see sre_compile.py | |
Collapse file Copy file name to clipboardExpand all lines: src/org/python/modules/posix/PosixModule.java +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -488,16 +488,16 @@ public static void ftruncate(PyObject fd, long length) { | 488 | 488 |
| 489 | 489 | public static PyString __doc__getcwd = new PyString( | 490 | 490 | "getcwd() -> path\n\n" + | 491 | | - "Return a string representing the current working directory."); | | 491 | + "Return a unicode string representing the current working directory."); | 492 | 492 | public static PyObject getcwd() { | 493 | 493 | return Py.newStringOrUnicode(Py.getSystemState().getCurrentWorkingDir()); | 494 | 494 | } | 495 | 495 |
| 496 | | - public static PyString __doc__getcwdu = new PyString( | | 496 | + public static PyString __doc__getcwdb = new PyString( | 497 | 497 | "getcwd() -> path\n\n" + | 498 | | - "Return a unicode string representing the current working directory."); | 499 | | - public static PyObject getcwdu() { | 500 | | - return Py.newUnicode(Py.getSystemState().getCurrentWorkingDir()); | | 498 | + "Return a bytes string representing the current working directory."); | | 499 | + public static PyObject getcwdb() { | | 500 | + return Py.newString(Py.getSystemState().getCurrentWorkingDir()); | 501 | 501 | } | 502 | 502 |
| 503 | 503 | public static PyString __doc__getegid = new PyString( | |
|