Skip to content

Commit 9b11aa7

Browse files
committed
Merge remote-tracking branch 'origin/master' into topic/GR-13107
2 parents 0eff0e3 + 1557a28 commit 9b11aa7

File tree

9 files changed

+1077
-10
lines changed

9 files changed

+1077
-10
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ language runtime. The main focus is on user-observable behavior of the engine.
1818
* Improve performance of `os.scandir` and functions that build on it (such as `glob`)
1919
* More correct implementation of standard streams, including buffering
2020
* Properly support the `-m` switch to run modules
21-
* Support creating ZIP files through the standard `zipfile` module
21+
* Support the standard `zipfile` module
22+
* Add the built-in `_cvs` module
23+
* Add support for `__slots__`
24+
* Allow arbitrary callable objects in methods, not only functions
25+
* Report that we have a TTY console if we are launched on a Terminal through our launcher
26+
* Add the `ginstall` custom module to install known packages such as NumPy and setuptools
2227

2328
## Version 1.0.0 RC10
2429

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,27 @@ To try it, you can use the bundled releases from
1414
some examples of what you can do with it, check out the
1515
[reference](https://www.graalvm.org/docs/reference-manual/languages/python/).
1616

17-
##### Extension modules
17+
### Installing packages
18+
19+
At the moment not enough of the standard library is implemented to run the
20+
standard package installers for many packages. As a convenience, we provide a
21+
simple module to install packages that we know to be working (including
22+
potential patches required for those packages). Try the following to find out
23+
more:
24+
25+
```
26+
graalpython -m ginstall --help
27+
```
28+
29+
As a slightly more exciting example, try:
30+
31+
```
32+
graalpython -m ginstall install numpy
33+
```
34+
35+
If all goes well (you'll need to have `clang`, `llvm-link`, `llvm-extract`,
36+
`llvm-nm`, and `opt` in your `PATH` in addition to the normal NumPy build
37+
dependencies), you should be able to `import numpy` afterwards.
1838

1939
Support for more extension modules is high priority for us. We are actively
2040
building out our support for the Python C API to make extensions such as NumPy,
@@ -34,3 +54,4 @@ Universal Permissive License v 1.0 as shown at
3454
implementation is in part derived from and contains additional code from 3rd
3555
parties, the copyrights and licensing of which is detailed in the
3656
[LICENSE](LICENSE) and [3rd_party_licenses.txt](3rd_party_licenses.txt) files.
57+

graalpython/com.oracle.graal.python.test/src/tests/test_bytes.py

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# The Universal Permissive License (UPL), Version 1.0
@@ -37,6 +37,7 @@
3737
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3838
# SOFTWARE.
3939

40+
import unittest
4041

4142
def assert_raises(err, fn, *args, **kwargs):
4243
raised = False
@@ -534,3 +535,89 @@ def test_strip_bytes():
534535
assert b'abc'.strip(b'ac') == b'b'
535536
assert b'abc'.lstrip(b'ac') == b'bc'
536537
assert b'abc'.rstrip(b'ac') == b'ab'
538+
539+
class BaseTestSplit:
540+
541+
def test_string_error(self):
542+
self.assertRaises(TypeError, self.type2test(b'a b').split, ' ')
543+
self.assertRaises(TypeError, self.type2test(b'a b').rsplit, ' ')
544+
545+
def test_int_error(self):
546+
self.assertRaises(TypeError, self.type2test(b'a b').split, 32)
547+
self.assertRaises(TypeError, self.type2test(b'a b').rsplit, 32)
548+
549+
def test_split_unicodewhitespace(self):
550+
for b in (b'a\x1Cb', b'a\x1Db', b'a\x1Eb', b'a\x1Fb'):
551+
b = self.type2test(b)
552+
self.assertEqual(b.split(), [b])
553+
b = self.type2test(b"\x09\x0A\x0B\x0C\x0D\x1C\x1D\x1E\x1F")
554+
self.assertEqual(b.split(), [b'\x1c\x1d\x1e\x1f'])
555+
556+
def test_rsplit_unicodewhitespace(self):
557+
b = self.type2test(b"\x09\x0A\x0B\x0C\x0D\x1C\x1D\x1E\x1F")
558+
self.assertEqual(b.rsplit(), [b'\x1c\x1d\x1e\x1f'])
559+
560+
def test_memoryview(self):
561+
self.assertEqual(self.type2test(b'a b').split(memoryview(b' ')), [b'a', b'b'])
562+
self.assertEqual(self.type2test(b'c d').rsplit(memoryview(b' ')), [b'c', b'd'])
563+
564+
def test_split(self):
565+
self.assertEqual(self.type2test(b'ahoj jak\tse\nmas').split(), [b'ahoj', b'jak', b'se', b'mas'])
566+
self.assertEqual(self.type2test(b'ahoj jak\tse\nmas').rsplit(), [b'ahoj', b'jak', b'se', b'mas'])
567+
568+
def test_maxsplit(self):
569+
self.assertEqual(self.type2test(b'ahoj jak\tse\nmas').split(maxsplit=1), [b'ahoj', b'jak\tse\nmas'])
570+
self.assertEqual(self.type2test(b'ahoj jak\tse\nmas').rsplit(maxsplit=1), [b'ahoj jak\tse', b'mas'])
571+
572+
def test_maxsplit_zero(self):
573+
self.assertEqual(self.type2test(b'ahoj jak\tse\nmas').split(maxsplit=0), [b'ahoj jak\tse\nmas'])
574+
self.assertEqual(self.type2test(b'ahoj jak\tse\nmas').rsplit(maxsplit=0), [b'ahoj jak\tse\nmas'])
575+
576+
def test_maxsplit_negative(self):
577+
self.assertEqual(self.type2test(b'ahoj jak\tse\nmas').split(maxsplit=-10), [b'ahoj', b'jak', b'se', b'mas'])
578+
self.assertEqual(self.type2test(b'ahoj jak\tse\nmas').rsplit(maxsplit=-10), [b'ahoj', b'jak', b'se', b'mas'])
579+
580+
def test_separator(self):
581+
self.assertEqual(self.type2test(b'ahoj jak\tse\nmas').split(b' '), [b'ahoj', b'jak\tse\nmas'])
582+
self.assertEqual(self.type2test(b'ahoj jak\tse\nmas').rsplit(b' '), [b'ahoj', b'jak\tse\nmas'])
583+
584+
def test_empty(self):
585+
self.assertEqual(self.type2test(b'').split(), [])
586+
self.assertEqual(self.type2test(b'').rsplit(), [])
587+
588+
def test_empty_delim(self):
589+
self.assertEqual(self.type2test(b'').split(b' '), [b''])
590+
self.assertEqual(self.type2test(b'').rsplit(b' '), [b''])
591+
592+
def test_empty_separator(self):
593+
self.assertRaises(ValueError, self.type2test(b'a b').split, b'')
594+
self.assertRaises(ValueError, self.type2test(b'a b').rsplit, b'')
595+
596+
def test_indexable_object(self):
597+
598+
class MyIndexable(object):
599+
def __init__(self, value):
600+
self.value = value
601+
def __index__(self):
602+
return self.value
603+
604+
self.assertEqual(self.type2test(b'ahoj jak\tse\nmas').split(maxsplit=MyIndexable(1)), [b'ahoj', b'jak\tse\nmas'])
605+
self.assertEqual(self.type2test(b'ahoj jak\tse\nmas').rsplit(maxsplit=MyIndexable(1)), [b'ahoj jak\tse', b'mas'])
606+
607+
class BytesSplitTest(BaseTestSplit, unittest.TestCase):
608+
type2test = bytes
609+
610+
class ByteArraySplitTest(BaseTestSplit, unittest.TestCase):
611+
type2test = bytearray
612+
613+
def test_add_mv_to_bytes():
614+
b = b'hello '
615+
mv = memoryview(b'world')
616+
b += mv
617+
assert b == b'hello world'
618+
619+
def test_add_mv_to_bytearray():
620+
ba = bytearray(b'hello ')
621+
mv = memoryview(b'world')
622+
ba += mv
623+
assert ba == b'hello world'

0 commit comments

Comments
 (0)