Is CONTINUE_LOOP still a thing?

2020-06-09 Thread Adam Preble
I got to the point of trying to implement continue in my own interpreter project and was surprised when my for-loop just used some jumps to manage its control flow. Actually, I hoped for something else; I don't have logic in my code generation to track jump positions. I kind of hoped there was s

Re: Is there some reason that recent Windows 3.6 releases don't included executable nor msi installers?

2020-05-29 Thread Adam Preble
On Friday, May 29, 2020 at 7:30:32 AM UTC-5, Eryk Sun wrote: > On 5/28/20, Adam Preble wrote: > Sometimes a user will open a script via "open with" and browse to > python.exe or py.exe. This associates .py files with a new progid that > doesn't pass the %* comma

Re: Is there some reason that recent Windows 3.6 releases don't included executable nor msi installers?

2020-05-28 Thread Adam Preble
On Thursday, May 28, 2020 at 7:57:04 PM UTC-5, Terry Reedy wrote: > The OP is so far choosing to not use an installer with those fixes. By > not doing so, he is missing out on the maybe 2000 non-security fixes and > some enhancements that likely would benefit him more than maybe 50 > mostly obs

Is there some reason that recent Windows 3.6 releases don't included executable nor msi installers?

2020-05-22 Thread Adam Preble
I wanted to update from 3.6.8 on Windows without necessarily moving on to 3.7+ (yet), so I thought I'd try 3.6.9 or 3.6.10. All I see for both are source archives: https://www.python.org/downloads/release/python-369/ https://www.python.org/downloads/release/python-3610/ So, uh, I theoretically

Import machinery for extracting non-modules from modules (not using import-from)

2020-05-03 Thread Adam Preble
The (rightful) obsession with modules in PEP-451 and the import machinery hit me with a gotcha when I was trying to implement importing .NET stuff that mimicked IronPython and Python.NET in my interpreter project. The meat of the question: Is it important that the spec loader actually return a m

How does the import machinery handle relative imports?

2020-04-22 Thread Adam Preble
I'm fussing over some details of relative imports while trying to mimic Python module loading in my personal project. This is getting more into corner cases, but I can spare time to talk about it while working on more normal stuff. I first found this place: https://manikos.github.io/how-pythons-

Re: Why generate POP_TOP after an "import from?"

2020-04-18 Thread Adam Preble
On Saturday, April 18, 2020 at 1:15:35 PM UTC-5, Alexandre Brault wrote: > >>> def f(): > ... â â from sys import path, argv ... So I figured it out and all but I wanted to ask about the special characters in that output. I've seen that a few times and never figured out what's going on and if

Re: Why generate POP_TOP after an "import from?"

2020-04-18 Thread Adam Preble
On Friday, April 17, 2020 at 1:37:18 PM UTC-5, Chris Angelico wrote: > The level is used for package-relative imports, and will basically be > the number of leading dots (eg "from ...spam import x" will have a > level of 3). You're absolutely right with your analysis, with one > small clarification

Re: Why generate POP_TOP after an "import from?"

2020-04-17 Thread Adam Preble
On Friday, April 17, 2020 at 1:22:18 PM UTC-5, Adam Preble wrote: > At this point, my conceptual stack is empty. If I POP_TOP then I have nothing > to pop and the world would end. Yet, it doesn't. What am I missing? Check out this guy replying to himself 10 minutes later. I guess

Why generate POP_TOP after an "import from?"

2020-04-17 Thread Adam Preble
Given this in Python 3.6.8: from dis import dis def import_from_test(): from sys import path >>> dis(import_from_test) 2 0 LOAD_CONST 1 (0) 2 LOAD_CONST 2 (('path',)) 4 IMPORT_NAME 0 (sys) 6 IMPORT_

Re: How does the super type present itself and do lookups?

2020-03-22 Thread Adam Preble
On Thursday, March 19, 2020 at 5:02:46 PM UTC-5, Greg Ewing wrote: > On 11/03/20 7:02 am, Adam Preble wrote: > > Is this foo attribute being looked up in an override of __getattr__, > > __getattribute__, or is it a reserved slot that's internally doing this? > > That&#

