Comments (8)
I was able to reproduce this on Linux with version 1.36. Very interesting! Digging in a little deeper.
from libpython-clj.
Agreed, this is an interesting one. I wonder if the sys module expects a stack frame and is just quietly exiting early when it doesn't get one.
from libpython-clj.
I can confirm that this is something related to require-python
.
This works (does not throw error):
(require '[libpython-clj.python :as py])
(py/initialize! :no-io-redirect? true)
(require '[libpython-clj.require :refer [require-python]])
(py/import-module "sys")
;;=> :ok
This will reproduce @mharju 's error
(require '[libpython-clj.python :as py])
(py/initialize! :no-io-redirect? true)
(require '[libpython-clj.require :refer [require-python]])
(require-python 'sys)
;;=> Failed to get a pyobject pointer from object.
from libpython-clj.
A stupid hack would be we could just automatically call import-python
when you (require 'libpython-clj.require)
if it turns out that this is isolated to the sys
module.
from libpython-clj.
Well, first let's get a bit more bug reporting discipline going :-).
The stack trace of the error is:
base.clj: 52 libpython-clj.jna.base/ensure-pyobj
base.clj: 48 libpython-clj.jna.base/ensure-pyobj
err.clj: 184 libpython-clj.jna.concrete.err/PyErr-Restore
err.clj: 184 libpython-clj.jna.concrete.err/PyErr-Restore
object.clj: 907 libpython-clj.python.object/python->jvm-iterator/next-fn
Atom.java: 93 clojure.lang.Atom/swapVals
core.clj: 2363 clojure.core/swap-vals!
core.clj: 2357 clojure.core/swap-vals!
object.clj: 920 libpython-clj.python.object/python/reify
RT.java: 523 clojure.lang.RT$4/invoke
LazySeq.java: 42 clojure.lang.LazySeq/sval
LazySeq.java: 51 clojure.lang.LazySeq/seq
RT.java: 535 clojure.lang.RT/seq
core.clj: 137 clojure.core/seq
core.clj: 2746 clojure.core/map/fn
LazySeq.java: 42 clojure.lang.LazySeq/sval
LazySeq.java: 51 clojure.lang.LazySeq/seq
ChunkedCons.java: 59 clojure.lang.ChunkedCons/chunkedNext
ChunkedCons.java: 43 clojure.lang.ChunkedCons/next
RT.java: 713 clojure.lang.RT/next
SeqIterator.java: 41 clojure.lang.SeqIterator/hasNext
RT.java: 522 clojure.lang.RT$4/invoke
LazySeq.java: 42 clojure.lang.LazySeq/sval
LazySeq.java: 51 clojure.lang.LazySeq/seq
RT.java: 535 clojure.lang.RT/seq
core.clj: 137 clojure.core/seq
core.clj: 2746 clojure.core/map/fn
LazySeq.java: 42 clojure.lang.LazySeq/sval
LazySeq.java: 51 clojure.lang.LazySeq/seq
RT.java: 535 clojure.lang.RT/seq
core.clj: 137 clojure.core/seq
core.clj: 2809 clojure.core/filter/fn
LazySeq.java: 42 clojure.lang.LazySeq/sval
LazySeq.java: 51 clojure.lang.LazySeq/seq
ChunkedCons.java: 59 clojure.lang.ChunkedCons/chunkedNext
ChunkedCons.java: 43 clojure.lang.ChunkedCons/next
RT.java: 713 clojure.lang.RT/next
core.clj: 64 clojure.core/next
protocols.clj: 63 clojure.core.protocols/naive-seq-reduce
protocols.clj: 72 clojure.core.protocols/interface-or-naive-reduce
protocols.clj: 169 clojure.core.protocols/fn
protocols.clj: 124 clojure.core.protocols/fn
protocols.clj: 19 clojure.core.protocols/fn/G
protocols.clj: 31 clojure.core.protocols/seq-reduce
protocols.clj: 75 clojure.core.protocols/fn
protocols.clj: 75 clojure.core.protocols/fn
protocols.clj: 13 clojure.core.protocols/fn/G
core.clj: 6828 clojure.core/reduce
core.clj: 6895 clojure.core/into
core.clj: 6887 clojure.core/into
metadata.clj: 231 libpython-clj.metadata/datafy-module
metadata.clj: 208 libpython-clj.metadata/datafy-module
require.clj: 348 libpython-clj.require/eval36195/fn
MultiFn.java: 229 clojure.lang.MultiFn/invoke
require.clj: 360 libpython-clj.require/py-datafy
require.clj: 359 libpython-clj.require/py-datafy
require.clj: 398 libpython-clj.require/eval36238/fn
protocols.clj: 182 clojure.core.protocols/fn/G
datafy.clj: 23 clojure.datafy/datafy
datafy.clj: 15 clojure.datafy/datafy
require.clj: 134 libpython-clj.require/do-require-python
require.clj: 92 libpython-clj.require/do-require-python
require.clj: 276 libpython-clj.require/require-python
require.clj: 177 libpython-clj.require/require-python
require.clj: 274 libpython-clj.require/require-python
require.clj: 177 libpython-clj.require/require-python
So it originates (in my case at least) from here:
https://github.com/clj-python/libpython-clj/blob/master/src/libpython_clj/python/object.clj#L907
Potentially I bound to pyerr_restore incorrectly as one of these objects is nil and perhaps that is OK while I have an explicit check to guarantee they aren't nill in the external C bindings.
from libpython-clj.
Got a bit further. In the metadata analysis of the sys module, we get:
ERROR!! #object[com.sun.jna.Pointer 0x30546999 native@0x7fb311e6bee0] #object[com.sun.jna.Pointer 0x2fd21b2 native@0x7fb3103fe7b0] nil
type #object[com.sun.jna.Pointer 0x30546999 native@0x7fb311e6bee0]
value #object[com.sun.jna.Pointer 0x2fd21b2 native@0x7fb3103fe7b0] dictionary changed size during iteration
from libpython-clj.
that's very interesting. I think it probably has something to do with the stack frames, like you were suggesting.
In [1]: d = {'a': 'b'}
In [2]: for k,v in d.items():
...: d['c'] = v
...:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-2-b538c53f99f1> in <module>
----> 1 for k,v in d.items():
2 d['c'] = v
3
RuntimeError: dictionary changed size during iteration
I'm pretty sure the stack frames are kept in a dictionary.
from libpython-clj.
This might be it:
In [5]: sys._current_frames()
Out[5]:
{140197899065088: <frame at 0x14bd268>,
140197530433280: <frame at 0x14bf4b8>,
140197909653248: <frame at 0x14c6558>,
140197480077056: <frame at 0x14c0008>,
140197496862464: <frame at 0x147ca88>,
140197889885952: <frame at 0x149f258>,
140197513647872: <frame at 0x144b9c8>,
140197929584384: <frame at 0x144c098>,
140198014052160: <frame at 0x14a0d28>}
from libpython-clj.
Related Issues (20)
- Cannot run the example in the tutorial in Cider with JDK 17 HOT 8
- process hanging in embeded mode on exception HOT 2
- from-import does not support "string"
- newbie: I get: `dir already refers to: #'clojure.repl/dir in namespace: user` HOT 2
- Newbie: Lein Clojure Windows Anaconda VSCode Cava REPL Returns (NoClassDefFoundError) HOT 5
- Create Python Module then Import Module and Call Function Inside Clojure? HOT 4
- Fix ubuntu version in dockerfiles HOT 6
- Consider releasing returned values from instance fns
- JDK-20 support HOT 3
- builtins/eval throws 'frame does not exist' HOT 2
- Unable to require libraries from within docker using conda HOT 6
- Failed to find a valid python library on MS-Windows with the official python distributions
- Extend CI coverage to all the mainstream architectures
- require-python missing functions with annotation HOT 3
- Make polyglot development easier by allow require-python to be path-informed HOT 1
- Data transformation pipelines? HOT 1
- NSWindow main thread error when trying to setup Gymnasium (openapi gym) HOT 5
- JVM crashes when requiring `libpython-clj2.require` on 64bit Raspberry Pi 4 HOT 1
- error of unhashable type HOT 15
- Ways to reduce probability of memory leaks? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libpython-clj.