Use of -a switch breaks imports

Open
#627 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, python
Domain
compilers

Research direction

Run the two transcrypt commands from the report with the provided test.py example and compare their generated imports. Trace the -a switch handling and import generation, including subsequent * imports and from package import my_module. Done means -a preserves the required runtime imports while retaining the working explicit module import behavior.

Written by the indexing model from the issue text.

Description

IS: bug

I was looking into a recent issue (#616) and it seems there's a bug when using the -a switch.

test.py
print("hello")
transcrypt -n output.js
// Transcrypt'ed from Python, 2019-04-26 09:45:28
import {AssertionError, AttributeError, BaseException, DeprecationWarning, Exception, IndexError, IterableError, KeyError, NotImplementedError, RuntimeWarning, StopIteration, UserWarning, ValueError, Warning, __JsIterator__, __PyIterator__, __Terminal__, __add__, __and__, __call__, __class__, __envir__, __eq__, __floordiv__, __ge__, __get__, __getcm__, __getitem__, __getslice__, __getsm__, __gt__, __i__, __iadd__, __iand__, __idiv__, __ijsmod__, __ilshift__, __imatmul__, __imod__, __imul__, __in__, __init__, __ior__, __ipow__, __irshift__, __isub__, __ixor__, __jsUsePyNext__, __jsmod__, __k__, __kwargtrans__, __le__, __lshift__, __lt__, __matmul__, __mergefields__, __mergekwargtrans__, __mod__, __mul__, __ne__, __neg__, __nest__, __or__, __pow__, __pragma__, __proxy__, __pyUseJsNext__, __rshift__, __setitem__, __setproperty__, __setslice__, __sort__, __specialattrib__, __sub__, __super__, __t__, __terminal__, __truediv__, __withblock__, __xor__, abs, all, any, assert, bool, bytearray, bytes, callable, chr, copy, deepcopy, delattr, dict, dir, divmod, enumerate, filter, float, getattr, hasattr, input, int, isinstance, issubclass, len, list, map, max, min, object, ord, pow, print, property, py_TypeError, py_iter, py_metatype, py_next, py_reversed, py_typeof, range, repr, round, set, setattr, sorted, str, sum, tuple, zip} from './org.transcrypt.__runtime__.js';
var __name__ = '__main__';
print ('hello');

//# sourceMappingURL=sketch.map
transcrypt -n -a output.js
/* 000001 */ // Transcrypt'ed from Python, 2019-04-26 09:44:46
/* 000001 */ import {} from './org.transcrypt.__runtime__.js';
/* 000001 */ var __name__ = '__main__';
/* 000001 */ print ('hello');
/* 000001 */ 
//# sourceMappingURL=sketch.map

Nothing will be imported from transcrypt. In other tests, I determined that it will also ignore any subsequent * imports but will render from package import my_module just fine.

Using transcrypt 3.7.12 on Windows 10

Dominant language
Python
Stars
2.9k
Forks
218
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from TranscryptOrg/Transcrypt

All issues in TranscryptOrg/Transcrypt

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.