Re: How does the super type present itself and do lookups?

2020-03-10 Thread Adam Preble
On Tuesday, March 10, 2020 at 9:28:11 AM UTC-5, Peter Otten wrote: > self.foo looks up the attribute in the instance, falls back to the class and > then works its way up to the parent class, whereas > > super().foo bypasses both instance and class, and starts its lookup in the > parent class. I

Re: How does the super type present itself and do lookups?

2020-03-09 Thread Adam Preble
On Monday, March 9, 2020 at 9:31:45 PM UTC-5, Souvik Dutta wrote: > This should be what you are looking for. > https://python-reference.readthedocs.io/en/latest/docs/functions/super.html I'm not trying to figure out how the super() function works, but rather the anatomy of the object is returns.

Re: How does the super type present itself and do lookups?

2020-03-09 Thread Adam Preble
On Wednesday, March 4, 2020 at 11:13:20 AM UTC-6, Adam Preble wrote: > Stuff I'm speculating that the stuff I don't see when poking are reserved slots. I figured out how much of a thing that is when I was digging around for how classes know how to construct themselves. I managed

How does the super type present itself and do lookups?

2020-03-04 Thread Adam Preble
Months ago, I asked a bunch of stuff about super() and managed to fake it well enough to move on to other things for awhile. The day of reckoning came this week and I was forced to implement it better for my personal Python project. I have a hack in place that makes it work well-enough but I fou

Re: Data model and attribute resolution in subclasses

2020-03-02 Thread Adam Preble
On Monday, March 2, 2020 at 3:12:33 PM UTC-6, Marco Sulla wrote: > Is your project published somewhere? What changes have you done to the > interpreter? I'm writing my own mess: https://github.com/rockobonaparte/cloaca It's a .NET Pythonish interpreter with the distinction of using a whole lot of

Re: Data model and attribute resolution in subclasses

2020-03-02 Thread Adam Preble
On Monday, March 2, 2020 at 7:09:24 AM UTC-6, Lele Gaifax wrote: > Yes, you just used it, although you may have confused its meaning: > Yeah I absolutely got it backwards. That's a fun one I have to fix in my project now! -- https://mail.python.org/mailman/listinfo/python-list

Re: Data model and attribute resolution in subclasses

2020-03-01 Thread Adam Preble
On Sunday, March 1, 2020 at 3:08:29 PM UTC-6, Terry Reedy wrote: > Because BaseClass is the superclass of SubClass. So there's a mechanism for parent classes to know all their children? -- https://mail.python.org/mailman/listinfo/python-list

Re: Data model and attribute resolution in subclasses

