kivy / kivy/pyobjus

KeyError at field_list.append()

Open
#70 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
192
Forks
47
PR merge metrics
No merged PRs in 30d

Description

I am trying to use pyobjus to access the view with the following code:
```
logging.debug("getting UIApplication")
app_cls=autoclass("UIApplication")
logging.debug("getting shared UIApplication obj")
app=app_cls.sharedApplication()
logging.debug("getting key window")
win=app.keyWindow
logging.debug("getting root view controller")
ctrl=win.rootViewController()
logging.debug("getting the view")
vw=ctrl.view()
logging.debug("getting the safe area insets")
logging.debug(dir(vw)) # problem 1
insets=vw.safeAreaInsets() # problem 2
```
However, it isn't working. dir(vw) returns a long blank string and calling safeAreaInsets() triggers an exception:
```
Traceback (most recent call last):
File "/Users/kent/vocabassistant-ios/YourApp/main.py", line 3, in
File "/Users/kent/vocabassistant-ios/YourApp/vocab_assistant.py", line 48, in __init__
File "/Users/kent/vocabassistant-ios/YourApp/safe_area.py", line 30, in get_safe_area
File "pyobjus/pyobjus.pyx", line 488, in pyobjus.pyobjus.ObjcMethod.__call__
File "pyobjus/pyobjus_conversions.pxi", line 262, in pyobjus.pyobjus.convert_cy_ret_to_py
File "/Users/kent/Library/Developer/CoreSimulator/Devices/D196DB9F-6194-4D47-B7BD-F2DFE8670DBC/data/Containers/Bundle/Application/C9B64836-4B91-41F6-837E-B2EBFB763E2E/vocabassistant.app/lib/python3.8/site-packages/pyobjus/objc_py_types.py", line 175, in find_object
return self.make_type(obj_type, members=members)
File "/Users/kent/Library/Developer/CoreSimulator/Devices/D196DB9F-6194-4D47-B7BD-F2DFE8670DBC/data/Containers/Bundle/Application/C9B64836-4B91-41F6-837E-B2EBFB763E2E/vocabassistant.app/lib/python3.8/site-packages/pyobjus/objc_py_types.py", line 144, in make_type
field_list.append((field_name, types[_type]))
KeyError: b'd'
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with pyobjus/objc_py_types.py at make_type(), then trace the conversion from pyobjus.pyx and pyobjus_conversions.pxi for UIView.safeAreaInsets. Reproduce the UIApplication/view sequence and inspect why field_list.append() receives the unsupported type b'd'. Done means the safe-area call no longer raises KeyError and the reported view inspection behavior is addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, objective-c, python
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.