Paul Sokolovsky
9e29666bf9
py: Implement proper separation between io.FileIO and io.TextIOWrapper.
io.FileIO is binary I/O, ans actually optional. Default file type is
io.TextIOWrapper, which provides str results. CPython3 explicitly describes
io.TextIOWrapper as buffered I/O, but we don't have buffering support yet
anyway.
11 years ago
Paul Sokolovsky
767e45c290
modos: Clean 64-bit issues.
11 years ago
Paul Sokolovsky
0c124c3123
unix: Add "_os" module with stat().
stat() is bad function to use using FFI, because its ABI is largely private.
To start with, Glibc .so doesn't even have "stat" symbol. Then, layout of
struct stat is too implementation-dependent. So, introduce _os to deal
with stat() and other similar cases.
11 years ago
Paul Sokolovsky
da9f0924ef
py, unix: Add copyright for modules I worked closely on.
11 years ago
Damien George
cc97446ca5
unix: Implement -O option to turn off __debug__ flag.
11 years ago
Damien George
96f137b24a
py: Rename BYTE_CODE to BYTECODE (this was missed in previous rename).
11 years ago
stijn
f42dbb98d1
unix: Fix linker errors when time/ffi modules are disabled
When disabling these via mpconfigport.mk or on the commandline,
the correspoding build options are not set and the sources are not
built so the modules should not be added to the
MICROPY_EXTRA_BUILTIN_MODULES list since they are undefined.
11 years ago
Antonin ENFRUN
da1fffaa09
Fix some unused variables, and silence a clang warning about initialization override in vmentrytable.h
11 years ago
Antonin ENFRUN
ceac71f1f5
unix: Add asm statements needed to read registers with clang. Code generated by gcc 4.9.0 is unchanged (same statements, different order).
Both are inefficient, saving unmodified registers on the stack.
11 years ago
Antonin ENFRUN
6caae0bcb1
unix: Create __bss_start and _end symbols for Mach-O targets.
It's a hack, but can't find a cleaner way to do it.
11 years ago
stijn
9e040b7cd8
unix: Use standard return codes for main
As in the CPython manual: "Unix programs generally use 2 for
command line syntax errors and 1 for all other kind of errors"
11 years ago
Damien George
89755ae67f
py: Rename MICROPY_SYS_EXIT to MICROPY_MOD_SYS_EXIT.
For consistency with MICROPY_MOD_SYS_STDFILES, etc.
11 years ago
Paul Sokolovsky
deaeaac469
modsys: Enable sys.exit() per port after all.
11 years ago
Paul Sokolovsky
d99e9083cb
modsys, unix: Add sys.exit(), should be implemented by a port.
11 years ago
Paul Sokolovsky
d80e2476c7
py: Disable frozenset by default, enable on unix.
Takes 416 text bytes on x86.
11 years ago
stijn
f45a83d7fc
mingw: Fix compilation issues
- use lowercase windows.h
- fix for mingw32 using preprocessor-unfriendly definition of CLOCKS_PER_SEC
11 years ago
stijn
5ed284a15e
windows: Add modtime implementation
11 years ago
Damien George
7c6c843965
unix: Add missing stdio.h header for readline.
11 years ago
Dave Hylands
117c46d9eb
Add input command for unix
11 years ago
Paul Sokolovsky
0ef015b253
stream: Make non-blcoking stream support configurable.
Enable only on unix. To avoid unpleasant surprises with error codes.
11 years ago
Paul Sokolovsky
6c62e7257f
unix modsocket: Add comments re: recv() vs read(), etc. semantics.
11 years ago
Paul Sokolovsky
f9e54e0ea5
modgc: Add new module for GC-related functionality.
11 years ago
Paul Sokolovsky
6b344d7816
py, unix: Add -v option, print bytecode dump if used.
This will work if MICROPY_DEBUG_PRINTERS is defined, which is only for
unix/windows ports. This makes it convenient to user uPy normally, but
easily get bytecode dump on the spot if needed, without constant recompiles
back and forth.
TODO: Add more useful debug output, adjust verbosity level on which
specifically bytecode dump happens.
11 years ago
Damien George
c327c0de5d
unix: Remove test class and code.
11 years ago
Damien George
04b9147e15
Add license header to (almost) all files.
Blanket wide to all .c and .h files. Some files originating from ST are
difficult to deal with (license wise) so it was left out of those.
Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
11 years ago
Damien George
d5f5b2f766
py, stream: Implement readlines for a stream.
11 years ago
Damien George
6ec835dfef
Don't print git hash as well as git tag in banner.
11 years ago
Damien George
977a0ce287
py: Print tag/version/git describe in uPy banner.
11 years ago
Damien George
e69b7e8288
unix, file.c: adhere to coding conventions.
11 years ago
stijn
4cd21deebc
mingw: Add implementation of realpath()
The mingw port used _fullpath() until now, but the behaviour is not exactly
the same as realpath()'s on unix; major difference being that it doesn't
return an error for non-existing files, which would bypass main's error
checking and bail out without any error message.
Also realpath() will return forward slashes only since main() relies on that.
11 years ago
stijn
a89e93e050
CPython compatibility: raise an error for operations on a closed file descriptor
In CPython any operations on a file that has been closed already reaises
a ValueError with message "I/O operation on closed file"
11 years ago
Paul Sokolovsky
9b71b16a94
unix,stmhal: Make "mpconfig.h" be first included, as other headers depend on it.
11 years ago
Paul Sokolovsky
f54bcbf099
py, unix: Make "mpconfig.h" be first included, as other headers depend on it.
Specifically, nlr.h does.
11 years ago
Paul Sokolovsky
1f85d6255d
py: Add tentative scheme for error messages configuration.
11 years ago
Paul Sokolovsky
27f5bdd6d4
py: "read" & "write" are so common that make them core.
Few other strings move to core, but make depend on "io" module.
11 years ago
Damien George
6d3c5e4301
Add ARRAY_SIZE macro, and use it where possible.
11 years ago
Paul Sokolovsky
12a9cfed76
modsocket: Make .send() support arbitrary objects with buffer interface.
This is CPython-compliant (except that CPython doesn't support buffer
protocol for str).
11 years ago
Paul Sokolovsky
fa6f0506c1
unix: Workaround MP_OBJ_NEW_SMALL_INT() 64-bit issues.
11 years ago
Paul Sokolovsky
5d3a830171
modsocket: Clean up OSError-like exception a bit.
Some BSD socket functions don't return error numbers in errno namespace, but
rather in other error namespaces. CPython resolves this by using OSError
subclasses for them. We don't do that so far, so there's ambiguity here.
11 years ago
Paul Sokolovsky
acb13886fc
unix: OSError's args[0] should be errno numeric value.
Well, Python3 also defines an attribute for that, but that's bloat.
11 years ago
Paul Sokolovsky
b418b6fb0d
modffi: Don't use OSError for clearly unrelated errors.
11 years ago
Paul Sokolovsky
88972b0d94
modffi: Describe typecodes where they differ from used by struct module.
Exact behavior of typecodes may be not yet enforced.
11 years ago
Paul Sokolovsky
a196d08dfc
unix windows: mingw32 doesn't have realpath(), use _fullpath() instead.
11 years ago
Paul Sokolovsky
1f2ca1c1f9
unix file: mingw32 has STDIN_FILENO and friends in stdio.h .
TODO: Never "optimize" includes any more!
11 years ago
Paul Sokolovsky
b76fd842f0
unix mem_info(): Dump GC info only if it's enabled.
11 years ago
Paul Sokolovsky
9fd02e186d
modsocket: Add setblocking() method.
11 years ago
Ilya Dmitrichenko
8e998ed280
modffi: Fix how we call `pkg-config`
11 years ago
Paul Sokolovsky
9ae0912496
modffi: Update for MP_OBJ_STOP_ITERATION refactor.
11 years ago
Paul Sokolovsky
752d2080b7
modffi: Mark 'p' type spec deprecated, replace with 'P'.
'p' in struct module is "pascal string". 'P' is void*.
11 years ago
Damien George
b11b85adaa
py: Allow to pass buffer protocol flags to get_buffer helper funcs.
11 years ago