2020-03-01 Thread Adam Preble
Based on what I was seeing here, I did some experiments to try to understand better what is going on: class BaseClass: def __init__(self): self.a = 1 def base_method(self): return self.a def another_base_method(self): return self.a + 1 class SubClass(BaseCl

Data model and attribute resolution in subclasses

2020-02-27 Thread Adam Preble
I have been making some progress on my custom interpreter project but I found I have totally blown implementing proper subclassing in the data model. What I have right now is PyClass defining what a PyObject is. When I make a PyObject from a PyClass, the PyObject sets up a __dict__ that is used

Understanding bytecode arguments: 1 byte versus 2 bytes

2020-01-06 Thread adam . preble
I'm trying to understand the difference in disassemblies with 3.6+ versus older versions of CPython. It looks like the basic opcodes like LOAD_FAST are 3 bytes in pre-3.6 versions, but 2 bytes in 3.6+. I read online somewhere that there was a change to the argument sizes in 3.6: it became 2 byte

Re: Plumbing behind super()

2019-06-29 Thread adam . preble
Thanks for the replies from everybody. It looks like I should double check super_init and see what truck is coming from that which will hit me with a gotcha later. I'm very naively right now plucking the class from my locals and I was able to proceed in the very, very short term. I think I woul

Re: Plumbing behind super()

2019-06-27 Thread adam . preble
I was wrong in the last email because I accidentally in super_gettro instead of super_init. Just for some helper context: >>> class Foo: ... pass ... >>> class Bar(Foo): ... def __init__(self): ... super().__init__() ... self.a = 2 ... >>> dis(Bar) Disassembly of __init__: 3

Re: Plumbing behind super()

2019-06-27 Thread adam . preble
On Thursday, June 27, 2019 at 8:30:21 PM UTC-5, DL Neil wrote: > I'm mystified by "literally given nothing". I'm focusing there particularly on the syntax of writing "super()" without any arguments to it. However, internally it's getting fed stuff. > If a class has not defined an attribute, eg s

Plumbing behind super()

2019-06-27 Thread adam . preble
I'm trying to mimick Python 3.6 as a .NET science project and have started to get into subclassing. The super() not-a-keyword-honestly-guys has tripped me up. I have to admit that I've professionally been doing a ton Python 2.7, so I'm not good on my Python 3.6 trivia yet. I think I have the gen

Re: From parsing a class to code object to class to mappingproxy to object (oh my!)

2019-04-05 Thread adam . preble
On Friday, April 5, 2019 at 5:54:42 PM UTC-5, Gregory Ewing wrote: > But when compiling a class body, it uses a dict to hold the > locals, and generates LOAD_NAME and STORE_NAME opcodes to > access it. > > These opcodes actually date from very early versions of > Python, when locals were always ke

Re: From parsing a class to code object to class to mappingproxy to object (oh my!)

2019-04-04 Thread adam . preble
On Thursday, April 4, 2019 at 1:17:02 PM UTC-5, adam@gmail.com wrote: > Thanks for the response. I was meaning to write back earlier, but I've been > spending my free Python time in the evenings reimplementing what I'm doing to > work more correctly. I'm guessing before the code object repre

Re: From parsing a class to code object to class to mappingproxy to object (oh my!)

2019-04-04 Thread adam . preble
On Monday, April 1, 2019 at 1:23:42 AM UTC-5, Gregory Ewing wrote: > adam.pre...@gmail.com wrote: > https://eli.thegreenplace.net/2012/06/15/under-the-hood-of-python-class-definitions > > Briefly, it creates a dict to serve as the class's namespace dict, > then executes the class body function pas

From parsing a class to code object to class to mappingproxy to object (oh my!)

2019-03-31 Thread adam . preble
I have been mimicking basic Python object constructs successfully until I started trying to handle methods as well in my hand-written interpreter. At that point, I wasn't sure where to stage all the methods before they get shuffled over to an actual instance of an object. I'm having to slap this

Re: log file

2019-03-21 Thread adam . preble
On Thursday, March 21, 2019 at 10:26:14 PM UTC-5, Sharan Basappa wrote: > I am running a program and even though the program runs all fine, the log > file is missing. I have pasted first few lines of the code. > I am thinking--hoping, rather--that you just kind of double pasted there. Anyways, y

Re: REPL, global, and local scoping

2019-03-21 Thread adam . preble
On Tuesday, March 19, 2019 at 9:49:48 PM UTC-5, Chris Angelico wrote: > I would recommend parsing in two broad steps, as CPython does: > > 1) Take the source code and turn it into an abstract syntax tree > (AST). This conceptualizes the behaviour of the code more-or-less the > way the programmer w

Re: REPL, global, and local scoping

2019-03-19 Thread adam . preble
On Tuesday, March 19, 2019 at 3:48:27 PM UTC-5, Chris Angelico wrote: > > I can see in vartest() that it's using a LOAD_GLOBAL for that, yet first() > > and second() don't go searching upstairs for a meow variable. What is the > > basis behind this? > > > > Both first() and second() assign to th

REPL, global, and local scoping

