Skip to content

Commit 0f06ca1

Browse files
authored
Merge branch 'main' into Xmader/fix/JSObjectProxy-as-dict
2 parents 93ad631 + c8565d5 commit 0f06ca1

23 files changed

+231
-37
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: File a Bug Report for PythonMonkey
2+
description: Use this template to report PythonMonkey-related issues. Thank you so much for making an issue!
3+
body:
4+
- type: dropdown
5+
id: issue-type
6+
attributes:
7+
label: Issue type
8+
description: What type of issue would you like to report?
9+
multiple: false
10+
options:
11+
- Bug
12+
- Build/Install
13+
- Performance
14+
- Support
15+
- Documentation Bug / Error
16+
- Other
17+
validations:
18+
required: true
19+
20+
- type: dropdown
21+
id: source
22+
attributes:
23+
label: How did you install PythonMonkey?
24+
options:
25+
- Source
26+
- Installed from pip
27+
- Other (Please specify in additional info)
28+
29+
- type: input
30+
id: OS
31+
attributes:
32+
label: OS platform and distribution
33+
placeholder: e.g., Linux Ubuntu 22.04
34+
35+
- type: input
36+
id: Python
37+
attributes:
38+
label: Python version (`python --version`)
39+
placeholder: e.g., 3.9
40+
41+
- type: input
42+
id: PythonMonkey
43+
attributes:
44+
label: PythonMonkey version (`pip show pythonmonkey`)
45+
placeholder: 0.2.0 or 0.0.1.dev997+1eb883
46+
description: You can also get this with `pmjs --version`.
47+
48+
- type: textarea
49+
id: what-happened
50+
attributes:
51+
label: Bug Description
52+
description: Please provide a clear and concise description of what the bug is.
53+
54+
- type: textarea
55+
id: code-to-reproduce
56+
attributes:
57+
label: Standalone code to reproduce the issue
58+
description: Provide a reproducible test case that is the bare minimum necessary to generate the problem.
59+
value:
60+
render: shell
61+
62+
- type: textarea
63+
id: logs
64+
attributes:
65+
label: Relevant log output or backtrace
66+
description: Please copy and paste any relevant log output.
67+
render: shell
68+
69+
- type: textarea
70+
id: additional-info
71+
attributes:
72+
label: Additional info if applicable
73+
description: Anything else to add.
74+
render: shell
75+
76+
- type: input
77+
id: branch
78+
attributes:
79+
label: What branch of PythonMonkey were you developing on? (If applicable)
80+
placeholder: main
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Make a Feature Request for PythonMonkey
2+
description: Use this template to make feature requests for PythonMonkey. Thank you so much for making an issue!
3+
body:
4+
5+
- type: textarea
6+
id: feature-body
7+
attributes:
8+
label: Describe your feature request here.
9+
description: Feel free to include diagrams drawings or anything else to help explain it.
10+
11+
- type: textarea
12+
id: feature-code
13+
attributes:
14+
label: Code example
15+
description: Provide a code example of this feature if applicable.
16+
value:
17+
render: shell
18+

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ If you are having trouble with the CommonJS require function, set environment va
307307
- the `-r` option can be used to load a module before your program or the REPL runs
308308
- the `-e` option can be used evaluate code -- e.g. define global variables -- before your program or the REPL runs
309309
- The REPL can evaluate Python expressions, storing them in variables named `$1`, `$2`, etc. ```
310-
# ./pmjs
310+
# pmjs
311311
Welcome to PythonMonkey v0.2.0.
312312
Type ".help" for more information.
313313
> .python import sys

include/pyTypeFactory.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ PyType *pyTypeFactorySafe(JSContext *cx, JS::Rooted<JSObject *> *thisObj, JS::Ro
4949
* @param args - Pointer to a PyTupleObject containing the arguments to the python function
5050
* @return PyObject* - The result of the JSFunction called with args coerced to JS types, coerced back to a PyObject type, or NULL if coercion wasn't possible
5151
*/
52-
static PyObject *callJSFunc(PyObject *JSFuncAddress, PyObject *args);
52+
PyObject *callJSFunc(PyObject *JSFuncAddress, PyObject *args);
5353

5454
#endif

peter-jr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fi
4646
[ "${1:-}" ] || set "${topDir}/tests/js"
4747
testLocations=("$@")
4848

49-
export PMJS="${topDir}/pmjs"
49+
export PMJS="pmjs"
5050

5151
function panic()
5252
{

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ bump = true
4343

4444
[tool.poetry.build]
4545
script = "build.py"
46-
generate-setup-file = false
46+
generate-setup-file = false
47+
48+
[tool.poetry.scripts]
49+
pmjs = "pythonmonkey.cli.pmjs:main"
4750

4851

4952
[tool.poetry.group.dev.dependencies]

python/pythonmonkey/builtin_modules/util.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/**
22
* @file util.js
3+
* Node.js-style util.inspect implementation, largely based on
4+
* https://github.com/nodejs/node/blob/v8.17.0/lib/util.js.
5+
*
36
* @author Tom Tang <[email protected]>
47
* @date June 2023
58
*/
@@ -532,7 +535,8 @@ function formatValue(ctx, value, recurseTimes, ln) {
532535
// Make error with message first say the error
533536
if (keyLength === 0)
534537
return formatError(ctx, value);
535-
base = ` ${formatError(ctx, value)}`;
538+
base = ` ${formatError(ctx, value)}\n`;
539+
braces.length=0;
536540
} else if (isAnyArrayBuffer(value)) {
537541
// Fast path for ArrayBuffer and SharedArrayBuffer.
538542
// Can't do the same for DataView because it has a non-primitive
@@ -647,10 +651,11 @@ function formatError(ctx, error)
647651
.split('\n')
648652
.filter(a => a.length > 0)
649653
.map(a => ` ${a}`);
650-
return (`${error.name}: ${error.message}\n`
651-
+ stackEls[0] + '\n'
652-
+ style(stackEls.slice(1).join('\n'))
653-
);
654+
const retstr =
655+
`${error.name}: ${error.message}\n`
656+
+ stackEls[0] + '\n'
657+
+ style(stackEls.slice(1).join('\n'));
658+
return retstr;
654659
}
655660

656661
function formatObject(ctx, value, recurseTimes, keys) {
@@ -871,7 +876,12 @@ function reduceToSingleString(ctx, output, base, braces, addLn) {
871876
}
872877
}
873878
if (length <= breakLength)
874-
return `${braces[0]}${base} ${join(output, ', ')} ${braces[1]}`;
879+
{
880+
if (braces.length)
881+
return `${braces[0]}${base} ${join(output, ', ')} ${braces[1]}`;
882+
else
883+
return `${base} ${join(output, ', ')}`;
884+
}
875885
}
876886
// If the opening "brace" is too large, like in the case of "Set {",
877887
// we need to force the first item to be on the next line or the
@@ -881,6 +891,7 @@ function reduceToSingleString(ctx, output, base, braces, addLn) {
881891
const ln = base === '' && braces[0].length === 1 ?
882892
' ' : `${base}\n${indentation} `;
883893
const str = join(output, `,\n${indentation} `);
894+
884895
return `${extraLn}${braces[0]}${ln}${str} ${braces[1]}`;
885896
}
886897

python/pythonmonkey/cli/__init__.py

Whitespace-only changes.

pmjs renamed to python/pythonmonkey/cli/pmjs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def initGlobalThis():
290290

291291
require = pm.createRequire(os.path.abspath(os.getcwd() + '/__pmjs_virtual__'), requirePath)
292292
globalThis.require = require
293-
globalInitModule = require(os.path.dirname(__file__) + "/pmjs-lib/global-init") # module load has side-effects
293+
globalInitModule = require(os.path.dirname(__file__) + "/../lib/pmjs/global-init") # module load has side-effects
294294
argvBuilder = globalInitModule.makeArgvBuilder()
295295
for arg in sys.argv:
296296
argvBuilder(arg); # list=>Array not working yet
File renamed without changes.

0 commit comments

Comments
 (0)