oracle / graalpython

A Python 3 implementation built on GraalVM
Other
1.2k stars 103 forks source link

patch for rich #323

Closed The-Alchemist closed 1 year ago

The-Alchemist commented 1 year ago

PR for rich at https://github.com/Textualize/rich/pull/2873/

without this patch, you get:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Library/Java/JavaVirtualMachines/graalvm-ce-java19-22.3.1/Contents/Home/languages/python/lib-python/3/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Library/Java/JavaVirtualMachines/graalvm-ce-java19-22.3.1/Contents/Home/languages/python/lib-python/3/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/private/tmp/venv/.venv/lib/python3.8/site-packages/rich/__main__.py", line 219, in <module>
    console.print(test_card)
  File "/private/var/folders/hc/lt2k7hw112z6p9c2v94pjvd40000gn/T/pip-unpacked-wheel-bfocmp14/rich/console.py", line 1698, in print
  File "/private/var/folders/hc/lt2k7hw112z6p9c2v94pjvd40000gn/T/pip-unpacked-wheel-bfocmp14/rich/console.py", line 1330, in render
  File "/private/var/folders/hc/lt2k7hw112z6p9c2v94pjvd40000gn/T/pip-unpacked-wheel-bfocmp14/rich/table.py", line 511, in __rich_console__
  File "/private/var/folders/hc/lt2k7hw112z6p9c2v94pjvd40000gn/T/pip-unpacked-wheel-bfocmp14/rich/table.py", line 827, in _render
  File "/private/var/folders/hc/lt2k7hw112z6p9c2v94pjvd40000gn/T/pip-unpacked-wheel-bfocmp14/rich/console.py", line 1370, in render_lines
  File "/private/var/folders/hc/lt2k7hw112z6p9c2v94pjvd40000gn/T/pip-unpacked-wheel-bfocmp14/rich/segment.py", line 292, in split_and_crop_lines
  File "/private/var/folders/hc/lt2k7hw112z6p9c2v94pjvd40000gn/T/pip-unpacked-wheel-bfocmp14/rich/console.py", line 1330, in render
  File "/private/var/folders/hc/lt2k7hw112z6p9c2v94pjvd40000gn/T/pip-unpacked-wheel-bfocmp14/rich/text.py", line 660, in __rich_console__
  File "/private/var/folders/hc/lt2k7hw112z6p9c2v94pjvd40000gn/T/pip-unpacked-wheel-bfocmp14/rich/text.py", line 1189, in wrap
  File "/private/var/folders/hc/lt2k7hw112z6p9c2v94pjvd40000gn/T/pip-unpacked-wheel-bfocmp14/rich/containers.py", line 163, in justify
  File "/private/var/folders/hc/lt2k7hw112z6p9c2v94pjvd40000gn/T/pip-unpacked-wheel-bfocmp14/rich/text.py", line 546, in get_style_at_offset
  File "/private/var/folders/hc/lt2k7hw112z6p9c2v94pjvd40000gn/T/pip-unpacked-wheel-bfocmp14/rich/style.py", line 634, in copy
TypeError: object.__new__(X): X is not a type object (Style)
msimacek commented 1 year ago

How do you reproduce the problem? I think we should be able to fix it on our side without patching rich

The-Alchemist commented 1 year ago

How do you reproduce the problem? I think we should be able to fix it on our side without patching rich

Test Case

class SomeClass:
    def copy(self):
        self.__new__(SomeClass)

def test__new__():
    o = SomeClass()
    o.copy()

Test Output

E       TypeError: object.__new__(X): X is not a type object (SomeClass)

Technical Details

Should I close this and open a new issue?

msimacek commented 1 year ago

I cannot reproduce it with the latest snapshot, I believe it's already fixed.

The-Alchemist commented 1 year ago

I cannot reproduce it with the latest snapshot, I believe it's already fixed.

Awesome, I'll give it a try when the next release comes out.

msimacek commented 1 year ago

I believe we can close this as fixed in a different way.

The-Alchemist commented 1 year ago

I believe we can close this as fixed in a different way.

Correct! rich works OOTB with the latest graalpython. :)