2019-03-19 Thread adam . preble
I got hit on the head and decided to try to write something of a Python interpreter for embedding. I'm starting to get into the ugly stuff like scoping. This has been a good way to learn the real deep details of the language. Here's a situation: >>> meow = 10 >>> def vartest(): ... x = 1 ..

pip not resolving newer package than required dependency

2018-08-27 Thread adam . preble
I have a module with a dependency specifically on pillow>=4.2.1. We are using an internal PyPI that has removed the pillow 4.x series, but it does have 5.2.0. If we try to install pillow>=4.2.1 it doesn't find anything. If we just instruct pip to install pillow, then it will end up installing pi

Re: Distributing a Python module as .rpm and .deb packages across major distributions

2018-06-13 Thread adam . preble
On Sunday, June 10, 2018 at 3:05:45 PM UTC-5, Barry wrote: > The way I learn about the details of RPM packaging is to look at examples > like what I wish to achieve. > > I would go get the source RPM for a python2 package from each distro you want > to supoort and read its .spec file. > > I se

Distributing a Python module as .rpm and .deb packages across major distributions

2018-06-08 Thread adam . preble
I have a situation where internally I need to distribute some Python code using Linux packages rather than simply relying on wheel files. This seems to be a solved problem because a lot of Python modules clearly get distributed as .rpm and .deb. It's not completely unreasonable because soon I wi

Re: Is it possible to make a unittest decorator to rename a method from "x" to "testx?"

2013-08-11 Thread adam . preble
On Friday, August 9, 2013 1:31:43 AM UTC-5, Peter Otten wrote: > I see I have to fix it myself then... Sorry man, I think in my excitement of seeing the first of your examples to work, that I missed the second example, only seeing your comments about it at the end of the post. I didn't expect s

Re: Resolving import errors reported by PyLint in modules using Python.NET

2013-08-11 Thread adam . preble
I thought I responded to this. Oh well On Friday, August 9, 2013 12:47:43 AM UTC-5, Benjamin Kaplan wrote: > Are you using Python.NET or IronPython? IronPython is reasonably well > > supported, and it looks like there's a patch you can use to get PyLint > > working on it (see > > http://mail.

Resolving import errors reported by PyLint in modules using Python.NET

2013-08-08 Thread adam . preble
PyLint can't figure out imports of .NET code being referenced in my Python scripts that use Python.NET. I can kind of see why; you have to evaluate some clr.AddReference calls for the imports to even succeed. I wonder if I have any recourse. Generally, to import a DLL you have to do a few thi

Re: Is it possible to make a unittest decorator to rename a method from "x" to "testx?"

2013-08-08 Thread adam . preble
On Thursday, August 8, 2013 3:50:47 AM UTC-5, Peter Otten wrote: > Peter Otten wrote: > Oops, that's an odd class name. Fixing the name clash in Types.__new__() is > > left as an exercise... Interesting, I got __main__.T, even though I pretty much just tried your code wholesale. For what it's

Re: Is it possible to make a unittest decorator to rename a method from "x" to "testx?"

2013-08-08 Thread adam . preble
On Thursday, August 8, 2013 3:04:30 AM UTC-5, Terry Reedy wrote: > I cannot help but note that this is *more* typing. But anyhow, something It wasn't so much about the typing so much as having "test" in front of everything. It's a problem particular to me since I'm writing code that, well, run

Re: Is it possible to make a unittest decorator to rename a method from "x" to "testx?"

2013-08-08 Thread adam . preble
On Thursday, August 8, 2013 3:50:47 AM UTC-5, Peter Otten wrote: > Peter Otten wrote: > Oops, that's an odd class name. Fixing the name clash in Types.__new__() is > > left as an exercise... I will do some experiments with a custom test loader since I wasn't aware of that as a viable alternativ

Is it possible to make a unittest decorator to rename a method from "x" to "testx?"

2013-08-07 Thread adam . preble
We were coming into Python's unittest module from backgrounds in nunit, where they use a decorate to identify tests. So I was hoping to avoid the convention of prepending "test" to the TestClass methods that are to be actually run. I'm sure this comes up all the time, but I mean not to have to